diff --git a/internal/apply/manager.go b/internal/apply/manager.go index 9951ada..45477ab 100644 --- a/internal/apply/manager.go +++ b/internal/apply/manager.go @@ -265,7 +265,7 @@ func (rm *EdgeConnectResourceManager) rollbackInstance(ctx context.Context, acti for _, instanceAction := range plan.InstanceActions { if instanceAction.InstanceName == action.Target { instanceKey := edgeconnect.AppInstanceKey{ - Organization: instanceAction.Target.Organization, + Organization: plan.AppAction.Desired.Organization, Name: instanceAction.InstanceName, CloudletKey: edgeconnect.CloudletKey{ Organization: instanceAction.Target.CloudletOrg, diff --git a/internal/apply/planner.go b/internal/apply/planner.go index c0a9f70..1cbc58d 100644 --- a/internal/apply/planner.go +++ b/internal/apply/planner.go @@ -135,7 +135,7 @@ func (p *EdgeConnectPlanner) planAppAction(ctx context.Context, config *config.E desired := &AppState{ Name: config.Metadata.Name, Version: config.Metadata.AppVersion, - Organization: config.Spec.InfraTemplate[0].Organization, // Use first infra template for org + Organization: config.Metadata.Organization, // Use first infra template for org Region: config.Spec.InfraTemplate[0].Region, // Use first infra template for region Exists: false, // Will be set based on current state } @@ -225,7 +225,7 @@ func (p *EdgeConnectPlanner) planInstanceActions(ctx context.Context, config *co desired := &InstanceState{ Name: instanceName, AppVersion: config.Metadata.AppVersion, - Organization: infra.Organization, + Organization: config.Metadata.Organization, Region: infra.Region, CloudletOrg: infra.CloudletOrg, CloudletName: infra.CloudletName, diff --git a/internal/apply/strategy_recreate.go b/internal/apply/strategy_recreate.go index 3ac1502..b2302ca 100644 --- a/internal/apply/strategy_recreate.go +++ b/internal/apply/strategy_recreate.go @@ -408,7 +408,7 @@ func (r *RecreateStrategy) executeAppActionWithRetry(ctx context.Context, action // deleteInstance deletes an instance (reuse existing logic from manager.go) func (r *RecreateStrategy) deleteInstance(ctx context.Context, action InstanceAction) (bool, error) { instanceKey := edgeconnect.AppInstanceKey{ - Organization: action.Target.Organization, + Organization: action.Desired.Organization, Name: action.InstanceName, CloudletKey: edgeconnect.CloudletKey{ Organization: action.Target.CloudletOrg, @@ -430,7 +430,7 @@ func (r *RecreateStrategy) createInstance(ctx context.Context, action InstanceAc Region: action.Target.Region, AppInst: edgeconnect.AppInstance{ Key: edgeconnect.AppInstanceKey{ - Organization: action.Target.Organization, + Organization: action.Desired.Organization, Name: action.InstanceName, CloudletKey: edgeconnect.CloudletKey{ Organization: action.Target.CloudletOrg, @@ -438,7 +438,7 @@ func (r *RecreateStrategy) createInstance(ctx context.Context, action InstanceAc }, }, AppKey: edgeconnect.AppKey{ - Organization: action.Target.Organization, + Organization: action.Desired.Organization, Name: config.Metadata.Name, Version: config.Metadata.AppVersion, }, diff --git a/internal/config/types.go b/internal/config/types.go index 88b52b7..05d84b7 100644 --- a/internal/config/types.go +++ b/internal/config/types.go @@ -18,8 +18,9 @@ type EdgeConnectConfig struct { // Metadata contains configuration metadata type Metadata struct { - Name string `yaml:"name"` - AppVersion string `yaml:"appVersion"` + Name string `yaml:"name"` + AppVersion string `yaml:"appVersion"` + Organization string `yaml:"organization"` } // Spec defines the application and infrastructure specification @@ -44,7 +45,6 @@ type DockerApp struct { // InfraTemplate defines infrastructure deployment targets type InfraTemplate struct { - Organization string `yaml:"organization"` Region string `yaml:"region"` CloudletOrg string `yaml:"cloudletOrg"` CloudletName string `yaml:"cloudletName"` @@ -121,6 +121,11 @@ func (m *Metadata) Validate() error { return fmt.Errorf("metadata.appVersion cannot have leading/trailing whitespace") } + if m.Organization == "" { + return fmt.Errorf("organization is required") + } + + return nil } @@ -209,10 +214,6 @@ func (d *DockerApp) Validate() error { // Validate validates infrastructure template configuration func (i *InfraTemplate) Validate() error { - if i.Organization == "" { - return fmt.Errorf("organization is required") - } - if i.Region == "" { return fmt.Errorf("region is required") } @@ -231,7 +232,6 @@ func (i *InfraTemplate) Validate() error { // Validate no leading/trailing whitespace fields := map[string]string{ - "organization": i.Organization, "region": i.Region, "cloudletOrg": i.CloudletOrg, "cloudletName": i.CloudletName, diff --git a/sdk/examples/comprehensive/EdgeConnectConfig.yaml b/sdk/examples/comprehensive/EdgeConnectConfig.yaml index 1430b33..b45abc4 100644 --- a/sdk/examples/comprehensive/EdgeConnectConfig.yaml +++ b/sdk/examples/comprehensive/EdgeConnectConfig.yaml @@ -4,6 +4,7 @@ kind: edgeconnect-deployment metadata: name: "edge-app-demo" # name could be used for appName appVersion: "1.0.0" + organization: "edp2" spec: # dockerApp: # Docker is OBSOLETE # appVersion: "1.0.0" @@ -12,8 +13,7 @@ spec: k8sApp: manifestFile: "./k8s-deployment.yaml" infraTemplate: - - organization: "edp2" - region: "EU" + - region: "EU" cloudletOrg: "TelekomOP" cloudletName: "Munich" flavorName: "EU.small"