From 01d0b2619c77353673f6aae6d6120620de9f86ee Mon Sep 17 00:00:00 2001 From: Josh Everett Date: Tue, 30 Jul 2024 20:17:20 -0400 Subject: [PATCH] feat(STONEINTG-941): replace Environment API references The IntegrationTestScenario Environment fields are now referencing API structs that have been removed from the latest versions of the application-api. Signed-off-by: Josh Everett --- api/v1alpha1/integrationtestscenario_types.go | 51 ++++++++++++-- api/v1alpha1/zz_generated.deepcopy.go | 70 ++++++++++++++++++- api/v1beta1/integrationtestscenario_types.go | 51 ++++++++++++-- api/v1beta1/zz_generated.deepcopy.go | 70 ++++++++++++++++++- ...o.redhat.com_integrationtestscenarios.yaml | 4 +- 5 files changed, 232 insertions(+), 14 deletions(-) diff --git a/api/v1alpha1/integrationtestscenario_types.go b/api/v1alpha1/integrationtestscenario_types.go index 87637cae7..2b01f1ba9 100644 --- a/api/v1alpha1/integrationtestscenario_types.go +++ b/api/v1alpha1/integrationtestscenario_types.go @@ -17,10 +17,53 @@ limitations under the License. package v1alpha1 import ( - applicationapiv1alpha1 "github.com/redhat-appstudio/application-api/api/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +// EnvVarPair describes environment variables to use for the component +type EnvVarPair struct { + + // Name is the environment variable name + Name string `json:"name"` + + // Value is the environment variable value + Value string `json:"value"` +} + +// DeploymentTargetClaimConfig specifies the DeploymentTargetClaim details for a given Environment. +type DeploymentTargetClaimConfig struct { + ClaimName string `json:"claimName"` +} + +// EnvironmentTarget provides the configuration for a deployment target. +type EnvironmentTarget struct { + DeploymentTargetClaim DeploymentTargetClaimConfig `json:"deploymentTargetClaim"` +} + +// EnvironmentConfiguration contains Environment-specific configurations details, to be used when generating +// Component/Application GitOps repository resources. +type DeprecatedEnvironmentConfiguration struct { + // Env is an array of standard environment variables + Env []EnvVarPair `json:"env,omitempty"` + + // Target is used to reference a DeploymentTargetClaim for a target Environment. + // The Environment controller uses the referenced DeploymentTargetClaim to access its bounded + // DeploymentTarget with cluster credential secret. + Target EnvironmentTarget `json:"target,omitempty"` +} + +// DEPRECATED: EnvironmentType should no longer be used, and has no replacement. +// - It's original purpose was to indicate whether an environment is POC/Non-POC, but these data were ultimately not required. +type DeprecatedEnvironmentType string + +const ( + // DEPRECATED: EnvironmentType_POC should no longer be used, and has no replacement. + EnvironmentType_POC DeprecatedEnvironmentType = "POC" + + // DEPRECATED: EnvironmentType_NonPOC should no longer be used, and has no replacement. + EnvironmentType_NonPOC DeprecatedEnvironmentType = "Non-POC" +) + // IntegrationTestScenarioSpec defines the desired state of IntegrationScenario type IntegrationTestScenarioSpec struct { // Application that's associated with the IntegrationTestScenario @@ -55,9 +98,9 @@ type PipelineParameter struct { // TestEnvironment contains the name and values of a Test environment type TestEnvironment struct { - Name string `json:"name"` - Type applicationapiv1alpha1.EnvironmentType `json:"type"` - Configuration *applicationapiv1alpha1.EnvironmentConfiguration `json:"configuration,omitempty"` + Name string `json:"name"` + Type DeprecatedEnvironmentType `json:"type"` + Configuration *DeprecatedEnvironmentConfiguration `json:"configuration,omitempty"` } // TestContext contains the name and values of a Test context diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 48fe62c1a..ef392709e 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -22,11 +22,77 @@ limitations under the License. package v1alpha1 import ( - apiv1alpha1 "github.com/redhat-appstudio/application-api/api/v1alpha1" "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DeploymentTargetClaimConfig) DeepCopyInto(out *DeploymentTargetClaimConfig) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeploymentTargetClaimConfig. +func (in *DeploymentTargetClaimConfig) DeepCopy() *DeploymentTargetClaimConfig { + if in == nil { + return nil + } + out := new(DeploymentTargetClaimConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DeprecatedEnvironmentConfiguration) DeepCopyInto(out *DeprecatedEnvironmentConfiguration) { + *out = *in + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVarPair, len(*in)) + copy(*out, *in) + } + out.Target = in.Target +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeprecatedEnvironmentConfiguration. +func (in *DeprecatedEnvironmentConfiguration) DeepCopy() *DeprecatedEnvironmentConfiguration { + if in == nil { + return nil + } + out := new(DeprecatedEnvironmentConfiguration) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EnvVarPair) DeepCopyInto(out *EnvVarPair) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EnvVarPair. +func (in *EnvVarPair) DeepCopy() *EnvVarPair { + if in == nil { + return nil + } + out := new(EnvVarPair) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EnvironmentTarget) DeepCopyInto(out *EnvironmentTarget) { + *out = *in + out.DeploymentTargetClaim = in.DeploymentTargetClaim +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EnvironmentTarget. +func (in *EnvironmentTarget) DeepCopy() *EnvironmentTarget { + if in == nil { + return nil + } + out := new(EnvironmentTarget) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *IntegrationTestScenario) DeepCopyInto(out *IntegrationTestScenario) { *out = *in @@ -176,7 +242,7 @@ func (in *TestEnvironment) DeepCopyInto(out *TestEnvironment) { *out = *in if in.Configuration != nil { in, out := &in.Configuration, &out.Configuration - *out = new(apiv1alpha1.EnvironmentConfiguration) + *out = new(DeprecatedEnvironmentConfiguration) (*in).DeepCopyInto(*out) } } diff --git a/api/v1beta1/integrationtestscenario_types.go b/api/v1beta1/integrationtestscenario_types.go index fc07122e2..a03c8f4d1 100644 --- a/api/v1beta1/integrationtestscenario_types.go +++ b/api/v1beta1/integrationtestscenario_types.go @@ -17,10 +17,53 @@ limitations under the License. package v1beta1 import ( - applicationapiv1alpha1 "github.com/redhat-appstudio/application-api/api/v1alpha1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +// EnvVarPair describes environment variables to use for the component +type EnvVarPair struct { + + // Name is the environment variable name + Name string `json:"name"` + + // Value is the environment variable value + Value string `json:"value"` +} + +// DeploymentTargetClaimConfig specifies the DeploymentTargetClaim details for a given Environment. +type DeploymentTargetClaimConfig struct { + ClaimName string `json:"claimName"` +} + +// EnvironmentTarget provides the configuration for a deployment target. +type EnvironmentTarget struct { + DeploymentTargetClaim DeploymentTargetClaimConfig `json:"deploymentTargetClaim"` +} + +// EnvironmentConfiguration contains Environment-specific configurations details, to be used when generating +// Component/Application GitOps repository resources. +type DeprecatedEnvironmentConfiguration struct { + // Env is an array of standard environment variables + Env []EnvVarPair `json:"env,omitempty"` + + // Target is used to reference a DeploymentTargetClaim for a target Environment. + // The Environment controller uses the referenced DeploymentTargetClaim to access its bounded + // DeploymentTarget with cluster credential secret. + Target EnvironmentTarget `json:"target,omitempty"` +} + +// DEPRECATED: EnvironmentType should no longer be used, and has no replacement. +// - It's original purpose was to indicate whether an environment is POC/Non-POC, but these data were ultimately not required. +type DeprecatedEnvironmentType string + +const ( + // DEPRECATED: EnvironmentType_POC should no longer be used, and has no replacement. + EnvironmentType_POC DeprecatedEnvironmentType = "POC" + + // DEPRECATED: EnvironmentType_NonPOC should no longer be used, and has no replacement. + EnvironmentType_NonPOC DeprecatedEnvironmentType = "Non-POC" +) + // IntegrationTestScenarioSpec defines the desired state of IntegrationScenario type IntegrationTestScenarioSpec struct { // Application that's associated with the IntegrationTestScenario @@ -52,9 +95,9 @@ type PipelineParameter struct { // TestEnvironment contains the name and values of a Test environment type TestEnvironment struct { - Name string `json:"name"` - Type applicationapiv1alpha1.EnvironmentType `json:"type"` - Configuration *applicationapiv1alpha1.EnvironmentConfiguration `json:"configuration,omitempty"` + Name string `json:"name"` + Type DeprecatedEnvironmentType `json:"type"` + Configuration *DeprecatedEnvironmentConfiguration `json:"configuration,omitempty"` } // TestContext contains the name and values of a Test context diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 7aefa53e3..6698cd63e 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -22,11 +22,77 @@ limitations under the License. package v1beta1 import ( - "github.com/redhat-appstudio/application-api/api/v1alpha1" "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DeploymentTargetClaimConfig) DeepCopyInto(out *DeploymentTargetClaimConfig) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeploymentTargetClaimConfig. +func (in *DeploymentTargetClaimConfig) DeepCopy() *DeploymentTargetClaimConfig { + if in == nil { + return nil + } + out := new(DeploymentTargetClaimConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DeprecatedEnvironmentConfiguration) DeepCopyInto(out *DeprecatedEnvironmentConfiguration) { + *out = *in + if in.Env != nil { + in, out := &in.Env, &out.Env + *out = make([]EnvVarPair, len(*in)) + copy(*out, *in) + } + out.Target = in.Target +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DeprecatedEnvironmentConfiguration. +func (in *DeprecatedEnvironmentConfiguration) DeepCopy() *DeprecatedEnvironmentConfiguration { + if in == nil { + return nil + } + out := new(DeprecatedEnvironmentConfiguration) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EnvVarPair) DeepCopyInto(out *EnvVarPair) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EnvVarPair. +func (in *EnvVarPair) DeepCopy() *EnvVarPair { + if in == nil { + return nil + } + out := new(EnvVarPair) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *EnvironmentTarget) DeepCopyInto(out *EnvironmentTarget) { + *out = *in + out.DeploymentTargetClaim = in.DeploymentTargetClaim +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EnvironmentTarget. +func (in *EnvironmentTarget) DeepCopy() *EnvironmentTarget { + if in == nil { + return nil + } + out := new(EnvironmentTarget) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *IntegrationTestScenario) DeepCopyInto(out *IntegrationTestScenario) { *out = *in @@ -212,7 +278,7 @@ func (in *TestEnvironment) DeepCopyInto(out *TestEnvironment) { *out = *in if in.Configuration != nil { in, out := &in.Configuration, &out.Configuration - *out = new(v1alpha1.EnvironmentConfiguration) + *out = new(DeprecatedEnvironmentConfiguration) (*in).DeepCopyInto(*out) } } diff --git a/config/crd/bases/appstudio.redhat.com_integrationtestscenarios.yaml b/config/crd/bases/appstudio.redhat.com_integrationtestscenarios.yaml index b779662fc..a0fc9ce9f 100644 --- a/config/crd/bases/appstudio.redhat.com_integrationtestscenarios.yaml +++ b/config/crd/bases/appstudio.redhat.com_integrationtestscenarios.yaml @@ -76,7 +76,7 @@ spec: GitOps repository resources. properties: env: - description: Env is an array of standard environment vairables + description: Env is an array of standard environment variables items: description: EnvVarPair describes environment variables to use for the component @@ -285,7 +285,7 @@ spec: GitOps repository resources. properties: env: - description: Env is an array of standard environment vairables + description: Env is an array of standard environment variables items: description: EnvVarPair describes environment variables to use for the component