-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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(cli): add support for multiple sources to sync command #17808
feat(cli): add support for multiple sources to sync command #17808
Conversation
3c4914b
to
6f0039e
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.
Thinking about it, I kind of regret that the "position" thing leaks into the API.
If it is not too late for breaking changes, I would only expose position as CLI parameters, and substract 1 before calling the API. This way, the server and repo-server always use index.
eb6ea3f
to
8006278
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.
LGTM 👍
Signed-off-by: ishitasequeira <ishiseq29@gmail.com>
…n swagger Signed-off-by: ishitasequeira <ishiseq29@gmail.com>
Signed-off-by: ishitasequeira <ishiseq29@gmail.com>
Signed-off-by: ishitasequeira <ishiseq29@gmail.com>
Signed-off-by: ishitasequeira <ishiseq29@gmail.com>
Signed-off-by: ishitasequeira <ishiseq29@gmail.com>
Signed-off-by: ishitasequeira <ishiseq29@gmail.com>
Signed-off-by: ishitasequeira <ishiseq29@gmail.com>
Signed-off-by: ishitasequeira <ishiseq29@gmail.com>
Signed-off-by: ishitasequeira <ishiseq29@gmail.com>
Signed-off-by: ishitasequeira <ishiseq29@gmail.com>
Signed-off-by: ishitasequeira <ishiseq29@gmail.com>
522cda6
to
bf7c7d6
Compare
Signed-off-by: ishitasequeira <ishiseq29@gmail.com>
@@ -2512,7 +2512,7 @@ func (s *Service) ResolveRevision(ctx context.Context, q *apiclient.ResolveRevis | |||
app := q.App | |||
ambiguousRevision := q.AmbiguousRevision | |||
var revision string | |||
var source = app.Spec.GetSource() | |||
var source = app.Spec.GetSourcePtrByIndex(int(q.SourceIndex)) |
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.
Not sure if it is possible that source can be nil, base on validations during app creation, but before this change, source was not reference and it always was not nil, after this change it may happens that you can get error here
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.
At any point, the application will have either at least 1 source in spec.Sources
or spec.Source
defined.
GetSourcePtrByIndex
will default to use source at certain index or 1st source in Sources or spec.Source. The behavior is similar to GetSource
function. Ref: https://github.com/argoproj/argo-cd/pull/17808/files#diff-1a32760cee151b5181abcd273fb66e286a02fd8c99573d988e423528760cc293R238-R245
server/application/application.go
Outdated
|
||
var revision string | ||
var displayRevision string | ||
var sourceRevisions []string |
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.
Can we move these variables calculations to some private function or even to utils?
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.
Moved and added tests.
server/application/application.go
Outdated
ambiguousRevision := syncReq.GetRevision() | ||
if ambiguousRevision == "" { | ||
ambiguousRevision = app.Spec.GetSource().TargetRevision | ||
var ambiguousRevision string |
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, could you please put it as separate function that will return ambiguousRevision
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.
Moved and added tests
@CodiumAI-Agent /review |
PR Review
Code feedback:
✨ Review tool usage guide:Overview: The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.
See the review usage page for a comprehensive guide on using this tool. |
@ishitasequeira this one from Codium, Probably worth to handle such case also |
Signed-off-by: ishitasequeira <ishiseq29@gmail.com>
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.
Thanks @pasha-codefresh for the review.
Data Validation Concern: The current validation checks if pos is less than or equal to numOfSources but does not explicitly check for negative values or non-integer inputs which might cause runtime errors or undefined behavior.
We are already throwing error for pos <= 0. Also for non-integer values, the values will not be allowed either by cmd or by API as they are expected to be of type int64
.
Example of error from CLI thrown before executing the command:
% ./dist/argocd app sync guestbook --source-positions 1.4 --revisions HEAD
Error: invalid argument "1.4" for "--source-positions" flag: strconv.ParseInt: parsing "1.4": invalid syntax
Signed-off-by: ishitasequeira <ishiseq29@gmail.com>
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.
LGTM
/cherry-pick release-2.11 |
Cherry-pick failed with |
…#17808) * update sync command Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * use arrays instead of map to display ApplicationManifetQuery fields in swagger Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * rebase and update logic for sync command Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * update conditions Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * update displayRevisions on OperationState Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * remove rerunreport file Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * fix index 0 out of bounds error Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * Address comments Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * fix codegen Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * rename GetSourcePtrBySourceIndex to GetSourcePtrByIndex Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * rename GetSourcePtrBySourcePosition to GetSourcePtrByPosition Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * rebase with master and resolve conflicts Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * fix codegen Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * Address feedback and add tests Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * fix unit test Signed-off-by: ishitasequeira <ishiseq29@gmail.com> --------- Signed-off-by: ishitasequeira <ishiseq29@gmail.com>
…#17808) * update sync command Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * use arrays instead of map to display ApplicationManifetQuery fields in swagger Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * rebase and update logic for sync command Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * update conditions Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * update displayRevisions on OperationState Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * remove rerunreport file Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * fix index 0 out of bounds error Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * Address comments Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * fix codegen Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * rename GetSourcePtrBySourceIndex to GetSourcePtrByIndex Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * rename GetSourcePtrBySourcePosition to GetSourcePtrByPosition Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * rebase with master and resolve conflicts Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * fix codegen Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * Address feedback and add tests Signed-off-by: ishitasequeira <ishiseq29@gmail.com> * fix unit test Signed-off-by: ishitasequeira <ishiseq29@gmail.com> --------- Signed-off-by: ishitasequeira <ishiseq29@gmail.com>
The PR adds support for multiple sources to
argocd app sync
command. As part of this PR, the support for multiple sources is by the addition of 2 new flags --revisions and --source-positions. This 2 flags allow the user to set a revision for a specific source defined by index in source-positions flag.Example:
Checklist: