Boolean template value substitution #8194
-
Hey folks! I'm trying to customize the value of prune and selHeal depending on the environment I'm deploying to, but I cannot be able to interpolate boolean values. Could someone help me, please? My manifest looks like this: apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: myapp-www
namespace: argocd
spec:
generators:
- list:
elements:
- environment: dev
cluster: nonprod
selfHeal: true
prune: true
- environment: ppd
cluster: nonprod
selfHeal: true
prune: true
- environment: prod
cluster: prod
selfHeal: true
prune: false
template:
metadata:
name: 'myapp-www-{{environment}}'
spec:
project: "myapp-www"
source:
repoURL: https://myrepo.com/web/myapp-deployment.git
targetRevision: HEAD
path: '.deploy'
destination:
name: '{{cluster}}'
namespace: 'myapp-www-{{environment}}'
syncPolicy:
automated:
prune: '{{prune}}'
selfHeal: '{{selfHeal}}'
syncOptions:
- CreateNamespace=true Thanks in advance for the help and for this amazing product! |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 4 replies
-
@brunocascio this is a known issue. The issues you could track
You could try removing the single quotes around the values:
to
|
Beta Was this translation helpful? Give feedback.
-
Hello, i have the same problem, i'm using helm and can't find a way to pass a boolean. Validator always throw an error:
This is what i tried (which is working for the other params with string expected):
|
Beta Was this translation helpful? Give feedback.
-
I'm running into the same issue, looking forward to a fix. |
Beta Was this translation helpful? Give feedback.
-
i am using kubectl, i got error on client |
Beta Was this translation helpful? Give feedback.
-
Hi, is there any workaround for this issue? I have the same problem, I need to set the skipCrds flag to true/false |
Beta Was this translation helpful? Give feedback.
-
I'm also facing the same issue, any working solutions ? |
Beta Was this translation helpful? Give feedback.
-
acutally they state here that it is not possible |
Beta Was this translation helpful? Give feedback.
-
If you applying the setup via kustomize or from a Helm Chart to ArgoCD , you can "trick" the system by overriding it via the patch (not nice but it works): https://argo-cd.readthedocs.io/en/stable/operator-manual/applicationset/Template/#template-patch Specific example (kustomize): apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: myapp-www
namespace: argocd
spec:
generators:
- list:
elements:
- environment: dev
cluster: nonprod
selfHeal: true
prune: true
- environment: ppd
cluster: nonprod
selfHeal: true
prune: true
- environment: prod
cluster: prod
selfHeal: true
prune: false
template:
metadata:
name: 'myapp-www-{{environment}}'
spec:
project: "myapp-www"
source:
repoURL: https://myrepo.com/web/myapp-deployment.git
targetRevision: HEAD
path: '.deploy'
destination:
name: '{{cluster}}'
namespace: 'myapp-www-{{environment}}'
syncPolicy:
syncOptions:
- CreateNamespace=true
templatePatch: |
spec:
syncPolicy:
automated:
prune: {{ .prune }}
selfHeal: {{ .selfHeal }} Specific example (Helm): apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: myapp-www
namespace: argocd
spec:
generators:
- list:
elements:
- environment: dev
cluster: nonprod
selfHeal: true
prune: true
- environment: ppd
cluster: nonprod
selfHeal: true
prune: true
- environment: prod
cluster: prod
selfHeal: true
prune: false
template:
metadata:
name: 'myapp-www-{{environment}}'
spec:
project: "myapp-www"
source:
repoURL: https://myrepo.com/web/myapp-deployment.git
targetRevision: HEAD
path: '.deploy'
destination:
name: '{{cluster}}'
namespace: 'myapp-www-{{environment}}'
syncPolicy:
syncOptions:
- CreateNamespace=true
templatePatch: |
spec:
syncPolicy:
automated:
prune: {{`{{ .prune }}`}}
selfHeal: {{`{{ .selfHeal }}`}} For Helm you need the extra {{`...`}} |
Beta Was this translation helpful? Give feedback.
@brunocascio this is a known issue. The issues you could track
You could try removing the single quotes around the values:
from
to