Open Ladanow opened 1 year ago
@Ladanow Our current subscription template has the following to generate the channel:
# Source: clustergroup/templates/core/subscriptions.yaml
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: {{ $subs.name }}
namespace: {{ . }}
spec:
name: {{ $subs.name }}
source: {{ default "redhat-operators" $subs.source }}
sourceNamespace: {{ default "openshift-marketplace" $subs.sourceNamespace }}
{{- if $subs.channel }}
channel: {{ $subs.channel }}
{{- end }}
One solution is to add the quote
filter to the template like so:
# Source: clustergroup/templates/core/subscriptions.yaml
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: {{ $subs.name }}
namespace: {{ . }}
spec:
name: {{ $subs.name }}
source: {{ default "redhat-operators" $subs.source }}
sourceNamespace: {{ default "openshift-marketplace" $subs.sourceNamespace }}
{{- if $subs.channel }}
channel: {{ $subs.channel | quote }}
{{- end }}
So if you define the subscription in the values file like so:
example:
name: example-sub
namespace: example-sub
channel: 4.10
The framework will generate the following:
---
# Source: pattern-clustergroup/templates/core/subscriptions.yaml
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: example-sub
namespace: example-sub
spec:
name: example-sub
source: redhat-operators
sourceNamespace: openshift-marketplace
channel: "4.10"
installPlanApproval: Automatic
I think it is okay to add the | quote
call. I am not sure it fixes it because at least on my laptop helm seems to round the 4.10 channel integer value before calling quote.
For example:
$ cat values.yaml
channel: 4.10
channelstring: "4.10"
$ cat templates/test.yaml
channel: {{ .Values.channel }}
channelquoted: {{ .Values.channel | quote }}
channelstring: {{ .Values.channelstring }}
channelstringquoted: {{ .Values.channelstring | quote }}
The above gives me the following:
$ helm template .
---
# Source: test/templates/test.yaml
channel: 4.1
channelquoted: "4.1"
channelstring: 4.10
channelstringquoted: "4.10"
channelquoted is 4.1 and not 4.10. So I suspect the only fix here is to quote it beforehand in the values files? FWIW I am using helm 3.11.0
@mbaldessari yeah somehow I missed something in my test. I think adding the quote filter does not help here. There are two options:
Tag | Description |
---|---|
!!bool | Denotes a boolean value |
!!int | Denotes a integer value |
!!float | Denotes a floating point number |
!!str | Denotes a string |
In our case for string we can do the following:
example:
name: example-sub
namespace: example-sub
channel: !!str 4.10
example:
name: example-sub
namespace: example-sub
channel: '4.10'
or
example:
name: example-sub
namespace: example-sub
channel: "4.10"
Either case above will render the following:
# Source: pattern-clustergroup/templates/core/subscriptions.yaml
apiVersion: operators.coreos.com/v1alpha1
kind: Subscription
metadata:
name: example-sub
namespace: example-sub
spec:
name: example-sub
source: redhat-operators
sourceNamespace: openshift-marketplace
channel: "4.10"
installPlanApproval: Automatic
@Ladanow This is something that we cannot really address in the Validated Pattern framework so you will have to address it in the values-*.yaml file.
Hi
When we have a channel like 4.10, it is translated into Argo as 4.1
a workaround was set to use "4.10" and it worked.