-
Notifications
You must be signed in to change notification settings - Fork 7k
feat: Allow users to template and render Application's resources fully locally #14365
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
Changes from all commits
4adf309
34a0f06
33c0064
d61d552
2dfff9a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -623,36 +623,62 @@ func constructAppsBaseOnName(appName string, labels, annotations, args []string, | |
| }, nil | ||
| } | ||
|
|
||
| func constructAppsFromFileUrl(fileURL, appName string, labels, annotations, args []string, appOpts AppOptions, flags *pflag.FlagSet) ([]*argoappv1.Application, error) { | ||
| func constructAppsFromFileUrl(fileURL, appName string, labels, annotations, args []string, appOpts AppOptions, flags *pflag.FlagSet, filterByAppName bool) ([]*argoappv1.Application, error) { | ||
| apps := make([]*argoappv1.Application, 0) | ||
| // read uri | ||
| err := readAppsFromURI(fileURL, &apps) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| filteredApps := make([]*argoappv1.Application, 0) | ||
|
Author
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. Now we can filter by application name from 1 file with multiple applications |
||
| for _, app := range apps { | ||
| if len(args) == 1 && args[0] != app.Name { | ||
| return nil, fmt.Errorf("app name '%s' does not match app spec metadata.name '%s'", args[0], app.Name) | ||
| } | ||
| if appName != "" && appName != app.Name { | ||
| app.Name = appName | ||
| if filterByAppName { | ||
| if len(args) == 1 { | ||
| if appName != "" && appName != args[0] { | ||
| return nil, fmt.Errorf("--name argument '%s' does not match app name %s", appName, args[0]) | ||
| } | ||
| appName = args[0] | ||
| } | ||
|
|
||
| if appName == app.Name { | ||
|
Contributor
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. Why do we need a separate 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. I think in case the file given as |
||
| SetAppSpecOptions(flags, &app.Spec, &appOpts) | ||
| SetParameterOverrides(app, appOpts.Parameters) | ||
| mergeLabels(app, labels) | ||
| setAnnotations(app, annotations) | ||
| filteredApps = append(filteredApps, app) | ||
| } | ||
| } else { | ||
| if len(args) == 1 && args[0] != app.Name { | ||
| return nil, fmt.Errorf("app name '%s' does not match app spec metadata.name '%s'", args[0], app.Name) | ||
| } | ||
| if appName != "" && appName != app.Name { | ||
| app.Name = appName | ||
| } | ||
| if app.Name == "" { | ||
| return nil, fmt.Errorf("app.Name is empty. --name argument can be used to provide app.Name") | ||
| } | ||
| SetAppSpecOptions(flags, &app.Spec, &appOpts) | ||
| SetParameterOverrides(app, appOpts.Parameters) | ||
| mergeLabels(app, labels) | ||
| setAnnotations(app, annotations) | ||
| filteredApps = append(filteredApps, app) | ||
| } | ||
| if app.Name == "" { | ||
| return nil, fmt.Errorf("app.Name is empty. --name argument can be used to provide app.Name") | ||
| } | ||
|
|
||
| if filterByAppName { | ||
| if len(filteredApps) == 0 { | ||
| return nil, fmt.Errorf("App name '%s' does not match any app spec in '%s'", appName, fileURL) | ||
| } | ||
| SetAppSpecOptions(flags, &app.Spec, &appOpts) | ||
| SetParameterOverrides(app, appOpts.Parameters) | ||
| mergeLabels(app, labels) | ||
| setAnnotations(app, annotations) | ||
| } | ||
| return apps, nil | ||
|
|
||
| return filteredApps, nil | ||
| } | ||
|
|
||
| func ConstructApps(fileURL, appName string, labels, annotations, args []string, appOpts AppOptions, flags *pflag.FlagSet) ([]*argoappv1.Application, error) { | ||
| func ConstructApps(fileURL, appName string, labels, annotations, args []string, appOpts AppOptions, flags *pflag.FlagSet, filterByAppName bool) ([]*argoappv1.Application, error) { | ||
| if fileURL == "-" { | ||
| return constructAppsFromStdin() | ||
| } else if fileURL != "" { | ||
| return constructAppsFromFileUrl(fileURL, appName, labels, annotations, args, appOpts, flags) | ||
| return constructAppsFromFileUrl(fileURL, appName, labels, annotations, args, appOpts, flags, filterByAppName) | ||
| } | ||
| return constructAppsBaseOnName(appName, labels, annotations, args, appOpts, flags) | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.