diff --git a/operator/deploy/melange.tmpl.yaml b/operator/deploy/melange.tmpl.yaml index 5ec8840b9..de09ba9fc 100644 --- a/operator/deploy/melange.tmpl.yaml +++ b/operator/deploy/melange.tmpl.yaml @@ -24,6 +24,11 @@ pipeline: - runs: | set -exuo pipefail + # remove a 'v' prefix from the version if it exists + if [[ ${VERSION:0:1} == "v" ]]; then + export VERSION=${VERSION:1} + fi + make -C operator build cp operator/bin/manager "${{targets.contextdir}}/manager" - uses: strip diff --git a/operator/pkg/charts/charts.go b/operator/pkg/charts/charts.go index 14ec571dc..b926c3cd5 100644 --- a/operator/pkg/charts/charts.go +++ b/operator/pkg/charts/charts.go @@ -18,6 +18,7 @@ import ( "github.com/replicatedhq/embedded-cluster/pkg/defaults" "github.com/replicatedhq/embedded-cluster/pkg/metrics" "github.com/replicatedhq/embedded-cluster/pkg/release" + "github.com/replicatedhq/embedded-cluster/pkg/versions" kotsv1beta1 "github.com/replicatedhq/kotskinds/apis/kots/v1beta1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -96,8 +97,11 @@ func generateHelmConfigs(ctx context.Context, in *clusterv1beta1.Installation, c if err != nil { return nil, fmt.Errorf("unable to get operator images: %w", err) } + // set the images, location, and version of the operator chart because the files compiled into the embedded-cluster-operator do not include the correct values + // those values depend on the sha256 of the compiled binary itself embeddedclusteroperator.Metadata.Images = oi embeddedclusteroperator.Metadata.Location = operatorLocation + embeddedclusteroperator.Metadata.Version = versions.Version embeddedclusteroperator.Render() migrationStatus := k8sutil.CheckConditionStatus(in.Status, registry.RegistryMigrationStatusConditionType) diff --git a/operator/pkg/charts/charts_test.go b/operator/pkg/charts/charts_test.go index 87973746d..28bd6a037 100644 --- a/operator/pkg/charts/charts_test.go +++ b/operator/pkg/charts/charts_test.go @@ -457,7 +457,7 @@ func test_replaceAddonMeta() { embeddedclusteroperator.Metadata = release.AddonMetadata{ Location: "oci://proxy.replicated.com/anonymous/registry.replicated.com/library/embedded-cluster-operator", } - versions.Version = "1.2.3-operator" // This is not great, the operator addon uses this to determine what version to deploy + versions.Version = "1.2.3-operator" // This is not great, we use this to override the version of the operator chart // we can't use the version from the metadata because it won't be set in the operator binary // TODO fix this diff --git a/pkg/addons/embeddedclusteroperator/embeddedclusteroperator.go b/pkg/addons/embeddedclusteroperator/embeddedclusteroperator.go index 5157426e4..edcb6eab7 100644 --- a/pkg/addons/embeddedclusteroperator/embeddedclusteroperator.go +++ b/pkg/addons/embeddedclusteroperator/embeddedclusteroperator.go @@ -61,7 +61,6 @@ func Render() { helmValues["kotsVersion"] = adminconsole.Metadata.Version helmValues["embeddedClusterVersion"] = versions.Version helmValues["embeddedClusterK0sVersion"] = versions.K0sVersion - Metadata.Version = versions.Version } // EmbeddedClusterOperator manages the installation of the embedded cluster operator