Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: argocd app manifests --local option (#5525) #7658

Closed
wants to merge 2 commits into from

Conversation

Cylix
Copy link
Contributor

@Cylix Cylix commented Nov 9, 2021

Context

Closes #5525:

Summary

Add CLI command for local templating, mainly when using Helm

Motivation

In order to scan K8s files in PR, they should be templated, but if the application has parameter override, then the user should know how argocd do the templating.

Misc.

We actually do a form of this in argocd app diff --local so it makes sense to have a command for it. But instead of argocd app template it should go under the existing argocd app manifests e.g.:

argocd app manifests APPNAME --local=./path/to/repo

Changes

I mostly followed how argo app diff --local is implemented for consistency and tried to reuse the existing getLocalObjects that does what we need.

Testing

I started an Argo server with helm install charts/argo-cd -n argocd-helm --generate-name and configured a sample helm app.

Among other things, I verified the following:

  • argocd app manifests helm-sample-app --help
  • argocd app manifests helm-sample-app --source live
  • argocd app manifests helm-sample-app --source git
  • argocd app manifests helm-sample-app --source git --local charts/helm-example

There does not seem to be existing unit tests for NewApplicationManifestsCommand, but let me know if that's something you'd like me to add.

Checklist

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • Optional. My organization is added to USERS.md.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).

@codecov
Copy link

codecov bot commented Nov 9, 2021

Codecov Report

Merging #7658 (667e8ea) into master (2cff57e) will decrease coverage by 3.60%.
The diff coverage is 0.00%.

❗ Current head 667e8ea differs from pull request most recent head e5afd26. Consider uploading reports for the commit e5afd26 to get more accurate results

@@            Coverage Diff             @@
##           master    #7658      +/-   ##
==========================================
- Coverage   45.89%   42.28%   -3.61%     
==========================================
  Files         227      176      -51     
  Lines       27327    22815    -4512     
==========================================
- Hits        12541     9647    -2894     
+ Misses      13084    11792    -1292     
+ Partials     1702     1376     -326     
Impacted Files Coverage Δ
cmd/argocd/commands/app.go 0.52% <0.00%> (-19.48%) ⬇️
util/oidc/provider.go 5.88% <0.00%> (-52.95%) ⬇️
util/util.go 25.00% <0.00%> (-41.67%) ⬇️
util/git/creds.go 10.00% <0.00%> (-31.18%) ⬇️
util/grpc/errors.go 22.72% <0.00%> (-24.45%) ⬇️
util/oidc/templates.go 0.00% <0.00%> (-21.43%) ⬇️
util/grpc/logging.go 40.00% <0.00%> (-18.34%) ⬇️
server/repository/repository.go 36.40% <0.00%> (-16.02%) ⬇️
util/oidc/oidc.go 40.67% <0.00%> (-15.45%) ⬇️
... and 134 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2cff57e...e5afd26. Read the comment docs.

@Cylix Cylix force-pushed the 5525-cli-app-manifests-local branch from 1ae13f5 to 292bb39 Compare November 11, 2021 03:48
@Cylix Cylix mentioned this pull request Feb 13, 2022
@Cylix Cylix force-pushed the 5525-cli-app-manifests-local branch from 0ec889e to 667e8ea Compare February 13, 2022 01:32
Signed-off-by: Simon Ninon <simon.ninon@gmail.com>
@Cylix Cylix force-pushed the 5525-cli-app-manifests-local branch from 667e8ea to 4102f81 Compare February 13, 2022 01:34
cluster, err := clusterIf.Get(context.Background(), &clusterpkg.ClusterQuery{Name: app.Spec.Destination.Name, Server: app.Spec.Destination.Server})
errors.CheckError(err)

unstructureds = getLocalObjects(app, local, localRepoRoot, argoSettings.AppLabelKey, cluster.ServerVersion, cluster.Info.APIVersions, argoSettings.KustomizeOptions, argoSettings.ConfigManagementPlugins, argoSettings.TrackingMethod)
Copy link

@w4rgrum w4rgrum Mar 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is local really useful for the manifests use case ?
Couldn't we use app.Spec.Source.Path instead of having to provide its value with local?
Then regarding the if local != "" condition to enable this behavior I would say checking if len(localRepoRoot) > 0 instead would make sense.

@todaywasawesome todaywasawesome self-requested a review July 14, 2022 13:45
Copy link
Contributor

@todaywasawesome todaywasawesome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I validated the commands are working as expected. There is some question of how useful this is but it has been implemented as designed in #5525 which had several requesters. So I think it's reasonable to merge.

@crenshaw-dev
Copy link
Member

@todaywasawesome, @Cylix I'm reopening here to fix a merge conflict I missed: #10061

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ArgoCD CLI local template
4 participants