Skip to content

Commit 5ad91a3

Browse files
hj-johannes-leetkatila
authored andcommitted
operator: fix upgradeImages
Operatorhub bundle can have sha256 image tags that are put through env vars. When operator controller manager gets upgraded, its operands (plugin daemonsets) should be updated to the image in the env vars. But it has not been working properly because of wrong parsing. Fix it to parse the image names that have sha256 tags correctly so env vars in operator can be used as intended. Additionatlly, add comments with an example result to the part where parsing, trimming, or transforming the name of images happens in UpgradImages to make the process intuitive. Signed-off-by: Hyeongju Johannes Lee <[email protected]>
1 parent 5e4a0ba commit 5ad91a3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

pkg/controllers/reconciler.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,13 @@ func UpgradeImages(ctx context.Context, image *string, initimage *string) (upgra
158158
if s == nil {
159159
continue
160160
}
161-
161+
// e.g. intel-dsa-plugin@sha256:hash -> [intel-dsa-plugin@sha256, hash]
162162
if parts := strings.SplitN(*s, ":", 2); len(parts) == 2 && len(parts[0]) > 0 {
163-
name, version := parts[0], parts[1]
163+
// e.g. [intel-dsa-plugin@sha256, hash] -> [intel-dsa-plugin, hash]
164+
name, version := strings.TrimSuffix(parts[0], "@sha256"), parts[1]
164165

166+
// e.g. intel-dsa-plugin -> INTEL_DSA_PLUGIN_SHA
167+
// and get the value of the env var INTEL_DSA_PLUGIN_SHA
165168
envVarValue := os.Getenv(strings.ReplaceAll(strings.ToUpper(filepath.Base(name)), "-", "_") + "_SHA")
166169

167170
if envVarValue != "" && *s != envVarValue {

0 commit comments

Comments
 (0)