Skip to content

Commit

Permalink
fix: Corrects the logic of determining the version #83
Browse files Browse the repository at this point in the history
* main.go
  * Adds missing ImageVersion to the BuildVariables that then get
    re-assigned to the operator's utils BuildVariables

* deployment.go
  * Corrects the logic of determining the ImageVersion from
      1. IMAGE_VERSION env var
      2. BuildVariables.ImageVersion
      3. Default to 'latest'
  • Loading branch information
phantomjinx committed Nov 28, 2023
1 parent ab9c0f9 commit e4e15a9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
// Go build-time variables
var (
ImageRepository string
ImageVersion string
LegacyServingCertificateMountVersion string
ProductName string
ServerRootDirectory string
Expand Down Expand Up @@ -128,6 +129,7 @@ func operatorRun(namespace string, cfg *rest.Config) error {
// Setup all Controllers
bv := util.BuildVariables{
ImageRepository: ImageRepository,
ImageVersion: ImageVersion,
LegacyServingCertificateMountVersion: LegacyServingCertificateMountVersion,
ProductName: ProductName,
ServerRootDirectory: ServerRootDirectory,
Expand Down
9 changes: 6 additions & 3 deletions pkg/resources/deployment.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package resources

import (
"fmt"
"os"
"path"

Expand Down Expand Up @@ -237,11 +238,13 @@ func getServingCertificateMountPath(version string, legacyServingCertificateMoun
}

func getVersion(buildVariables util.BuildVariables) string {
fmt.Println("Getting version from IMAGE_VERSION environment variable ...")
version := os.Getenv("IMAGE_VERSION")
if version == "" {
if len(version) > 0 {
version = buildVariables.ImageVersion
} else {
fmt.Println("Getting version from build variable ImageVersion")
version = buildVariables.ImageVersion
if len(version) == 0 {
fmt.Println("Defaulting to version being latest")
version = "latest"
}
}
Expand Down

0 comments on commit e4e15a9

Please sign in to comment.