From 2eb17acd80f8907c0c3df4c5ca6226c186fe2a6f Mon Sep 17 00:00:00 2001 From: David MICHENEAU Date: Wed, 6 Nov 2024 14:26:02 +0100 Subject: [PATCH 1/2] fix: now use the last version release of kimup --- .goreleaser.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index c5ad4b1..0bab7db 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -9,7 +9,7 @@ release: prerelease: auto snapshot: - version_template: "{{ .Tag }}" + version_template: "{{ .Version }}" checksum: name_template: '{{ .ProjectName }}-{{ .Version }}-checksums.txt' @@ -26,6 +26,8 @@ builds: - arm64 env: - CGO_ENABLED=0 + ldflags: + - '-X main.version={{.Tag}}' - id: "kimup-operator" binary: kimup-operator main: ./cmd/operator From 7e91e1112056b37a896ac3f05a7cda30eaa9862c Mon Sep 17 00:00:00 2001 From: David MICHENEAU Date: Wed, 6 Nov 2024 15:11:54 +0100 Subject: [PATCH 2/2] fix: release version used --- .goreleaser.yaml | 4 +++- cmd/kimup/main.go | 8 ++------ internal/controller/const.go | 6 ------ internal/controller/resources_controller.go | 7 ++++--- internal/models/version.go | 3 +++ 5 files changed, 12 insertions(+), 16 deletions(-) create mode 100644 internal/models/version.go diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 0bab7db..4468c48 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -27,7 +27,7 @@ builds: env: - CGO_ENABLED=0 ldflags: - - '-X main.version={{.Tag}}' + - '-X github.com/orange-cloudavenue/kube-image-updater/internal/models.Version={{.Tag}}' - id: "kimup-operator" binary: kimup-operator main: ./cmd/operator @@ -39,6 +39,8 @@ builds: - arm64 env: - CGO_ENABLED=0 + ldflags: + - '-X github.com/orange-cloudavenue/kube-image-updater/internal/models/models.Version={{.Tag}}' dockers: # * KIMUP diff --git a/cmd/kimup/main.go b/cmd/kimup/main.go index 63e0270..1c0a8bd 100644 --- a/cmd/kimup/main.go +++ b/cmd/kimup/main.go @@ -18,11 +18,7 @@ import ( "github.com/orange-cloudavenue/kube-image-updater/internal/triggers" ) -var ( - version = "dev" // set by build script - - c = make(chan os.Signal, 1) -) +var c = make(chan os.Signal, 1) func init() { // Initialize the metrics @@ -40,7 +36,7 @@ func init() { func main() { signal.Notify(c, syscall.SIGINT, syscall.SIGTERM) - log.WithField("version", version).Info("Starting kimup", version) + log.WithField("version", models.Version).Info("Starting kimup", models.Version) // kubernetes golang library provide flag "kubeconfig" to specify the path to the kubeconfig file k, err := kubeclient.New(flag.Lookup("kubeconfig").Value.String(), kubeclient.ComponentController) diff --git a/internal/controller/const.go b/internal/controller/const.go index 248f09e..ed99719 100644 --- a/internal/controller/const.go +++ b/internal/controller/const.go @@ -1,7 +1,5 @@ package controller -var Version = "dev" - const ( BaseKimupImage = "ghcr.io/orange-cloudavenue/" @@ -14,10 +12,6 @@ const ( KimupController = "controller" KimupControllerName = KimupName + "-" + KimupController KimupControllerImage = BaseKimupImage + KimupControllerName - - KimupAdmissionController = "admission-controler" - KimupAdmissionControllerName = KimupName + "-" + KimupAdmissionController - KimupAdmissionControllerImage = BaseKimupImage + KimupAdmissionControllerName ) const ( diff --git a/internal/controller/resources_controller.go b/internal/controller/resources_controller.go index 9d09783..d0c81b5 100644 --- a/internal/controller/resources_controller.go +++ b/internal/controller/resources_controller.go @@ -9,6 +9,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "github.com/orange-cloudavenue/kube-image-updater/api/v1alpha1" + "github.com/orange-cloudavenue/kube-image-updater/internal/models" "github.com/orange-cloudavenue/kube-image-updater/internal/utils" ) @@ -23,7 +24,7 @@ func GetKimupControllerResources(ctx context.Context, ki v1alpha1.Kimup) []Objec ) if image == "" { - image = fmt.Sprintf("%s:%s", KimupControllerImage, Version) + image = fmt.Sprintf("%s:%s", KimupControllerImage, models.Version) } // Create a deployment @@ -48,7 +49,7 @@ func GetKimupControllerResources(ctx context.Context, ki v1alpha1.Kimup) []Objec KubernetesAppComponentLabelKey: KimupControllerName, KubernetesAppInstanceNameLabel: name, KubernetesAppNameLabelKey: KimupControllerName, - KubernetesAppVersionLabelKey: Version, + KubernetesAppVersionLabelKey: models.Version, KubernetesPartOfLabelKey: KimupControllerName, KubernetesManagedByLabelKey: KimupOperatorName, "app": name, @@ -135,7 +136,7 @@ func GetKimupControllerResources(ctx context.Context, ki v1alpha1.Kimup) []Objec KubernetesAppComponentLabelKey: KimupControllerName, KubernetesAppInstanceNameLabel: name, KubernetesAppNameLabelKey: KimupControllerName, - KubernetesAppVersionLabelKey: Version, + KubernetesAppVersionLabelKey: models.Version, KubernetesPartOfLabelKey: KimupControllerName, KubernetesManagedByLabelKey: KimupOperatorName, "app": name, diff --git a/internal/models/version.go b/internal/models/version.go new file mode 100644 index 0000000..4a925f7 --- /dev/null +++ b/internal/models/version.go @@ -0,0 +1,3 @@ +package models + +var Version = "dev"