Skip to content

feat: add support for parameters when running actions from the CLI (#28000)#28004

Open
olavst-spk wants to merge 7 commits into
argoproj:masterfrom
olavst-spk:cli-action-parameters
Open

feat: add support for parameters when running actions from the CLI (#28000)#28004
olavst-spk wants to merge 7 commits into
argoproj:masterfrom
olavst-spk:cli-action-parameters

Conversation

@olavst-spk
Copy link
Copy Markdown

@olavst-spk olavst-spk commented May 26, 2026

Fixes #28000

Adds a --param key=value flag to argocd app actions run. The parameter parsing logic that already existed in argocd admin settings is moved into a shared ParseActionParameters helper in cmd/util and reused by both commands.

Also fixes the Lua scale actions to separately handle both the "missing parameter" and "invalid value" cases, using the same logic as the existing scale action for keda.sh/ScaledObject

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.
    • Not a new feature, but adds missing CLI support for an existing feature
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Title of the PR
  • 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.
    • Only the CLI needs updating in this case. Action parameters are already supported in the UI
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • 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).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.
  • Optional. My organization is added to USERS.md.
  • Optional. For bug fixes, I've indicated what older releases this fix should be cherry-picked into (this may or may not happen depending on risk/complexity).

@bunnyshell
Copy link
Copy Markdown

bunnyshell Bot commented May 26, 2026

🔴 Preview Environment stopped on Bunnyshell

See: Environment Details | Pipeline Logs

Available commands (reply to this comment):

  • 🔵 /bns:start to start the environment
  • 🚀 /bns:deploy to redeploy the environment
  • /bns:delete to remove the environment

@olavst-spk olavst-spk force-pushed the cli-action-parameters branch 4 times, most recently from f6e47d7 to 444f7c6 Compare May 26, 2026 13:06
@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

❌ Patch coverage is 65.90909% with 15 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (master@a912a3e). Learn more about missing BASE report.

Files with missing lines Patch % Lines
cmd/argocd/commands/app_actions.go 13.33% 13 Missing ⚠️
cmd/argocd/commands/admin/settings.go 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master   #28004   +/-   ##
=========================================
  Coverage          ?   64.60%           
=========================================
  Files             ?      424           
  Lines             ?    58248           
  Branches          ?        0           
=========================================
  Hits              ?    37634           
  Misses            ?    17097           
  Partials          ?     3517           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@olavst-spk olavst-spk force-pushed the cli-action-parameters branch 2 times, most recently from e25b87a to 0882d55 Compare May 27, 2026 07:13
@olavst-spk olavst-spk marked this pull request as ready for review May 27, 2026 08:32
@olavst-spk olavst-spk requested review from a team as code owners May 27, 2026 08:32
Comment thread cmd/argocd/commands/app_actions.go Outdated
Comment thread cmd/util/actions.go
Comment thread cmd/argocd/commands/app_actions.go
@olavst-spk olavst-spk force-pushed the cli-action-parameters branch 2 times, most recently from 4833cdf to f30e92b Compare May 27, 2026 12:26
@olavst-spk olavst-spk requested a review from ppapapetrou76 May 28, 2026 12:35
Comment thread cmd/util/actions.go Outdated
return nil, fmt.Errorf("invalid parameter format %q: parameter name cannot be empty", param)
}
if seen[name] {
return nil, fmt.Errorf("parameter %q is specified more than once", name)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This means duplicate parameter names are not supported after this change. Can you explain the reason for this? AFAIK we support duplicate parameter names where the last value would win at action runtime.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I thought it would be better to return an error rather than silently choosing the last value since that could be confusing to users, but maybe I am missing something? Is there a reason to support setting the same parameter multiple times? What is the use-case for that?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree with @nitishfy and it was I originally suggested

Also there are several cases in the code base that are using the Last-write-wins pattern so let's stick on it

Also we need to document it properly

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Okay, I have updated the code to print a warning instead of exiting with an error.

Do we need to do the documentation update in this PR?

olavst-spk and others added 7 commits May 29, 2026 17:15
Fixes argoproj#28000

Adds a `--param key=value` flag to `argocd app actions run`.
The parameter parsing logic that already existed in `argocd admin settings`
is moved into a shared ParseActionParameters helper in cmd/util and
reused by both commands.

Also fixes the Lua scale actions to separately handle both the
"missing parameter" and "invalid value" cases, using the same logic as the
existing scale action for keda.sh/ScaledObject

Signed-off-by: Olav Thoresen <Olav.Sortland.Thoresen@spk.no>
Co-authored-by: Papapetrou Patroklos <1743100+ppapapetrou76@users.noreply.github.com>
Signed-off-by: Olav Sortland Thoresen <137788666+olavst-spk@users.noreply.github.com>
Signed-off-by: Olav Thoresen <Olav.Sortland.Thoresen@spk.no>
Signed-off-by: Olav Thoresen <Olav.Sortland.Thoresen@spk.no>
Signed-off-by: Olav Thoresen <Olav.Sortland.Thoresen@spk.no>
This reverts commit cc43915.

Signed-off-by: Olav Thoresen <Olav.Sortland.Thoresen@spk.no>
Signed-off-by: Olav Thoresen <Olav.Sortland.Thoresen@spk.no>
@olavst-spk olavst-spk force-pushed the cli-action-parameters branch from 114b91a to 2a442fb Compare May 29, 2026 15:15
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.

Cannot run scale (or other actions that require parameters) from the CLI

3 participants