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
1
apply.md
1
apply.md
|
|
@ -35,7 +35,6 @@ metadata:
|
||||||
name: "edge-app-demo"
|
name: "edge-app-demo"
|
||||||
spec:
|
spec:
|
||||||
k8sApp: # App definition
|
k8sApp: # App definition
|
||||||
appName: "edge-app-demo"
|
|
||||||
appVersion: "1.0.0"
|
appVersion: "1.0.0"
|
||||||
manifestFile: "./k8s-deployment.yaml"
|
manifestFile: "./k8s-deployment.yaml"
|
||||||
infraTemplate: # Instance deployment targets
|
infraTemplate: # Instance deployment targets
|
||||||
|
|
|
||||||
|
|
@ -335,7 +335,7 @@ func (rm *EdgeConnectResourceManager) createInstance(ctx context.Context, action
|
||||||
},
|
},
|
||||||
AppKey: edgeconnect.AppKey{
|
AppKey: edgeconnect.AppKey{
|
||||||
Organization: action.Target.Organization,
|
Organization: action.Target.Organization,
|
||||||
Name: config.Spec.GetAppName(),
|
Name: config.Metadata.Name,
|
||||||
Version: config.Spec.GetAppVersion(),
|
Version: config.Spec.GetAppVersion(),
|
||||||
},
|
},
|
||||||
Flavor: edgeconnect.Flavor{
|
Flavor: edgeconnect.Flavor{
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,6 @@ func createTestManagerConfig(t *testing.T) *config.EdgeConnectConfig {
|
||||||
},
|
},
|
||||||
Spec: config.Spec{
|
Spec: config.Spec{
|
||||||
K8sApp: &config.K8sApp{
|
K8sApp: &config.K8sApp{
|
||||||
AppName: "test-app",
|
|
||||||
AppVersion: "1.0.0",
|
AppVersion: "1.0.0",
|
||||||
ManifestFile: manifestFile,
|
ManifestFile: manifestFile,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ func (p *EdgeConnectPlanner) planAppAction(ctx context.Context, config *config.E
|
||||||
|
|
||||||
// Build desired app state
|
// Build desired app state
|
||||||
desired := &AppState{
|
desired := &AppState{
|
||||||
Name: config.Spec.GetAppName(),
|
Name: config.Metadata.Name,
|
||||||
Version: config.Spec.GetAppVersion(),
|
Version: config.Spec.GetAppVersion(),
|
||||||
Organization: config.Spec.InfraTemplate[0].Organization, // Use first infra template for org
|
Organization: config.Spec.InfraTemplate[0].Organization, // Use first infra template for org
|
||||||
Region: config.Spec.InfraTemplate[0].Region, // Use first infra template for region
|
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
|
var warnings []string
|
||||||
|
|
||||||
for _, infra := range config.Spec.InfraTemplate {
|
for _, infra := range config.Spec.InfraTemplate {
|
||||||
instanceName := getInstanceName(config.Spec.GetAppName(), config.Spec.GetAppVersion())
|
instanceName := getInstanceName(config.Metadata.Name, config.Spec.GetAppVersion())
|
||||||
|
|
||||||
desired := &InstanceState{
|
desired := &InstanceState{
|
||||||
Name: instanceName,
|
Name: instanceName,
|
||||||
AppName: config.Spec.GetAppName(),
|
|
||||||
AppVersion: config.Spec.GetAppVersion(),
|
AppVersion: config.Spec.GetAppVersion(),
|
||||||
Organization: infra.Organization,
|
Organization: infra.Organization,
|
||||||
Region: infra.Region,
|
Region: infra.Region,
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,6 @@ func createTestConfig(t *testing.T) *config.EdgeConnectConfig {
|
||||||
},
|
},
|
||||||
Spec: config.Spec{
|
Spec: config.Spec{
|
||||||
K8sApp: &config.K8sApp{
|
K8sApp: &config.K8sApp{
|
||||||
AppName: "test-app",
|
|
||||||
AppVersion: "1.0.0",
|
AppVersion: "1.0.0",
|
||||||
ManifestFile: manifestFile,
|
ManifestFile: manifestFile,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ func TestParseExampleConfig(t *testing.T) {
|
||||||
parser := NewParser()
|
parser := NewParser()
|
||||||
|
|
||||||
// Parse the actual example file (now that we've created the manifest file)
|
// 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)
|
config, err := parser.ParseFile(examplePath)
|
||||||
|
|
||||||
// This should now succeed with full validation
|
// This should now succeed with full validation
|
||||||
|
|
@ -27,7 +27,6 @@ func TestParseExampleConfig(t *testing.T) {
|
||||||
|
|
||||||
// Check k8s app configuration
|
// Check k8s app configuration
|
||||||
require.NotNil(t, config.Spec.K8sApp)
|
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)
|
assert.Equal(t, "1.0.0", config.Spec.K8sApp.AppVersion)
|
||||||
// Note: ManifestFile path should be resolved to absolute path
|
// Note: ManifestFile path should be resolved to absolute path
|
||||||
assert.Contains(t, config.Spec.K8sApp.ManifestFile, "k8s-deployment.yaml")
|
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)
|
assert.Equal(t, "0.0.0.0/0", conn2.RemoteCIDR)
|
||||||
|
|
||||||
// Test utility methods
|
// 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.Equal(t, "1.0.0", config.Spec.GetAppVersion())
|
||||||
assert.Contains(t, config.Spec.GetManifestFile(), "k8s-deployment.yaml")
|
assert.Contains(t, config.Spec.GetManifestFile(), "k8s-deployment.yaml")
|
||||||
assert.True(t, config.Spec.IsK8sApp())
|
assert.True(t, config.Spec.IsK8sApp())
|
||||||
assert.False(t, config.Spec.IsDockerApp())
|
assert.False(t, config.Spec.IsDockerApp())
|
||||||
|
|
||||||
// Test instance name generation
|
// 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)
|
assert.Equal(t, "edge-app-demo-1.0.0-instance", instanceName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -80,7 +79,6 @@ func TestValidateExampleStructure(t *testing.T) {
|
||||||
},
|
},
|
||||||
Spec: Spec{
|
Spec: Spec{
|
||||||
DockerApp: &DockerApp{ // Use DockerApp to avoid manifest file validation
|
DockerApp: &DockerApp{ // Use DockerApp to avoid manifest file validation
|
||||||
AppName: "edge-app-demo",
|
|
||||||
AppVersion: "1.0.0",
|
AppVersion: "1.0.0",
|
||||||
Image: "nginx:latest",
|
Image: "nginx:latest",
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,6 @@ metadata:
|
||||||
name: "test-app"
|
name: "test-app"
|
||||||
spec:
|
spec:
|
||||||
k8sApp:
|
k8sApp:
|
||||||
appName: "test-app"
|
|
||||||
appVersion: "1.0.0"
|
appVersion: "1.0.0"
|
||||||
manifestFile: "./test-manifest.yaml"
|
manifestFile: "./test-manifest.yaml"
|
||||||
infraTemplate:
|
infraTemplate:
|
||||||
|
|
@ -55,7 +54,6 @@ metadata:
|
||||||
name: "test-app"
|
name: "test-app"
|
||||||
spec:
|
spec:
|
||||||
dockerApp:
|
dockerApp:
|
||||||
appName: "test-app"
|
|
||||||
appVersion: "1.0.0"
|
appVersion: "1.0.0"
|
||||||
image: "nginx:latest"
|
image: "nginx:latest"
|
||||||
infraTemplate:
|
infraTemplate:
|
||||||
|
|
@ -74,7 +72,6 @@ metadata:
|
||||||
name: "test-app"
|
name: "test-app"
|
||||||
spec:
|
spec:
|
||||||
k8sApp:
|
k8sApp:
|
||||||
appName: "test-app"
|
|
||||||
appVersion: "1.0.0"
|
appVersion: "1.0.0"
|
||||||
manifestFile: "./test-manifest.yaml"
|
manifestFile: "./test-manifest.yaml"
|
||||||
infraTemplate:
|
infraTemplate:
|
||||||
|
|
@ -95,7 +92,6 @@ metadata:
|
||||||
name: "test-app"
|
name: "test-app"
|
||||||
spec:
|
spec:
|
||||||
dockerApp:
|
dockerApp:
|
||||||
appName: "test-app"
|
|
||||||
appVersion: "1.0.0"
|
appVersion: "1.0.0"
|
||||||
image: "nginx:latest"
|
image: "nginx:latest"
|
||||||
infraTemplate:
|
infraTemplate:
|
||||||
|
|
@ -133,7 +129,6 @@ metadata:
|
||||||
name: "test-app"
|
name: "test-app"
|
||||||
spec:
|
spec:
|
||||||
k8sApp:
|
k8sApp:
|
||||||
appName: "test-app"
|
|
||||||
appVersion: "1.0.0"
|
appVersion: "1.0.0"
|
||||||
manifestFile: "./test-manifest.yaml"
|
manifestFile: "./test-manifest.yaml"
|
||||||
dockerApp:
|
dockerApp:
|
||||||
|
|
@ -158,7 +153,6 @@ metadata:
|
||||||
name: "test-app"
|
name: "test-app"
|
||||||
spec:
|
spec:
|
||||||
dockerApp:
|
dockerApp:
|
||||||
appName: "test-app"
|
|
||||||
appVersion: "1.0.0"
|
appVersion: "1.0.0"
|
||||||
image: "nginx:latest"
|
image: "nginx:latest"
|
||||||
infraTemplate: []
|
infraTemplate: []
|
||||||
|
|
@ -174,7 +168,6 @@ metadata:
|
||||||
name: "test-app"
|
name: "test-app"
|
||||||
spec:
|
spec:
|
||||||
dockerApp:
|
dockerApp:
|
||||||
appName: "test-app"
|
|
||||||
appVersion: "1.0.0"
|
appVersion: "1.0.0"
|
||||||
image: "nginx:latest"
|
image: "nginx:latest"
|
||||||
infraTemplate:
|
infraTemplate:
|
||||||
|
|
@ -231,7 +224,6 @@ metadata:
|
||||||
name: "test-app"
|
name: "test-app"
|
||||||
spec:
|
spec:
|
||||||
dockerApp:
|
dockerApp:
|
||||||
appName: "test-app"
|
|
||||||
appVersion: "1.0.0"
|
appVersion: "1.0.0"
|
||||||
image: "nginx:latest"
|
image: "nginx:latest"
|
||||||
infraTemplate:
|
infraTemplate:
|
||||||
|
|
@ -294,7 +286,6 @@ metadata:
|
||||||
name: "test-app"
|
name: "test-app"
|
||||||
spec:
|
spec:
|
||||||
k8sApp:
|
k8sApp:
|
||||||
appName: "test-app"
|
|
||||||
appVersion: "1.0.0"
|
appVersion: "1.0.0"
|
||||||
manifestFile: "./manifest.yaml"
|
manifestFile: "./manifest.yaml"
|
||||||
infraTemplate:
|
infraTemplate:
|
||||||
|
|
@ -334,7 +325,6 @@ func TestEdgeConnectConfig_Validate(t *testing.T) {
|
||||||
},
|
},
|
||||||
Spec: Spec{
|
Spec: Spec{
|
||||||
DockerApp: &DockerApp{
|
DockerApp: &DockerApp{
|
||||||
AppName: "test-app",
|
|
||||||
AppVersion: "1.0.0",
|
AppVersion: "1.0.0",
|
||||||
Image: "nginx:latest",
|
Image: "nginx:latest",
|
||||||
},
|
},
|
||||||
|
|
@ -736,7 +726,6 @@ func TestGetInstanceName(t *testing.T) {
|
||||||
func TestSpec_GetMethods(t *testing.T) {
|
func TestSpec_GetMethods(t *testing.T) {
|
||||||
k8sSpec := &Spec{
|
k8sSpec := &Spec{
|
||||||
K8sApp: &K8sApp{
|
K8sApp: &K8sApp{
|
||||||
AppName: "k8s-app",
|
|
||||||
AppVersion: "1.0.0",
|
AppVersion: "1.0.0",
|
||||||
ManifestFile: "k8s.yaml",
|
ManifestFile: "k8s.yaml",
|
||||||
},
|
},
|
||||||
|
|
@ -744,19 +733,16 @@ func TestSpec_GetMethods(t *testing.T) {
|
||||||
|
|
||||||
dockerSpec := &Spec{
|
dockerSpec := &Spec{
|
||||||
DockerApp: &DockerApp{
|
DockerApp: &DockerApp{
|
||||||
AppName: "docker-app",
|
|
||||||
AppVersion: "2.0.0",
|
AppVersion: "2.0.0",
|
||||||
ManifestFile: "docker.yaml",
|
ManifestFile: "docker.yaml",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
assert.Equal(t, "k8s-app", k8sSpec.GetAppName())
|
|
||||||
assert.Equal(t, "1.0.0", k8sSpec.GetAppVersion())
|
assert.Equal(t, "1.0.0", k8sSpec.GetAppVersion())
|
||||||
assert.Equal(t, "k8s.yaml", k8sSpec.GetManifestFile())
|
assert.Equal(t, "k8s.yaml", k8sSpec.GetManifestFile())
|
||||||
assert.True(t, k8sSpec.IsK8sApp())
|
assert.True(t, k8sSpec.IsK8sApp())
|
||||||
assert.False(t, k8sSpec.IsDockerApp())
|
assert.False(t, k8sSpec.IsDockerApp())
|
||||||
|
|
||||||
assert.Equal(t, "docker-app", dockerSpec.GetAppName())
|
|
||||||
assert.Equal(t, "2.0.0", dockerSpec.GetAppVersion())
|
assert.Equal(t, "2.0.0", dockerSpec.GetAppVersion())
|
||||||
assert.Equal(t, "docker.yaml", dockerSpec.GetManifestFile())
|
assert.Equal(t, "docker.yaml", dockerSpec.GetManifestFile())
|
||||||
assert.False(t, dockerSpec.IsK8sApp())
|
assert.False(t, dockerSpec.IsK8sApp())
|
||||||
|
|
|
||||||
|
|
@ -31,14 +31,12 @@ type Spec struct {
|
||||||
|
|
||||||
// K8sApp defines Kubernetes application configuration
|
// K8sApp defines Kubernetes application configuration
|
||||||
type K8sApp struct {
|
type K8sApp struct {
|
||||||
AppName string `yaml:"appName"`
|
|
||||||
AppVersion string `yaml:"appVersion"`
|
AppVersion string `yaml:"appVersion"`
|
||||||
ManifestFile string `yaml:"manifestFile"`
|
ManifestFile string `yaml:"manifestFile"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DockerApp defines Docker application configuration
|
// DockerApp defines Docker application configuration
|
||||||
type DockerApp struct {
|
type DockerApp struct {
|
||||||
AppName string `yaml:"appName"`
|
|
||||||
AppVersion string `yaml:"appVersion"`
|
AppVersion string `yaml:"appVersion"`
|
||||||
ManifestFile string `yaml:"manifestFile"`
|
ManifestFile string `yaml:"manifestFile"`
|
||||||
Image string `yaml:"image"`
|
Image string `yaml:"image"`
|
||||||
|
|
@ -148,10 +146,6 @@ func (s *Spec) Validate() error {
|
||||||
|
|
||||||
// Validate validates k8s app configuration
|
// Validate validates k8s app configuration
|
||||||
func (k *K8sApp) Validate() error {
|
func (k *K8sApp) Validate() error {
|
||||||
if k.AppName == "" {
|
|
||||||
return fmt.Errorf("appName is required")
|
|
||||||
}
|
|
||||||
|
|
||||||
if k.AppVersion == "" {
|
if k.AppVersion == "" {
|
||||||
return fmt.Errorf("appVersion is required")
|
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)
|
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
|
// Validate version format
|
||||||
if strings.TrimSpace(k.AppVersion) != k.AppVersion {
|
if strings.TrimSpace(k.AppVersion) != k.AppVersion {
|
||||||
return fmt.Errorf("appVersion cannot have leading/trailing whitespace")
|
return fmt.Errorf("appVersion cannot have leading/trailing whitespace")
|
||||||
|
|
@ -180,10 +169,6 @@ func (k *K8sApp) Validate() error {
|
||||||
|
|
||||||
// Validate validates docker app configuration
|
// Validate validates docker app configuration
|
||||||
func (d *DockerApp) Validate() error {
|
func (d *DockerApp) Validate() error {
|
||||||
if d.AppName == "" {
|
|
||||||
return fmt.Errorf("appName is required")
|
|
||||||
}
|
|
||||||
|
|
||||||
if d.AppVersion == "" {
|
if d.AppVersion == "" {
|
||||||
return fmt.Errorf("appVersion is required")
|
return fmt.Errorf("appVersion is required")
|
||||||
}
|
}
|
||||||
|
|
@ -192,11 +177,6 @@ func (d *DockerApp) Validate() error {
|
||||||
return fmt.Errorf("image is required")
|
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
|
// Validate version format
|
||||||
if strings.TrimSpace(d.AppVersion) != d.AppVersion {
|
if strings.TrimSpace(d.AppVersion) != d.AppVersion {
|
||||||
return fmt.Errorf("appVersion cannot have leading/trailing whitespace")
|
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)
|
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
|
// GetAppVersion returns the application version from the active app type
|
||||||
func (s *Spec) GetAppVersion() string {
|
func (s *Spec) GetAppVersion() string {
|
||||||
if s.K8sApp != nil {
|
if s.K8sApp != nil {
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,15 @@
|
||||||
# Is there a swagger file for the new EdgeConnect API?
|
# Is there a swagger file for the new EdgeConnect API?
|
||||||
#
|
# How does it differ from the EdgeXR API?
|
||||||
|
|
||||||
kind: edgeconnect-deployment
|
kind: edgeconnect-deployment
|
||||||
metadata:
|
metadata:
|
||||||
name: "edge-app-demo"
|
name: "edge-app-demo" # name could be used for appName
|
||||||
spec:
|
spec:
|
||||||
# dockerApp:
|
# dockerApp: # Docker is OBSOLETE
|
||||||
# appName: "edge-app-demo"
|
|
||||||
# appVersion: "1.0.0"
|
# appVersion: "1.0.0"
|
||||||
# manifestFile: "./docker-compose.yaml"
|
# manifestFile: "./docker-compose.yaml"
|
||||||
# image: "https://registry-1.docker.io/library/nginx:latest"
|
# image: "https://registry-1.docker.io/library/nginx:latest"
|
||||||
k8sApp:
|
k8sApp:
|
||||||
appName: "edge-app-demo" # appinstance name is $appName-$appVersion-instance
|
appVersion: "1.0.0"
|
||||||
appVersion: "1.0.1"
|
|
||||||
manifestFile: "./k8s-deployment.yaml" # store hash of the manifest file in annotation field. Annotations is a comma separated map of arbitrary key value pairs,
|
manifestFile: "./k8s-deployment.yaml" # store hash of the manifest file in annotation field. Annotations is a comma separated map of arbitrary key value pairs,
|
||||||
infraTemplate:
|
infraTemplate:
|
||||||
- organization: "edp2"
|
- organization: "edp2"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue