From 006fb4fc9e0bf63a16fa43f42f6df03cce9c4807 Mon Sep 17 00:00:00 2001 From: Sai Date: Tue, 12 Nov 2024 10:00:11 +0800 Subject: [PATCH] TerminusManifest to OlaresManifest --- internal/constants/constants.go | 2 +- internal/models/app_info.go | 4 +-- internal/validate/appcfg_validate.go | 6 ++-- internal/validate/appcfg_validate_test.go | 36 +++++++++++------------ internal/validate/resource_check.go | 4 +-- pkg/apiserver/service/v1/handler_dev.go | 4 +-- 6 files changed, 28 insertions(+), 28 deletions(-) diff --git a/internal/constants/constants.go b/internal/constants/constants.go index d621784..53c7520 100644 --- a/internal/constants/constants.go +++ b/internal/constants/constants.go @@ -11,7 +11,7 @@ const ( DataPath = "./data" ChartsLocalDir = "./data/charts" ChartsLocalTempDir = "./data/chartsTmp" - AppCfgFileName = "TerminusManifest.yaml" + AppCfgFileName = "OlaresManifest.yaml" ) const ( diff --git a/internal/models/app_info.go b/internal/models/app_info.go index d4518ab..3a53f37 100644 --- a/internal/models/app_info.go +++ b/internal/models/app_info.go @@ -215,8 +215,8 @@ type AppMetaData struct { } type AppConfiguration struct { - ConfigVersion string `yaml:"terminusManifest.version" json:"terminusManifest.version"` - ConfigType string `yaml:"terminusManifest.type" json:"terminusManifest.type"` + ConfigVersion string `yaml:"olaresManifest.version" json:"olaresManifest.version"` + ConfigType string `yaml:"olaresManifest.type" json:"olaresManifest.type"` Metadata AppMetaData `yaml:"metadata" json:"metadata"` Entrances []EntranceFromCfg `yaml:"entrances" json:"entrances" bson:"entrance"` Spec AppSpec `yaml:"spec" json:"spec"` diff --git a/internal/validate/appcfg_validate.go b/internal/validate/appcfg_validate.go index 4ba06c8..f1bbcee 100644 --- a/internal/validate/appcfg_validate.go +++ b/internal/validate/appcfg_validate.go @@ -24,7 +24,7 @@ func init() { } type AppConfiguration struct { - ConfigVersion string `yaml:"terminusManifest.version" json:"terminusManifest.version" vd:"len($)>0;msg:sprintf('invalid parameter: %v;terminusManifest.version must satisfy the expr: len($)>0',$)"` + ConfigVersion string `yaml:"olaresManifest.version" json:"olaresManifest.version" vd:"len($)>0;msg:sprintf('invalid parameter: %v;olaresManifest.version must satisfy the expr: len($)>0',$)"` Metadata AppMetaData `yaml:"metadata" json:"metadata"` Entrances []Entrance `yaml:"entrances" json:"entrances" vd:"len($)>0 && len($)<=10;msg:sprintf('invalid parameter: %v;entrances must satisfy the expr: len($)>0 && len($)<=10',$)"` Spec AppSpec `yaml:"spec,omitempty" json:"spec,omitempty"` @@ -207,7 +207,7 @@ func getAppConfigFromCfgFile(chartPath string) (*AppConfiguration, error) { if !strings.HasSuffix(chartPath, "/") { chartPath += "/" } - f, err := os.Open(chartPath + "TerminusManifest.yaml") + f, err := os.Open(chartPath + "OlaresManifest.yaml") if err != nil { return nil, err } @@ -339,7 +339,7 @@ func CheckAppData(cfg *AppConfiguration, chartPath string) error { scanner := bufio.NewScanner(f) for scanner.Scan() { if p.MatchString(scanner.Text()) { - rerr = fmt.Errorf("found .Values.userspace.appCache in %s, but not set permission.appCache in TerminusManifest.yaml", filepath.Base(path)) + rerr = fmt.Errorf("found .Values.userspace.appCache in %s, but not set permission.appCache in OlaresManifest.yaml", filepath.Base(path)) } } } diff --git a/internal/validate/appcfg_validate_test.go b/internal/validate/appcfg_validate_test.go index f2e32b7..82f89a9 100644 --- a/internal/validate/appcfg_validate_test.go +++ b/internal/validate/appcfg_validate_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/assert" ) -const metaAndEntrance = `terminusManifest.version: v1 +const metaAndEntrance = `olaresManifest.version: v1 metadata: name: nginx description: "n8n is an extendable workflow automation tool." @@ -27,13 +27,13 @@ entrances: title: nginx ` -const metaAndEntranceWithoutMeta = `terminusManifest.version: v1 +const metaAndEntranceWithoutMeta = `olaresManifest.version: v1 entrances: - name: nginx-service port: 80 title: nginx ` -const metaAndEntranceWithoutEntrance = `terminusManifest.version: v1 +const metaAndEntranceWithoutEntrance = `olaresManifest.version: v1 metadata: name: nginx description: "n8n is an extendable workflow automation tool." @@ -45,7 +45,7 @@ metadata: - utils ` -const appSpec = `terminusManifest.version: v1 +const appSpec = `olaresManifest.version: v1 metadata: name: nginx description: "n8n is an extendable workflow automation tool." @@ -68,7 +68,7 @@ spec: limitedCpu: 500m ` -const appCfgWithPermission = `terminusManifest.version: v1 +const appCfgWithPermission = `olaresManifest.version: v1 metadata: name: nginx description: "n8n is an extendable workflow automation tool." @@ -98,7 +98,7 @@ Permission: ops: - get ` -const appCfgWithPermissionWithEmptyOps = `terminusManifest.version: v1 +const appCfgWithPermissionWithEmptyOps = `olaresManifest.version: v1 metadata: name: nginx description: "n8n is an extendable workflow automation tool." @@ -126,7 +126,7 @@ Permission: dataType: sys version: v1 ` -const appCfgWithMiddleware = `terminusManifest.version: v1 +const appCfgWithMiddleware = `olaresManifest.version: v1 metadata: name: nginx description: "n8n is an extendable workflow automation tool." @@ -169,7 +169,7 @@ middleware: - name: index0 ` -const appCfgWithMiddlewareWithMultiRedisDb = `terminusManifest.version: v1 +const appCfgWithMiddlewareWithMultiRedisDb = `olaresManifest.version: v1 metadata: name: nginx description: "n8n is an extendable workflow automation tool." @@ -213,7 +213,7 @@ middleware: - name: index0 ` -const appCfgWithOptionsWithPolicy = `terminusManifest.version: v1 +const appCfgWithOptionsWithPolicy = `olaresManifest.version: v1 metadata: name: nginx description: "n8n is an extendable workflow automation tool." @@ -241,7 +241,7 @@ options: oneTime: false validDuration: "3600s" ` -const appCfgWithOptionsWithPolicyDuration1 = `terminusManifest.version: v1 +const appCfgWithOptionsWithPolicyDuration1 = `olaresManifest.version: v1 metadata: name: nginx description: "n8n is an extendable workflow automation tool." @@ -269,7 +269,7 @@ options: oneTime: false validDuration: "1h1h" ` -const appCfgWithOptionsWithPolicyDuration2 = `terminusManifest.version: v1 +const appCfgWithOptionsWithPolicyDuration2 = `olaresManifest.version: v1 metadata: name: nginx description: "n8n is an extendable workflow automation tool." @@ -298,7 +298,7 @@ options: validDuration: "-1h5ms5us8ns" ` -const appCfgWithOptionsWithPolicyDuration3 = `terminusManifest.version: v1 +const appCfgWithOptionsWithPolicyDuration3 = `olaresManifest.version: v1 metadata: name: nginx description: "n8n is an extendable workflow automation tool." @@ -327,7 +327,7 @@ options: validDuration: "100" ` -const appCfgWithOptionsWithAnalytics = `terminusManifest.version: v1 +const appCfgWithOptionsWithAnalytics = `olaresManifest.version: v1 metadata: name: nginx description: "n8n is an extendable workflow automation tool." @@ -353,7 +353,7 @@ options: enabled: true ` -const appCfgWithOptionsWithDependencies = `terminusManifest.version: v1 +const appCfgWithOptionsWithDependencies = `olaresManifest.version: v1 metadata: name: nginx description: "n8n is an extendable workflow automation tool." @@ -384,7 +384,7 @@ options: type: application ` -const appCfgWithOptionsWithDependenciesErrorType = `terminusManifest.version: v1 +const appCfgWithOptionsWithDependenciesErrorType = `olaresManifest.version: v1 metadata: name: nginx description: "n8n is an extendable workflow automation tool." @@ -415,7 +415,7 @@ options: type: applications ` -const appCfgWithAll = `terminusManifest.version: v1 +const appCfgWithAll = `olaresManifest.version: v1 metadata: name: nginx description: "n8n is an extendable workflow automation tool." @@ -481,7 +481,7 @@ options: type: application ` -const appCfgWith11Entrances = `terminusManifest.version: v1 +const appCfgWith11Entrances = `olaresManifest.version: v1 metadata: name: nginx description: "n8n is an extendable workflow automation tool." @@ -635,7 +635,7 @@ func TestChartAppCfg(t *testing.T) { err = vd.Validate(cfg, true) err = checkAppCfg(cfg, "./testdata/nextcloud2") if err != nil { - t.Error("TerminusManifest.yaml validate failed", err) + t.Error("olaresManifest.yaml validate failed", err) } } diff --git a/internal/validate/resource_check.go b/internal/validate/resource_check.go index a8d9a83..b4e6a2b 100644 --- a/internal/validate/resource_check.go +++ b/internal/validate/resource_check.go @@ -93,10 +93,10 @@ func checkResourceLimit(resources kube.ResourceList, cfg *AppConfiguration) erro } } if limitCPU > appLimitedCPU { - errs = append(errs, fmt.Errorf("sum of all containers resources limits cpu should less than TerminusManifest.yaml spec.limitedCpu")) + errs = append(errs, fmt.Errorf("sum of all containers resources limits cpu should less than OlaresManifest.yaml spec.limitedCpu")) } if limitMemory > appLimitedMemory { - errs = append(errs, fmt.Errorf("sum of all containers resources limits memory should less than TerminusManifest.yaml spec.limitedMemory")) + errs = append(errs, fmt.Errorf("sum of all containers resources limits memory should less than OlaresManifest.yaml spec.limitedMemory")) } return AggregateErr(errs) } diff --git a/pkg/apiserver/service/v1/handler_dev.go b/pkg/apiserver/service/v1/handler_dev.go index 29cbed7..0983ba6 100644 --- a/pkg/apiserver/service/v1/handler_dev.go +++ b/pkg/apiserver/service/v1/handler_dev.go @@ -89,10 +89,10 @@ func validChart(chartDir string, info *models.ApplicationInfo) (err error) { switch info.CfgType { case constants.AppType: case constants.RecommendType, constants.AgentType, constants.ModelType, constants.MiddlewareType: //todo - glog.Infof("terminusManifest.type:%s do not check chart", info.CfgType) + glog.Infof("olaresManifest.type:%s do not check chart", info.CfgType) return default: - err = fmt.Errorf("terminusManifest.type %s must in %v", info.CfgType, constants.ValidTypes) + err = fmt.Errorf("olaresManifest.type %s must in %v", info.CfgType, constants.ValidTypes) return }