Comments (4)
@steve-todorov I read the thread. Do you have .spec.goTemplate
set to true
in your ApplicationSet resource?
from argo-cd.
@christianh814 yes I have it (updated the ticket to reflect this, sorry)
spec:
goTemplate: true
goTemplateOptions: ["missingkey=error"]
from argo-cd.
@steve-todorov It shouldn't "matter" but have you tried using ''
instead? Like '{{.branch}}'
and 'https://github.com/{{.organization}}/{{.repository}}'
from argo-cd.
@christianh814 My code slightly evolved since I've opened the ticket, because I've introduced a custom plugin that generates some additional parameters based on the branch name. I've tried a few combinations but none of them work (again showing either a missing .branch
, .organization
, repository
error or .case_number
one).
Basically the idea is to have the scmProvider
scan for the repos, then have the plugin
generate dynamic properties based on branch name convention and finally give an option to manually override properties via a git path in the same repository when a file with the same case number exists.
Example 1:
spec:
goTemplate: true
goTemplateOptions: ["missingkey=error"]
generators:
- matrix:
generators:
- scmProvider:
cloneProtocol: ssh
github:
organization: my-organization
allBranches: true
tokenRef:
secretName: github-token
key: token
filters:
- repositoryMatch: ^my-repository$
branchMatch: ^kustomize|scm/([0-9]+).*$
pathsExist: [deployment/kubernetes/kustomization.yaml]
- plugin:
configMapRef:
# produces some parameters based on the branch naming convention (i.e. case_number)
name: applicationset-branch-generator-plugin
input:
parameters:
branch: '{{.branch}}'
project_code: 'exmpl'
organization: '{{.organization}}'
repository: '{{.repository}}'
requeueAfterSeconds: 30
- git:
repoURL: '[email protected]:{{.organization}}/{{.repository}}.git'
revision: '{{.branch}}'
files:
- path: 'deployment/kubernetes/properties/{{.case_number}}.yml'
Example 2:
spec:
goTemplate: true
goTemplateOptions: ["missingkey=error"]
generators:
- matrix:
generators:
- scmProvider:
cloneProtocol: ssh
github:
organization: my-organization
allBranches: true
tokenRef:
secretName: github-token
key: token
filters:
- repositoryMatch: ^my-repository$
branchMatch: ^kustomize|scm/([0-9]+).*$
pathsExist: [deployment/kubernetes/kustomization.yaml]
- matrix:
generators:
- plugin:
configMapRef:
# produces some parameters based on the branch naming convention (i.e. case_number)
name: applicationset-branch-generator-plugin
input:
parameters:
branch: '{{.branch}}'
project_code: 'exmpl'
organization: '{{.organization}}'
repository: '{{.repository}}'
requeueAfterSeconds: 30
- git:
repoURL: '[email protected]:{{.organization}}/{{.repository}}.git'
revision: '{{.branch}}'
files:
- path: 'deployment/kubernetes/properties/{{.case_number}}.yml'
Here's an example output of the generator plugin:
10.0.0.8 - - [02/Jul/2024 12:19:19] "POST /api/v1/getparams.execute HTTP/1.1" 200 -
Received arguments: {'applicationSetName': 'exmpl-staging-scm-preview', 'input': {'parameters': {'branch': 'scm/35765-some-title', 'organization': 'my-organization', 'project_code': 'exmpl', 'repository': 'my-repository'}}}
Output parameters: {'case_number': '35765', 'subdomain': '35765-exmpl-staging-scm', 'memoryRequest': '500Mi', 'memoryLimit': '700Mi', 'keycloakServerUrl': 'https://keycloak-staging.local.domain/auth', 'branch': 'scm/35765-some-title', 'organization': 'my-organization', 'project_code': 'exmpl', 'repository': 'my-repository'}
So the plugin does receive the proper values and switching from double quotes "
to single quotes '
seems to be resolving the .branch
/ .organization
/ .repository
error. Unfortunately now it's unable to resolve the .case_number
that's generated by the custom generator
plugin.
ERRO[301695] error interpolating generator with other generator's parameter error="failed to replace parameters in generator: failed to execute go template deployment/kubernetes/properties/{{.case_number}}.yml: template: :1:35: executing \"\" at <.case_number>: map has no entry for key \"case_number\"" interpolatedGenerator=nil
ERRO[301695] error interpolating params for generator error="failed to replace parameters in generator: failed to execute go template deployment/kubernetes/properties/{{.case_number}}.yml: template: :1:35: executing \"\" at <.case_number>: map has no entry for key \"case_number\"" genParams="map[branch:kustomize branchNormalized:kustomize labels: organization:my-organization repository:my-repository sha:xdfe8ccb3609e14d1ada9cf1967568f9e277075 short_sha:abdfe8cc short_sha_7:abdfe8c url:[email protected]:my-organization/my-repository.git]"
ERRO[301695] error generating params error="failed to get params for second generator in the matrix generator: child generator returned an error on parameter generation: failed to replace parameters in generator: failed to execute go template deployment/kubernetes/properties/{{.case_number}}.yml: template: :1:35: executing \"\" at <.case_number>: map has no entry for key \"case_number\"" generator="&{map[ClusterDecisionResource:0xc001383590 Clusters:0xc001383540 Git:0xc0013e7a70 List:0x75e9dc0 Matrix:0xc0013980e0 Merge:0xc0013980e8 Plugin:0xc001560bc0 PullRequest:0xc001395680 SCMProvider:0xc001395620]}"
ERRO[301695] error generating application from params applicationset=argocd/exmpl-staging-scm-preview error="failed to get params for second generator in the matrix generator: child generator returned an error on parameter generation: failed to replace parameters in generator: failed to execute go template deployment/kubernetes/properties/{{.case_number}}.yml: template: :1:35: executing \"\" at <.case_number>: map has no entry for key \"case_number\"" generator="{nil nil nil nil nil nil &MatrixGenerator{Generators:[]ApplicationSetNestedGenerator{ApplicationSetNestedGenerator{List:nil,Clusters:nil,Git:nil,SCMProvider:&SCMProviderGenerator{Github:&SCMProviderGeneratorGithub{Organization:my-organization,API:,TokenRef:&SecretRef{SecretName:github-token,Key:token,},AppSecretName:,AllBranches:true,},Gitlab:nil,Bitbucket:nil,BitbucketServer:nil,Gitea:nil,AzureDevOps:nil,Filters:[]SCMProviderGeneratorFilter{SCMProviderGeneratorFilter{RepositoryMatch:*^my-repository$,PathsExist:[deployment/kubernetes/kustomization.yaml],PathsDoNotExist:[],LabelMatch:nil,BranchMatch:*^kustomize|scm/([0-9]+).*$,},},CloneProtocol:ssh,RequeueAfterSeconds:nil,Template:ApplicationSetTemplate{ApplicationSetTemplateMeta:ApplicationSetTemplateMeta{Name:,Namespace:,Labels:map[string]string{},Annotations:map[string]string{},Finalizers:[],},Spec:ApplicationSpec{Source:nil,Destination:ApplicationDestination{Server:,Namespace:,Name:,},Project:,SyncPolicy:nil,IgnoreDifferences:[]ResourceIgnoreDifferences{},Info:[]Info{},RevisionHistoryLimit:nil,Sources:[]ApplicationSource{},},},Values:map[string]string{},AWSCodeCommit:nil,},ClusterDecisionResource:nil,PullRequest:nil,Matrix:nil,Merge:nil,Selector:nil,Plugin:nil,},ApplicationSetNestedGenerator{List:nil,Clusters:nil,Git:nil,SCMProvider:nil,ClusterDecisionResource:nil,PullRequest:nil,Matrix:&v11.JSON{Raw:*[ shortened ],},Merge:nil,Selector:nil,Plugin:nil,},},Template:ApplicationSetTemplate{ApplicationSetTemplateMeta:ApplicationSetTemplateMeta{Name:,Namespace:,Labels:map[string]string{},Annotations:map[string]string{},Finalizers:[],},Spec:ApplicationSpec{Source:nil,Destination:ApplicationDestination{Server:,Namespace:,Name:,},Project:,SyncPolicy:nil,IgnoreDifferences:[]ResourceIgnoreDifferences{},Info:[]Info{},RevisionHistoryLimit:nil,Sources:[]ApplicationSource{},},},} nil nil nil}"
INFO[301720] generated 1 applications
Not sure what I'm doing wrong here. Any ideas?
from argo-cd.
Related Issues (20)
- rpc error: code = Unknown desc = error testing repository connectivity: repository "" cannot be initialized: repo URL is invalid
- argocd.argoproj.io/skip-reconcile requires argocd controller to be restarted HOT 1
- notifications controller not included in core install HOT 1
- maybe long server with speific namespace cause application creation invalid
- rpc error: code = Internal desc = Failed to fetch default: `git fetch origin --tags --force --prune` failed exit status 128: kex_exchange_identification HOT 4
- UI: EndpointSlices should use the same icon as Endpoint objects HOT 1
- Argocd does not respond occasionally HOT 3
- Support for OCI (Oracle Cloud Infrastructure) Integration to Manage OKE Clusters
- Unable to sync helm chart with OCI dependency hosted in private docker.io HOT 1
- Start watch {...} Failed to watch {...} loop when target cluster paused
- Repo URL in application summary page will not open a new tab HOT 1
- Enable git submodule HOT 4
- Ability to update cluster information including labels HOT 1
- changing destination from server to name causes constant app refresh HOT 5
- Use transforming informer for cluster cache
- Application controller can run out of disk space on '/dev/shm', when deploying concurrently to a large number of clusters, or with many large manifests
- ArgoCD does not set OutOfSync status after editing a deployed resource HOT 1
- [UI] App of Apps 'Go-To-Parent' Button on Application Details View HOT 6
- Argo CD versions release-2.9 and release-2.10 are pulling outdated versions of github.com/hashicorp/go-retryablehttp.
- Can't add docker-desktop cluster
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from argo-cd.