-
Notifications
You must be signed in to change notification settings - Fork 7.7k
feat: Make spec.source.helm.values field accepts either a string or a rawExtension #8794
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
Closed
mcbenjemaa
wants to merge
10
commits into
argoproj:master
from
mcbenjemaa:feat/argocd-helm-values-raw
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2dda807
Make values accepts a string and an object
mcbenjemaa 4abd841
Fix string Values
mcbenjemaa 61ca96d
Make argocd application spec.source.hem.values accepts either a stri…
mcbenjemaa b5f6ecd
Add org to users
mcbenjemaa e23b384
Fix e2e test and fix lint
mcbenjemaa 953ce0a
Add unit test for helm values as raw format
mcbenjemaa 831035a
Fix MarshalJSON
mcbenjemaa 40533b2
Fix TestHelmValuesLiteralFileRemote test
b6718cb
Add a cli flag for accepting helm values as raw object and adding an …
mcbenjemaa f201dc1
Regenrate
mcbenjemaa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -576,6 +576,7 @@ func NewApplicationUnsetCommand(clientOpts *argocdclient.ClientOptions) *cobra.C | |
| kustomizeImages []string | ||
| pluginEnvs []string | ||
| appOpts cmdutil.AppOptions | ||
| valuesRawLiteral bool | ||
| ) | ||
| var command = &cobra.Command{ | ||
| Use: "unset APPNAME parameters", | ||
|
|
@@ -632,7 +633,7 @@ func NewApplicationUnsetCommand(clientOpts *argocdclient.ClientOptions) *cobra.C | |
| } | ||
| } | ||
| if app.Spec.Source.Helm != nil { | ||
| if len(parameters) == 0 && len(valuesFiles) == 0 && !valuesLiteral && !ignoreMissingValueFiles { | ||
| if len(parameters) == 0 && len(valuesFiles) == 0 && !valuesLiteral && !valuesRawLiteral && !ignoreMissingValueFiles { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| c.HelpFunc()(c, args) | ||
| os.Exit(1) | ||
| } | ||
|
|
@@ -647,7 +648,13 @@ func NewApplicationUnsetCommand(clientOpts *argocdclient.ClientOptions) *cobra.C | |
| } | ||
| } | ||
| if valuesLiteral { | ||
| app.Spec.Source.Helm.Values = "" | ||
| app.Spec.Source.Helm.Values.Values = "" | ||
| updated = true | ||
| } | ||
| if valuesRawLiteral { | ||
| app.Spec.Source.Helm.Values = argoappv1.StringOrObject{ | ||
| Raw: nil, | ||
| } | ||
| updated = true | ||
| } | ||
| for _, valuesFile := range valuesFiles { | ||
|
|
@@ -705,6 +712,7 @@ func NewApplicationUnsetCommand(clientOpts *argocdclient.ClientOptions) *cobra.C | |
| command.Flags().BoolVar(&kustomizeVersion, "kustomize-version", false, "Kustomize version") | ||
| command.Flags().StringArrayVar(&kustomizeImages, "kustomize-image", []string{}, "Kustomize images name (e.g. --kustomize-image node --kustomize-image mysql)") | ||
| command.Flags().StringArrayVar(&pluginEnvs, "plugin-env", []string{}, "Unset plugin env variables (e.g --plugin-env name)") | ||
| command.Flags().BoolVar(&valuesRawLiteral, "values-raw-literal", false, "Unset literal Helm values raw") | ||
| return command | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,11 +10,13 @@ import ( | |
| "time" | ||
|
|
||
| "github.com/argoproj/gitops-engine/pkg/utils/kube" | ||
| "sigs.k8s.io/yaml" | ||
|
|
||
| log "github.com/sirupsen/logrus" | ||
| "github.com/spf13/cobra" | ||
| "github.com/spf13/pflag" | ||
| v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/apimachinery/pkg/runtime" | ||
| "k8s.io/utils/pointer" | ||
|
|
||
| "github.com/argoproj/argo-cd/v2/pkg/apis/application" | ||
|
|
@@ -74,6 +76,7 @@ type AppOptions struct { | |
| retryBackoffDuration time.Duration | ||
| retryBackoffMaxDuration time.Duration | ||
| retryBackoffFactor int64 | ||
| valuesRaw string | ||
| } | ||
|
|
||
| func AddAppFlags(command *cobra.Command, opts *AppOptions) { | ||
|
|
@@ -126,6 +129,7 @@ func AddAppFlags(command *cobra.Command, opts *AppOptions) { | |
| command.Flags().DurationVar(&opts.retryBackoffDuration, "sync-retry-backoff-duration", argoappv1.DefaultSyncRetryDuration, "Sync retry backoff base duration. Input needs to be a duration (e.g. 2m, 1h)") | ||
| command.Flags().DurationVar(&opts.retryBackoffMaxDuration, "sync-retry-backoff-max-duration", argoappv1.DefaultSyncRetryMaxDuration, "Max sync retry backoff duration. Input needs to be a duration (e.g. 2m, 1h)") | ||
| command.Flags().Int64Var(&opts.retryBackoffFactor, "sync-retry-backoff-factor", argoappv1.DefaultSyncRetryFactor, "Factor multiplies the base duration after each failed sync retry") | ||
| command.Flags().StringVar(&opts.valuesRaw, "values-raw-literal-file", "", "Filename or URL to import as a literal Helm values raw object") | ||
|
crenshaw-dev marked this conversation as resolved.
Outdated
crenshaw-dev marked this conversation as resolved.
crenshaw-dev marked this conversation as resolved.
|
||
| } | ||
|
|
||
| func SetAppSpecOptions(flags *pflag.FlagSet, spec *argoappv1.ApplicationSpec, appOpts *AppOptions) int { | ||
|
|
@@ -151,6 +155,18 @@ func SetAppSpecOptions(flags *pflag.FlagSet, spec *argoappv1.ApplicationSpec, ap | |
| setHelmOpt(&spec.Source, helmOpts{valueFiles: appOpts.valuesFiles}) | ||
| case "ignore-missing-value-files": | ||
| setHelmOpt(&spec.Source, helmOpts{ignoreMissingValueFiles: appOpts.ignoreMissingValueFiles}) | ||
| case "values-raw-literal-file": | ||
| var data []byte | ||
|
|
||
| // read uri | ||
| parsedURL, err := url.ParseRequestURI(appOpts.valuesRaw) | ||
| if err != nil || !(parsedURL.Scheme == "http" || parsedURL.Scheme == "https") { | ||
| data, err = ioutil.ReadFile(appOpts.valuesRaw) | ||
| } else { | ||
| data, err = config.ReadRemoteFile(appOpts.valuesRaw) | ||
| } | ||
| errors.CheckError(err) | ||
|
crenshaw-dev marked this conversation as resolved.
|
||
| setHelmOpt(&spec.Source, helmOpts{valuesRaw: data}) | ||
| case "values-literal-file": | ||
| var data []byte | ||
|
|
||
|
|
@@ -385,6 +401,7 @@ type helmOpts struct { | |
| helmSetFiles []string | ||
| passCredentials bool | ||
| skipCrds bool | ||
| valuesRaw []byte | ||
| } | ||
|
|
||
| func setHelmOpt(src *argoappv1.ApplicationSource, opts helmOpts) { | ||
|
|
@@ -398,7 +415,14 @@ func setHelmOpt(src *argoappv1.ApplicationSource, opts helmOpts) { | |
| src.Helm.IgnoreMissingValueFiles = opts.ignoreMissingValueFiles | ||
| } | ||
| if len(opts.values) > 0 { | ||
| src.Helm.Values = opts.values | ||
| src.Helm.Values.Values = opts.values | ||
| } | ||
| if len(opts.valuesRaw) > 0 { | ||
|
Comment on lines
417
to
+420
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens if someone specifies both? Should we throw an error if they try? |
||
| data, err := yaml.YAMLToJSON(opts.valuesRaw) | ||
| if err != nil { | ||
| log.Fatal(err) | ||
| } | ||
| src.Helm.Values.Raw = &runtime.RawExtension{Raw: data} | ||
| } | ||
| if opts.releaseName != "" { | ||
| src.Helm.ReleaseName = opts.releaseName | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.