From 8985b890254c0dfbf1925836f6e8480fc1e9b79b Mon Sep 17 00:00:00 2001 From: spoukke Date: Thu, 9 Feb 2023 12:42:00 +0100 Subject: [PATCH] feat: use common remediation strategy --- api/v1alpha1/common.go | 7 +++++ api/v1alpha1/terraformlayer_types.go | 21 +++++---------- api/v1alpha1/terraformrepository_types.go | 13 +++------- api/v1alpha1/zz_generated.deepcopy.go | 31 ++++++++++++----------- 4 files changed, 33 insertions(+), 39 deletions(-) diff --git a/api/v1alpha1/common.go b/api/v1alpha1/common.go index 55c0e636..e9efe1b6 100644 --- a/api/v1alpha1/common.go +++ b/api/v1alpha1/common.go @@ -10,3 +10,10 @@ type OverrideRunnerSpec struct { NodeSelector map[string]string `json:"nodeSelector,omitempty"` ServiceAccountName string `json:"serviceAccountName,omitempty"` } + +type RemediationStrategy struct { + PlanOnDrift bool `json:"planOnDrift,omitempty"` + ApplyOnDrift bool `json:"applyOnDrift,omitempty"` + PlanOnPush bool `json:"planOnPush,omitempty"` + ApplyOnPush bool `json:"applyOnPush,omitempty"` +} diff --git a/api/v1alpha1/terraformlayer_types.go b/api/v1alpha1/terraformlayer_types.go index 0b09f8cb..2a5c637b 100644 --- a/api/v1alpha1/terraformlayer_types.go +++ b/api/v1alpha1/terraformlayer_types.go @@ -28,20 +28,13 @@ type TerraformLayerSpec struct { // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster // Important: Run "make" to regenerate code after modifying this file - Path string `json:"path,omitempty"` - Branch string `json:"branch,omitempty"` - TerraformVersion string `json:"terraformVersion,omitempty"` - Repository TerraformLayerRepository `json:"repository,omitempty"` - RemediationStrategy TerraformLayerRemediationStrategy `json:"remediationStrategy,omitempty"` - PlanOnPullRequest bool `json:"planOnPullRequest,omitempty"` - OverrideRunnerSpec OverrideRunnerSpec `json:"overrideRunnerSpec,omitempty"` -} - -type TerraformLayerRemediationStrategy struct { - PlanOnDrift bool `json:"planOnDrift,omitempty"` - ApplyOnDrift bool `json:"applyOnDrift,omitempty"` - PlanOnPush bool `json:"planOnPush,omitempty"` - ApplyOnPush bool `json:"applyOnPush,omitempty"` + Path string `json:"path,omitempty"` + Branch string `json:"branch,omitempty"` + TerraformVersion string `json:"terraformVersion,omitempty"` + Repository TerraformLayerRepository `json:"repository,omitempty"` + RemediationStrategy RemediationStrategy `json:"remediationStrategy,omitempty"` + PlanOnPullRequest bool `json:"planOnPullRequest,omitempty"` + OverrideRunnerSpec OverrideRunnerSpec `json:"overrideRunnerSpec,omitempty"` } type TerraformLayerRepository struct { diff --git a/api/v1alpha1/terraformrepository_types.go b/api/v1alpha1/terraformrepository_types.go index ed65ce59..0ed3c469 100644 --- a/api/v1alpha1/terraformrepository_types.go +++ b/api/v1alpha1/terraformrepository_types.go @@ -28,9 +28,9 @@ type TerraformRepositorySpec struct { // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster // Important: Run "make" to regenerate code after modifying this file - Repository TerraformRepositoryRepository `json:"repository,omitempty"` - RemediationStrategy TerraformRepositoryRemediationStrategy `json:"remediationStrategy,omitempty"` - OverrideRunnerSpec OverrideRunnerSpec `json:"overrideRunnerSpec,omitempty"` + Repository TerraformRepositoryRepository `json:"repository,omitempty"` + RemediationStrategy RemediationStrategy `json:"remediationStrategy,omitempty"` + OverrideRunnerSpec OverrideRunnerSpec `json:"overrideRunnerSpec,omitempty"` } type TerraformRepositoryRepository struct { @@ -43,13 +43,6 @@ type TerraformRepositoryStatus struct { Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"` } -type TerraformRepositoryRemediationStrategy struct { - PlanOnDrift bool `json:"planOnDrift,omitempty"` - ApplyOnDrift bool `json:"applyOnDrift,omitempty"` - PlanOnPush bool `json:"planOnPush,omitempty"` - ApplyOnPush bool `json:"applyOnPush,omitempty"` -} - //+kubebuilder:object:root=true //+kubebuilder:subresource:status diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index 14b024b4..2690a20a 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -61,6 +61,21 @@ func (in *OverrideRunnerSpec) DeepCopy() *OverrideRunnerSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RemediationStrategy) DeepCopyInto(out *RemediationStrategy) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemediationStrategy. +func (in *RemediationStrategy) DeepCopy() *RemediationStrategy { + if in == nil { + return nil + } + out := new(RemediationStrategy) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TerraformLayer) DeepCopyInto(out *TerraformLayer) { *out = *in @@ -120,21 +135,6 @@ func (in *TerraformLayerList) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TerraformLayerRemediationStrategy) DeepCopyInto(out *TerraformLayerRemediationStrategy) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TerraformLayerRemediationStrategy. -func (in *TerraformLayerRemediationStrategy) DeepCopy() *TerraformLayerRemediationStrategy { - if in == nil { - return nil - } - out := new(TerraformLayerRemediationStrategy) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *TerraformLayerRepository) DeepCopyInto(out *TerraformLayerRepository) { *out = *in @@ -268,6 +268,7 @@ func (in *TerraformRepositoryRepository) DeepCopy() *TerraformRepositoryReposito func (in *TerraformRepositorySpec) DeepCopyInto(out *TerraformRepositorySpec) { *out = *in out.Repository = in.Repository + out.RemediationStrategy = in.RemediationStrategy in.OverrideRunnerSpec.DeepCopyInto(&out.OverrideRunnerSpec) }