From d72d4d29d42631502639353212b6d251f1494d7f Mon Sep 17 00:00:00 2001 From: shreddedbacon Date: Tue, 4 Oct 2022 10:25:14 +1100 Subject: [PATCH] chore: add clearer label for idling and storage calculator --- apis/lagoon/v1beta1/lagoonbuild_types.go | 42 ++++++++++---------- apis/lagoon/v1beta1/zz_generated.deepcopy.go | 4 +- controllers/v1beta1/build_helpers.go | 20 ++++++++-- 3 files changed, 39 insertions(+), 27 deletions(-) diff --git a/apis/lagoon/v1beta1/lagoonbuild_types.go b/apis/lagoon/v1beta1/lagoonbuild_types.go index 9c0164c3..faaaa290 100644 --- a/apis/lagoon/v1beta1/lagoonbuild_types.go +++ b/apis/lagoon/v1beta1/lagoonbuild_types.go @@ -107,27 +107,27 @@ type Build struct { // Project contains the project information from lagoon. type Project struct { - ID *uint `json:"id,omitempty"` - Name string `json:"name"` - Environment string `json:"environment"` - EnvironmentID *uint `json:"environmentId,omitempty"` - UILink string `json:"uiLink,omitempty"` - GitURL string `json:"gitUrl"` - NamespacePattern string `json:"namespacePattern,omitempty"` - RouterPattern string `json:"routerPattern,omitempty"` - EnvironmentType string `json:"environmentType"` - ProductionEnvironment string `json:"productionEnvironment"` - StandbyEnvironment string `json:"standbyEnvironment"` - DeployTarget string `json:"deployTarget"` - ProjectSecret string `json:"projectSecret"` - SubFolder string `json:"subfolder,omitempty"` - Key []byte `json:"key"` - Monitoring Monitoring `json:"monitoring"` - Variables Variables `json:"variables"` - Registry string `json:"registry,omitempty"` - EnvironmentIdling *int `json:"environmentIdling,omitempty"` - ProjectIdling *int `json:"projectIdling,omitempty"` - StorageCalculatorDisabled *int `json:"storageCalc,omitempty"` + ID *uint `json:"id,omitempty"` + Name string `json:"name"` + Environment string `json:"environment"` + EnvironmentID *uint `json:"environmentId,omitempty"` + UILink string `json:"uiLink,omitempty"` + GitURL string `json:"gitUrl"` + NamespacePattern string `json:"namespacePattern,omitempty"` + RouterPattern string `json:"routerPattern,omitempty"` + EnvironmentType string `json:"environmentType"` + ProductionEnvironment string `json:"productionEnvironment"` + StandbyEnvironment string `json:"standbyEnvironment"` + DeployTarget string `json:"deployTarget"` + ProjectSecret string `json:"projectSecret"` + SubFolder string `json:"subfolder,omitempty"` + Key []byte `json:"key"` + Monitoring Monitoring `json:"monitoring"` + Variables Variables `json:"variables"` + Registry string `json:"registry,omitempty"` + EnvironmentIdling *int `json:"environmentIdling,omitempty"` + ProjectIdling *int `json:"projectIdling,omitempty"` + StorageCalculator *int `json:"storageCalc,omitempty"` } // Variables contains the project and environment variables from lagoon. diff --git a/apis/lagoon/v1beta1/zz_generated.deepcopy.go b/apis/lagoon/v1beta1/zz_generated.deepcopy.go index 92db6e66..1652e7d5 100644 --- a/apis/lagoon/v1beta1/zz_generated.deepcopy.go +++ b/apis/lagoon/v1beta1/zz_generated.deepcopy.go @@ -580,8 +580,8 @@ func (in *Project) DeepCopyInto(out *Project) { *out = new(int) **out = **in } - if in.StorageCalculatorDisabled != nil { - in, out := &in.StorageCalculatorDisabled, &out.StorageCalculatorDisabled + if in.StorageCalculator != nil { + in, out := &in.StorageCalculator, &out.StorageCalculator *out = new(int) **out = **in } diff --git a/controllers/v1beta1/build_helpers.go b/controllers/v1beta1/build_helpers.go index 99432a59..aa73eab8 100644 --- a/controllers/v1beta1/build_helpers.go +++ b/controllers/v1beta1/build_helpers.go @@ -114,16 +114,28 @@ func (r *LagoonBuildReconciler) getOrCreateNamespace(ctx context.Context, namesp } // set the auto idling values if they are defined if lagoonBuild.Spec.Project.EnvironmentIdling != nil { + // eventually deprecate 'lagoon.sh/environmentAutoIdle' for 'lagoon.sh/environmentIdlingEnabled' nsLabels["lagoon.sh/environmentAutoIdle"] = fmt.Sprintf("%d", *lagoonBuild.Spec.Project.EnvironmentIdling) + if *lagoonBuild.Spec.Project.ProjectIdling == 1 { + nsLabels["lagoon.sh/environmentIdlingEnabled"] = "true" + } else { + nsLabels["lagoon.sh/environmentIdlingEnabled"] = "false" + } } if lagoonBuild.Spec.Project.ProjectIdling != nil { + // eventually deprecate 'lagoon.sh/projectAutoIdle' for 'lagoon.sh/projectIdlingEnabled' nsLabels["lagoon.sh/projectAutoIdle"] = fmt.Sprintf("%d", *lagoonBuild.Spec.Project.ProjectIdling) + if *lagoonBuild.Spec.Project.ProjectIdling == 1 { + nsLabels["lagoon.sh/projectIdlingEnabled"] = "true" + } else { + nsLabels["lagoon.sh/projectIdlingEnabled"] = "false" + } } - if lagoonBuild.Spec.Project.StorageCalculatorDisabled != nil { - if *lagoonBuild.Spec.Project.StorageCalculatorDisabled != 1 { - nsLabels["lagoon.sh/storageCalculatorDisabled"] = "true" + if lagoonBuild.Spec.Project.StorageCalculator != nil { + if *lagoonBuild.Spec.Project.StorageCalculator == 1 { + nsLabels["lagoon.sh/storageCalculatorEnabled"] = "true" } else { - nsLabels["lagoon.sh/storageCalculatorDisabled"] = "false" + nsLabels["lagoon.sh/storageCalculatorEnabled"] = "false" } } // add the required lagoon labels to the namespace when creating