Skip to content

Commit adbd913

Browse files
authored
Provide Diff for new apps (#18)
* Initial commit of "Provide Diff for new apps" * Delete temp app after diff * Nest ArgoCD configuration keys under one key. * Add configuration key to toggle this feature * Add some feature limitation to docs * Use prBtanch for temp app object TargetRevision
1 parent 322cad1 commit adbd913

File tree

7 files changed

+366
-74
lines changed

7 files changed

+366
-74
lines changed

docs/installation.md

+11-7
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,11 @@ Configuration keys:
123123
|`autoApprovePromotionPrs`| if true the bot will auto-approve all promotion PRs, with the assumption the original PR was peer reviewed and is promoted verbatim. Required additional GH token via APPROVER_GITHUB_OAUTH_TOKEN env variable|
124124
|`toggleCommitStatus`| Map of strings, allow (non-repo-admin) users to change the [Github commit status](https://docs.github.com/en/rest/commits/statuses) state(from failure to success and back). This can be used to continue promotion of a change that doesn't pass repo checks. the keys are strings commented in the PRs, values are [Github commit status context](https://docs.github.com/en/rest/commits/statuses?apiVersion=2022-11-28#create-a-commit-status) to be overridden|
125125
|`whProxtSkipTLSVerifyUpstream`| This disables upstream TLS server certificate validation for the webhook proxy functionality. Default is `false`. |
126-
|`commentArgocdDiffonPR`| Uses ArgoCD API to calculate expected changes to k8s state and comment the resulting "diff" as comment in the PR. Requires ARGOCD_* environment variables, see below. |
127-
|`autoMergeNoDiffPRs`| if true, Telefonistka will **merge** promotion PRs that are not expected to change the target clusters. Requires `commentArgocdDiffonPR` and possibly `autoApprovePromotionPrs`(depending on repo branch protection rules)|
128-
|`useSHALabelForArgoDicovery`| The default method for discovering relevant ArgoCD applications (for a PR) relies on fetching all applications in the repo and checking the `argocd.argoproj.io/manifest-generate-paths` **annotation**, this might cause a performance issue on a repo with a large number of ArgoCD applications. The alternative is to add SHA1 of the application path as a **label** and rely on ArgoCD server-side filtering, label name is `telefonistka.io/component-path-sha1`.|
129-
|`allowSyncArgoCDAppfromBranchPathRegex`| This controls which component(=ArgoCD apps) are allowed to be "applied" from a PR branch, by setting the ArgoCD application `Target Revision` to PR branch.|
126+
|`argocd.commentDiffonPR`| Uses ArgoCD API to calculate expected changes to k8s state and comment the resulting "diff" as comment in the PR. Requires ARGOCD_* environment variables, see below. |
127+
|`argocd.autoMergeNoDiffPRs`| if true, Telefonistka will **merge** promotion PRs that are not expected to change the target clusters. Requires `commentArgocdDiffonPR` and possibly `autoApprovePromotionPrs`(depending on repo branch protection rules)|
128+
|`argocd.useSHALabelForAppDiscovery`| The default method for discovering relevant ArgoCD applications (for a PR) relies on fetching all applications in the repo and checking the `argocd.argoproj.io/manifest-generate-paths` **annotation**, this might cause a performance issue on a repo with a large number of ArgoCD applications. The alternative is to add SHA1 of the application path as a **label** and rely on ArgoCD server-side filtering, label name is `telefonistka.io/component-path-sha1`.|
129+
|`argocd.allowSyncfromBranchPathRegex`| This controls which component(=ArgoCD apps) are allowed to be "applied" from a PR branch, by setting the ArgoCD application `Target Revision` to PR branch.|
130+
|`argocd.createTempAppObjectFromNewApps`| For application created in PR Telefonistka needs to create a temporary ArgoCD Application Object to render the manifests, this key enables this behavior. The application spec is pulled from a Matching ApplicationSet object and the temporary object is deleted after the manifests are rendered. This feature currently support ApplicationSets with Git **Directory** generator|
130131
<!-- markdownlint-enable MD033 -->
131132

132133
Example:
@@ -172,9 +173,12 @@ promotionPaths:
172173
- "clusters/prod/us-east4/c2"
173174
dryRunMode: true
174175
autoApprovePromotionPrs: true
175-
commentArgocdDiffonPR: true
176-
autoMergeNoDiffPRs: true
177-
allowSyncArgoCDAppfromBranchPathRegex: '^workspace/.*$'
176+
argocd:
177+
commentDiffonPR: true
178+
autoMergeNoDiffPRs: true
179+
allowSyncfromBranchPathRegex: '^workspace/.*$'
180+
useSHALabelForAppDiscovery: true
181+
createTempAppObjectFromNewApps: true
178182
toggleCommitStatus:
179183
override-terrafrom-pipeline: "github-action-terraform"
180184
```

go.mod

+27-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ toolchain go1.22.1
77
require github.com/alexliesenfeld/health v0.8.0
88

99
require (
10-
github.com/argoproj/argo-cd/v2 v2.11.2
11-
github.com/argoproj/gitops-engine v0.7.1-0.20240416142647-fbecbb86e412
10+
github.com/argoproj/argo-cd/v2 v2.11.4
11+
github.com/argoproj/gitops-engine v0.7.1-0.20240702153804-5995eca2fb63
1212
github.com/bradleyfalzon/ghinstallation/v2 v2.10.0
1313
github.com/cenkalti/backoff/v4 v4.2.1
1414
github.com/go-test/deep v1.1.0
@@ -34,15 +34,19 @@ require (
3434
require (
3535
cloud.google.com/go/compute v1.25.1 // indirect
3636
cloud.google.com/go/compute/metadata v0.2.3 // indirect
37+
code.gitea.io/sdk/gitea v0.15.1 // indirect
3738
dario.cat/mergo v1.0.0 // indirect
3839
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
3940
github.com/MakeNowJust/heredoc v1.0.0 // indirect
41+
github.com/Masterminds/goutils v1.1.1 // indirect
4042
github.com/Masterminds/semver/v3 v3.2.1 // indirect
43+
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
4144
github.com/Microsoft/go-winio v0.6.1 // indirect
4245
github.com/ProtonMail/go-crypto v1.0.0 // indirect
4346
github.com/a8m/envsubst v1.4.2 // indirect
4447
github.com/alecthomas/participle/v2 v2.1.1 // indirect
4548
github.com/argoproj/pkg v0.13.7-0.20230626144333-d56162821bd1 // indirect
49+
github.com/aws/aws-sdk-go v1.50.8 // indirect
4650
github.com/beorn7/perks v1.0.1 // indirect
4751
github.com/blang/semver/v4 v4.0.0 // indirect
4852
github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect
@@ -60,11 +64,14 @@ require (
6064
github.com/emicklei/go-restful/v3 v3.12.0 // indirect
6165
github.com/emirpasic/gods v1.18.1 // indirect
6266
github.com/evanphx/json-patch v5.9.0+incompatible // indirect
67+
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
6368
github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect
6469
github.com/fatih/camelcase v1.0.0 // indirect
6570
github.com/fatih/color v1.16.0 // indirect
6671
github.com/felixge/httpsnoop v1.0.4 // indirect
72+
github.com/fsnotify/fsnotify v1.6.0 // indirect
6773
github.com/fvbommel/sortorder v1.1.0 // indirect
74+
github.com/gfleury/go-bitbucket-v1 v0.0.0-20220301131131-8e7ed04b843e // indirect
6875
github.com/go-errors/errors v1.5.1 // indirect
6976
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
7077
github.com/go-git/go-billy/v5 v5.5.0 // indirect
@@ -86,36 +93,48 @@ require (
8693
github.com/google/btree v1.1.2 // indirect
8794
github.com/google/gnostic v0.7.0 // indirect
8895
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
96+
github.com/google/go-github/v35 v35.3.0 // indirect
8997
github.com/google/go-github/v56 v56.0.0 // indirect
9098
github.com/google/go-github/v60 v60.0.0 // indirect
9199
github.com/google/go-querystring v1.1.0 // indirect
92100
github.com/google/gofuzz v1.2.0 // indirect
93101
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
94102
github.com/google/uuid v1.6.0 // indirect
95103
github.com/gorilla/mux v1.8.0 // indirect
104+
github.com/gosimple/slug v1.13.1 // indirect
105+
github.com/gosimple/unidecode v1.0.1 // indirect
96106
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
97107
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
98108
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
99109
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
100110
github.com/hashicorp/go-retryablehttp v0.7.4 // indirect
111+
github.com/hashicorp/go-version v1.2.1 // indirect
112+
github.com/huandu/xstrings v1.3.3 // indirect
101113
github.com/imdario/mergo v0.3.16 // indirect
102114
github.com/inconshreveable/mousetrap v1.1.0 // indirect
103115
github.com/itchyny/gojq v0.12.13 // indirect
104116
github.com/itchyny/timefmt-go v0.1.5 // indirect
105117
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
118+
github.com/jeremywohl/flatten v1.0.1 // indirect
106119
github.com/jinzhu/copier v0.4.0 // indirect
120+
github.com/jmespath/go-jmespath v0.4.0 // indirect
107121
github.com/jonboulle/clockwork v0.4.0 // indirect
108122
github.com/josharian/intern v1.0.0 // indirect
109123
github.com/json-iterator/go v1.1.12 // indirect
110124
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
111125
github.com/kevinburke/ssh_config v1.2.0 // indirect
112126
github.com/klauspost/compress v1.17.8 // indirect
127+
github.com/ktrysmt/go-bitbucket v0.9.67 // indirect
113128
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
114129
github.com/magiconair/properties v1.8.7 // indirect
115130
github.com/mailru/easyjson v0.7.7 // indirect
116131
github.com/mattn/go-colorable v0.1.13 // indirect
117132
github.com/mattn/go-isatty v0.0.20 // indirect
133+
github.com/microsoft/azure-devops-go-api/azuredevops v1.0.0-b5 // indirect
134+
github.com/mitchellh/copystructure v1.0.0 // indirect
118135
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
136+
github.com/mitchellh/mapstructure v1.5.0 // indirect
137+
github.com/mitchellh/reflectwalk v1.0.0 // indirect
119138
github.com/moby/spdystream v0.2.0 // indirect
120139
github.com/moby/term v0.5.0 // indirect
121140
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
@@ -139,12 +158,17 @@ require (
139158
github.com/robfig/cron/v3 v3.0.1 // indirect
140159
github.com/russross/blackfriday/v2 v2.1.0 // indirect
141160
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
161+
github.com/shopspring/decimal v1.2.0 // indirect
142162
github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466 // indirect
143163
github.com/skeema/knownhosts v1.2.2 // indirect
164+
github.com/spf13/cast v1.6.0 // indirect
144165
github.com/spf13/pflag v1.0.5 // indirect
166+
github.com/valyala/bytebufferpool v1.0.0 // indirect
167+
github.com/valyala/fasttemplate v1.2.2 // indirect
145168
github.com/vmihailenco/go-tinylfu v0.2.2 // indirect
146169
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
147170
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
171+
github.com/xanzy/go-gitlab v0.91.1 // indirect
148172
github.com/xanzy/ssh-agent v0.3.3 // indirect
149173
github.com/xlab/treeprint v1.2.0 // indirect
150174
github.com/yuin/gopher-lua v1.1.1 // indirect
@@ -163,6 +187,7 @@ require (
163187
golang.org/x/time v0.5.0 // indirect
164188
golang.org/x/tools v0.21.0 // indirect
165189
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
190+
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
166191
google.golang.org/genproto v0.0.0-20240401170217-c3f982113cda // indirect
167192
google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda // indirect
168193
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect

0 commit comments

Comments
 (0)