-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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(app): Add optional 'name' to Source object #20470
base: master
Are you sure you want to change the base?
Conversation
❗ Preview Environment deployment failed on BunnyshellSee: Environment Details | Pipeline Logs Available commands (reply to this comment):
|
name
reference to Source object
name
reference to Source object220edee
to
b9e648b
Compare
b9e648b
to
a45c12b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this PR is ready for review, can you go ahead and fix the CI checks?
d70723f
to
f490b1d
Compare
f490b1d
to
e2650a1
Compare
bc501b0
to
ed5b9b6
Compare
01ba671
to
39b0038
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work 👍 The code changes are missing unit tests and maybe e2e too on the different commands. @ishitasequeira has more knowledge on the usage of multi-source. Do you see something that has been forgotten in this PR?
for _, r := range app.Status.Resources { | ||
statusByName[r.Name] = r.Status | ||
} | ||
// check if the app has 3 resources, guestbook and 2 pods |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should validate that the final source is equal to two and contains "dynamic duo" and "guestbook2" items.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CefBoud Thanks for taking this up!! Left some comments. Also, I think this change would also need to be reflected on the Application Create and AddSource UI Pages too.
@@ -381,6 +396,19 @@ func NewApplicationGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com | |||
}) | |||
errors.CheckError(err) | |||
|
|||
if sourceName != "" && sourcePosition != -1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the Name
parameter has been added to the ApplicationSource
object, it's not exclusive to multi-source applications. This means the name
field also applies to single-source apps. Therefore, in all commands where we’re adding the sourceName
check, we should ensure the command supports single-source applications as well, using the sourceName
field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ishitasequeira Thank you for the review.
My reasoning was that although the field is defined in ApplicationSource
, much like Ref
and the implicit source-position
, it only should be considered in the multi-source case. Additionally, the purpose of the proposal was to offer an alternative to source-position
in the multi-source case.
What are your thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works for me. Although, let's update the comment on the Name
field in types.go to reflect that it is mainly used for multi-source apps.
@@ -435,6 +463,7 @@ func NewApplicationGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com | |||
command.Flags().BoolVar(&hardRefresh, "hard-refresh", false, "Refresh application data as well as target manifests cache") | |||
command.Flags().StringVarP(&appNamespace, "app-namespace", "N", "", "Only get application from namespace") | |||
command.Flags().IntVar(&sourcePosition, "source-position", -1, "Position of the source from the list of sources of the app. Counting starts at 1.") | |||
command.Flags().StringVar(&sourceName, "source-name", "", "Name of the source from the list of sources of the app.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, considering Name
is not specific to a multi-source app, the description might need an update.
@@ -751,6 +753,8 @@ func ConstructSource(source *argoappv1.ApplicationSource, appOpts AppOptions, fl | |||
setPluginOptEnvs(source, appOpts.pluginEnvs) | |||
case "ref": | |||
source.Ref = appOpts.ref | |||
case "source-name": | |||
source.Name = appOpts.SourceName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be checking if the name is already assigned to some other source within the app.spec.sources
before allowing to set it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the check in validateAndNormalizeApp
to have a central validation for the both the UI and CLI API calls.
12252d8
to
0a9d9ac
Compare
0a9d9ac
to
1376663
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #20470 +/- ##
==========================================
- Coverage 55.12% 55.02% -0.11%
==========================================
Files 324 324
Lines 55197 55339 +142
==========================================
+ Hits 30430 30452 +22
- Misses 22145 22277 +132
+ Partials 2622 2610 -12 ☔ View full report in Codecov by Sentry. |
@@ -191,6 +191,8 @@ type ApplicationSource struct { | |||
Chart string `json:"chart,omitempty" protobuf:"bytes,12,opt,name=chart"` | |||
// Ref is reference to another source within sources field. This field will not be used if used with a `source` tag. | |||
Ref string `json:"ref,omitempty" protobuf:"bytes,13,opt,name=ref"` | |||
// Name is used to refer to a source and is displayed in the UI. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Considering we want this to be of use only for a multi-source app, can we update the comment to reflect the same?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing. Updated.
@@ -381,6 +396,19 @@ func NewApplicationGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com | |||
}) | |||
errors.CheckError(err) | |||
|
|||
if sourceName != "" && sourcePosition != -1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works for me. Although, let's update the comment on the Name
field in types.go to reflect that it is mainly used for multi-source apps.
1376663
to
129a95b
Compare
Signed-off-by: cef <[email protected]>
129a95b
to
b96f1db
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR looks good!! Thanks @CefBoud!!
@agaudreault do you still have any concerns on the PR? |
Closes #17731
Description
This PR adds an optional 'name' to the Application Source object. It can be used instead of the source position in multi-source Applications CLI.
Screenshots
Checklist: