Skip to content

Commit 290dc91

Browse files
refactor(gateway-helm-chart): only rewrite chart-default image repos
Previously the subscription rewrite triggered for any repository value starting with `ghcr.io/wso2/api-platform/`, which silently re-mapped explicit overrides such as SHA-pinned or canary references that happen to keep the WSO2 namespace prefix (e.g. `gateway-controller-canary`). Tighten the gate from a prefix check to an exact-default match by passing each component's canonical default repository through a new `defaultRepository` parameter on the `componentImage` helper. Rewriting now happens only when the user has not overridden `image.repository`; any explicit value — including ones still under the WSO2 GHCR namespace — passes through verbatim. Addresses CodeRabbit review feedback on #2017.
1 parent af767b3 commit 290dc91

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

kubernetes/helm/gateway-helm-chart/templates/_helpers.tpl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,22 @@ app.kubernetes.io/component: {{ $component }}
6363

6464
{{/*
6565
Render a component image reference, applying the WSO2 subscription registry rewrite
66-
when wso2.subscription.imagePullSecret is set AND the repository still matches the
67-
default upstream prefix `ghcr.io/wso2/api-platform/`. Explicit overrides pass through.
66+
only when wso2.subscription.imagePullSecret is set AND the repository value is
67+
exactly the chart-canonical default for this component. Any explicit override —
68+
including overrides that happen to stay under `ghcr.io/wso2/api-platform/` (e.g.
69+
SHA-pinned references, canary tags) — passes through unchanged.
6870
69-
Args (dict): root, repository, tag
71+
Args (dict): root, repository, defaultRepository, tag
7072
*/}}
7173
{{- define "gateway-operator.componentImage" -}}
7274
{{- $root := .root -}}
7375
{{- $repo := .repository -}}
76+
{{- $defaultRepo := .defaultRepository -}}
7477
{{- $tag := .tag -}}
7578
{{- $sub := $root.Values.wso2.subscription.imagePullSecret -}}
7679
{{- $defaultPrefix := "ghcr.io/wso2/api-platform/" -}}
7780
{{- $wso2Prefix := "registry.wso2.com/wso2-api-platform/" -}}
78-
{{- if and (ne $sub "") (hasPrefix $defaultPrefix $repo) -}}
81+
{{- if and (ne $sub "") (eq $repo $defaultRepo) (hasPrefix $defaultPrefix $repo) -}}
7982
{{- printf "%s%s:%s" $wso2Prefix (trimPrefix $defaultPrefix $repo) $tag -}}
8083
{{- else -}}
8184
{{- printf "%s:%s" $repo $tag -}}

kubernetes/helm/gateway-helm-chart/templates/gateway/controller/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ spec:
6666
{{- end }}
6767
containers:
6868
- name: gateway-controller
69-
image: {{ include "gateway-operator.componentImage" (dict "root" . "repository" $controller.image.repository "tag" $controller.image.tag) | quote }}
69+
image: {{ include "gateway-operator.componentImage" (dict "root" . "repository" $controller.image.repository "defaultRepository" "ghcr.io/wso2/api-platform/gateway-controller" "tag" $controller.image.tag) | quote }}
7070
imagePullPolicy: {{ $controller.image.pullPolicy }}
7171
{{- with $deployment.securityContext }}
7272
securityContext:

kubernetes/helm/gateway-helm-chart/templates/gateway/gateway-runtime/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ spec:
6363
{{- end }}
6464
containers:
6565
- name: gateway-runtime
66-
image: {{ include "gateway-operator.componentImage" (dict "root" . "repository" $unified.image.repository "tag" $unified.image.tag) | quote }}
66+
image: {{ include "gateway-operator.componentImage" (dict "root" . "repository" $unified.image.repository "defaultRepository" "ghcr.io/wso2/api-platform/gateway-runtime" "tag" $unified.image.tag) | quote }}
6767
imagePullPolicy: {{ $unified.image.pullPolicy }}
6868
args: ["--pol.config", "/etc/policy-engine/config.toml"]
6969
{{- with $deployment.securityContext }}

0 commit comments

Comments
 (0)