Skip to content

Commit

Permalink
Merge pull request #179 from uselagoon/label-names
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon authored Oct 3, 2022
2 parents e2227f2 + d72d4d2 commit 7f277fb
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 27 deletions.
42 changes: 21 additions & 21 deletions apis/lagoon/v1beta1/lagoonbuild_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions apis/lagoon/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 16 additions & 4 deletions controllers/v1beta1/build_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7f277fb

Please sign in to comment.