chore(cli): Removed appName from config schema. This is redundant to metadata name
This commit is contained in:
parent
5f0eccd315
commit
5d6fd8fc59
9 changed files with 14 additions and 68 deletions
|
|
@ -335,7 +335,7 @@ func (rm *EdgeConnectResourceManager) createInstance(ctx context.Context, action
|
|||
},
|
||||
AppKey: edgeconnect.AppKey{
|
||||
Organization: action.Target.Organization,
|
||||
Name: config.Spec.GetAppName(),
|
||||
Name: config.Metadata.Name,
|
||||
Version: config.Spec.GetAppVersion(),
|
||||
},
|
||||
Flavor: edgeconnect.Flavor{
|
||||
|
|
|
|||
|
|
@ -131,7 +131,6 @@ func createTestManagerConfig(t *testing.T) *config.EdgeConnectConfig {
|
|||
},
|
||||
Spec: config.Spec{
|
||||
K8sApp: &config.K8sApp{
|
||||
AppName: "test-app",
|
||||
AppVersion: "1.0.0",
|
||||
ManifestFile: manifestFile,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ func (p *EdgeConnectPlanner) planAppAction(ctx context.Context, config *config.E
|
|||
|
||||
// Build desired app state
|
||||
desired := &AppState{
|
||||
Name: config.Spec.GetAppName(),
|
||||
Name: config.Metadata.Name,
|
||||
Version: config.Spec.GetAppVersion(),
|
||||
Organization: config.Spec.InfraTemplate[0].Organization, // Use first infra template for org
|
||||
Region: config.Spec.InfraTemplate[0].Region, // Use first infra template for region
|
||||
|
|
@ -204,11 +204,10 @@ func (p *EdgeConnectPlanner) planInstanceActions(ctx context.Context, config *co
|
|||
var warnings []string
|
||||
|
||||
for _, infra := range config.Spec.InfraTemplate {
|
||||
instanceName := getInstanceName(config.Spec.GetAppName(), config.Spec.GetAppVersion())
|
||||
instanceName := getInstanceName(config.Metadata.Name, config.Spec.GetAppVersion())
|
||||
|
||||
desired := &InstanceState{
|
||||
Name: instanceName,
|
||||
AppName: config.Spec.GetAppName(),
|
||||
AppVersion: config.Spec.GetAppVersion(),
|
||||
Organization: infra.Organization,
|
||||
Region: infra.Region,
|
||||
|
|
|
|||
|
|
@ -106,7 +106,6 @@ func createTestConfig(t *testing.T) *config.EdgeConnectConfig {
|
|||
},
|
||||
Spec: config.Spec{
|
||||
K8sApp: &config.K8sApp{
|
||||
AppName: "test-app",
|
||||
AppVersion: "1.0.0",
|
||||
ManifestFile: manifestFile,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ func TestParseExampleConfig(t *testing.T) {
|
|||
parser := NewParser()
|
||||
|
||||
// Parse the actual example file (now that we've created the manifest file)
|
||||
examplePath := filepath.Join("../examples/comprehensive/EdgeConnectConfig.yaml")
|
||||
examplePath := filepath.Join("../../sdk/examples/comprehensive/EdgeConnectConfig.yaml")
|
||||
config, err := parser.ParseFile(examplePath)
|
||||
|
||||
// This should now succeed with full validation
|
||||
|
|
@ -27,7 +27,6 @@ func TestParseExampleConfig(t *testing.T) {
|
|||
|
||||
// Check k8s app configuration
|
||||
require.NotNil(t, config.Spec.K8sApp)
|
||||
assert.Equal(t, "edge-app-demo", config.Spec.K8sApp.AppName)
|
||||
assert.Equal(t, "1.0.0", config.Spec.K8sApp.AppVersion)
|
||||
// Note: ManifestFile path should be resolved to absolute path
|
||||
assert.Contains(t, config.Spec.K8sApp.ManifestFile, "k8s-deployment.yaml")
|
||||
|
|
@ -58,14 +57,14 @@ func TestParseExampleConfig(t *testing.T) {
|
|||
assert.Equal(t, "0.0.0.0/0", conn2.RemoteCIDR)
|
||||
|
||||
// Test utility methods
|
||||
assert.Equal(t, "edge-app-demo", config.Spec.GetAppName())
|
||||
assert.Equal(t, "edge-app-demo", config.Metadata.Name)
|
||||
assert.Equal(t, "1.0.0", config.Spec.GetAppVersion())
|
||||
assert.Contains(t, config.Spec.GetManifestFile(), "k8s-deployment.yaml")
|
||||
assert.True(t, config.Spec.IsK8sApp())
|
||||
assert.False(t, config.Spec.IsDockerApp())
|
||||
|
||||
// Test instance name generation
|
||||
instanceName := GetInstanceName(config.Spec.GetAppName(), config.Spec.GetAppVersion())
|
||||
instanceName := GetInstanceName(config.Metadata.Name, config.Spec.GetAppVersion())
|
||||
assert.Equal(t, "edge-app-demo-1.0.0-instance", instanceName)
|
||||
}
|
||||
|
||||
|
|
@ -80,7 +79,6 @@ func TestValidateExampleStructure(t *testing.T) {
|
|||
},
|
||||
Spec: Spec{
|
||||
DockerApp: &DockerApp{ // Use DockerApp to avoid manifest file validation
|
||||
AppName: "edge-app-demo",
|
||||
AppVersion: "1.0.0",
|
||||
Image: "nginx:latest",
|
||||
},
|
||||
|
|
@ -127,4 +125,4 @@ func TestValidateExampleStructure(t *testing.T) {
|
|||
// Test port range validation
|
||||
err = parser.ValidatePortRanges(config)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ metadata:
|
|||
name: "test-app"
|
||||
spec:
|
||||
k8sApp:
|
||||
appName: "test-app"
|
||||
appVersion: "1.0.0"
|
||||
manifestFile: "./test-manifest.yaml"
|
||||
infraTemplate:
|
||||
|
|
@ -55,7 +54,6 @@ metadata:
|
|||
name: "test-app"
|
||||
spec:
|
||||
dockerApp:
|
||||
appName: "test-app"
|
||||
appVersion: "1.0.0"
|
||||
image: "nginx:latest"
|
||||
infraTemplate:
|
||||
|
|
@ -74,7 +72,6 @@ metadata:
|
|||
name: "test-app"
|
||||
spec:
|
||||
k8sApp:
|
||||
appName: "test-app"
|
||||
appVersion: "1.0.0"
|
||||
manifestFile: "./test-manifest.yaml"
|
||||
infraTemplate:
|
||||
|
|
@ -95,7 +92,6 @@ metadata:
|
|||
name: "test-app"
|
||||
spec:
|
||||
dockerApp:
|
||||
appName: "test-app"
|
||||
appVersion: "1.0.0"
|
||||
image: "nginx:latest"
|
||||
infraTemplate:
|
||||
|
|
@ -133,7 +129,6 @@ metadata:
|
|||
name: "test-app"
|
||||
spec:
|
||||
k8sApp:
|
||||
appName: "test-app"
|
||||
appVersion: "1.0.0"
|
||||
manifestFile: "./test-manifest.yaml"
|
||||
dockerApp:
|
||||
|
|
@ -158,7 +153,6 @@ metadata:
|
|||
name: "test-app"
|
||||
spec:
|
||||
dockerApp:
|
||||
appName: "test-app"
|
||||
appVersion: "1.0.0"
|
||||
image: "nginx:latest"
|
||||
infraTemplate: []
|
||||
|
|
@ -174,7 +168,6 @@ metadata:
|
|||
name: "test-app"
|
||||
spec:
|
||||
dockerApp:
|
||||
appName: "test-app"
|
||||
appVersion: "1.0.0"
|
||||
image: "nginx:latest"
|
||||
infraTemplate:
|
||||
|
|
@ -231,7 +224,6 @@ metadata:
|
|||
name: "test-app"
|
||||
spec:
|
||||
dockerApp:
|
||||
appName: "test-app"
|
||||
appVersion: "1.0.0"
|
||||
image: "nginx:latest"
|
||||
infraTemplate:
|
||||
|
|
@ -294,7 +286,6 @@ metadata:
|
|||
name: "test-app"
|
||||
spec:
|
||||
k8sApp:
|
||||
appName: "test-app"
|
||||
appVersion: "1.0.0"
|
||||
manifestFile: "./manifest.yaml"
|
||||
infraTemplate:
|
||||
|
|
@ -334,7 +325,6 @@ func TestEdgeConnectConfig_Validate(t *testing.T) {
|
|||
},
|
||||
Spec: Spec{
|
||||
DockerApp: &DockerApp{
|
||||
AppName: "test-app",
|
||||
AppVersion: "1.0.0",
|
||||
Image: "nginx:latest",
|
||||
},
|
||||
|
|
@ -736,7 +726,6 @@ func TestGetInstanceName(t *testing.T) {
|
|||
func TestSpec_GetMethods(t *testing.T) {
|
||||
k8sSpec := &Spec{
|
||||
K8sApp: &K8sApp{
|
||||
AppName: "k8s-app",
|
||||
AppVersion: "1.0.0",
|
||||
ManifestFile: "k8s.yaml",
|
||||
},
|
||||
|
|
@ -744,19 +733,16 @@ func TestSpec_GetMethods(t *testing.T) {
|
|||
|
||||
dockerSpec := &Spec{
|
||||
DockerApp: &DockerApp{
|
||||
AppName: "docker-app",
|
||||
AppVersion: "2.0.0",
|
||||
ManifestFile: "docker.yaml",
|
||||
},
|
||||
}
|
||||
|
||||
assert.Equal(t, "k8s-app", k8sSpec.GetAppName())
|
||||
assert.Equal(t, "1.0.0", k8sSpec.GetAppVersion())
|
||||
assert.Equal(t, "k8s.yaml", k8sSpec.GetManifestFile())
|
||||
assert.True(t, k8sSpec.IsK8sApp())
|
||||
assert.False(t, k8sSpec.IsDockerApp())
|
||||
|
||||
assert.Equal(t, "docker-app", dockerSpec.GetAppName())
|
||||
assert.Equal(t, "2.0.0", dockerSpec.GetAppVersion())
|
||||
assert.Equal(t, "docker.yaml", dockerSpec.GetManifestFile())
|
||||
assert.False(t, dockerSpec.IsK8sApp())
|
||||
|
|
@ -786,4 +772,4 @@ func TestPortRangesOverlap(t *testing.T) {
|
|||
assert.Equal(t, tt.expected, result)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,14 +31,12 @@ type Spec struct {
|
|||
|
||||
// K8sApp defines Kubernetes application configuration
|
||||
type K8sApp struct {
|
||||
AppName string `yaml:"appName"`
|
||||
AppVersion string `yaml:"appVersion"`
|
||||
ManifestFile string `yaml:"manifestFile"`
|
||||
}
|
||||
|
||||
// DockerApp defines Docker application configuration
|
||||
type DockerApp struct {
|
||||
AppName string `yaml:"appName"`
|
||||
AppVersion string `yaml:"appVersion"`
|
||||
ManifestFile string `yaml:"manifestFile"`
|
||||
Image string `yaml:"image"`
|
||||
|
|
@ -148,10 +146,6 @@ func (s *Spec) Validate() error {
|
|||
|
||||
// Validate validates k8s app configuration
|
||||
func (k *K8sApp) Validate() error {
|
||||
if k.AppName == "" {
|
||||
return fmt.Errorf("appName is required")
|
||||
}
|
||||
|
||||
if k.AppVersion == "" {
|
||||
return fmt.Errorf("appVersion is required")
|
||||
}
|
||||
|
|
@ -165,11 +159,6 @@ func (k *K8sApp) Validate() error {
|
|||
return fmt.Errorf("manifestFile does not exist: %s", k.ManifestFile)
|
||||
}
|
||||
|
||||
// Validate app name format
|
||||
if strings.TrimSpace(k.AppName) != k.AppName {
|
||||
return fmt.Errorf("appName cannot have leading/trailing whitespace")
|
||||
}
|
||||
|
||||
// Validate version format
|
||||
if strings.TrimSpace(k.AppVersion) != k.AppVersion {
|
||||
return fmt.Errorf("appVersion cannot have leading/trailing whitespace")
|
||||
|
|
@ -180,10 +169,6 @@ func (k *K8sApp) Validate() error {
|
|||
|
||||
// Validate validates docker app configuration
|
||||
func (d *DockerApp) Validate() error {
|
||||
if d.AppName == "" {
|
||||
return fmt.Errorf("appName is required")
|
||||
}
|
||||
|
||||
if d.AppVersion == "" {
|
||||
return fmt.Errorf("appVersion is required")
|
||||
}
|
||||
|
|
@ -192,11 +177,6 @@ func (d *DockerApp) Validate() error {
|
|||
return fmt.Errorf("image is required")
|
||||
}
|
||||
|
||||
// Validate app name format
|
||||
if strings.TrimSpace(d.AppName) != d.AppName {
|
||||
return fmt.Errorf("appName cannot have leading/trailing whitespace")
|
||||
}
|
||||
|
||||
// Validate version format
|
||||
if strings.TrimSpace(d.AppVersion) != d.AppVersion {
|
||||
return fmt.Errorf("appVersion cannot have leading/trailing whitespace")
|
||||
|
|
@ -321,17 +301,6 @@ func (d *DockerApp) GetManifestPath(configDir string) string {
|
|||
return filepath.Join(configDir, d.ManifestFile)
|
||||
}
|
||||
|
||||
// GetAppName returns the application name from the active app type
|
||||
func (s *Spec) GetAppName() string {
|
||||
if s.K8sApp != nil {
|
||||
return s.K8sApp.AppName
|
||||
}
|
||||
if s.DockerApp != nil {
|
||||
return s.DockerApp.AppName
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// GetAppVersion returns the application version from the active app type
|
||||
func (s *Spec) GetAppVersion() string {
|
||||
if s.K8sApp != nil {
|
||||
|
|
@ -362,4 +331,4 @@ func (s *Spec) IsK8sApp() bool {
|
|||
// IsDockerApp returns true if this is a Docker application
|
||||
func (s *Spec) IsDockerApp() bool {
|
||||
return s.DockerApp != nil
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue