Skip to content
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

[cli] Add flags to change exit codes on plan command #236

Merged
merged 5 commits into from
Apr 12, 2022

Conversation

angrycub
Copy link
Contributor

@angrycub angrycub commented Apr 11, 2022

Description
Provide CLI flags to allow end users to specify the exit codes for the plan command.

Closes #224

Reminders

  • Add CHANGELOG.md entry

@angrycub angrycub marked this pull request as ready for review April 11, 2022 22:13
Copy link
Contributor

@lgfa29 lgfa29 left a comment

Choose a reason for hiding this comment

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

:shipit:

Comment on lines +198 to +217
f.IntVar(&flag.IntVar{
Name: "exit-code-no-changes",
Target: &c.exitCodeNoChanges,
Default: 0,
Usage: `Override exit code returned when the plan shown no changes.`,
})

f.IntVar(&flag.IntVar{
Name: "exit-code-makes-changes",
Target: &c.exitCodeChanges,
Default: 1,
Usage: `Override exit code returned when the plan shows changes.`,
})

f.IntVar(&flag.IntVar{
Name: "exit-code-error",
Target: &c.exitCodeError,
Default: 255,
Usage: `Override exit code returned when there is an error.`,
})
Copy link
Contributor

Choose a reason for hiding this comment

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

One alternative that I thought would be to have k=v flag that can be defined multiple times instead of specific flags:

$ nomad-pack plan -exit-code "error=20" -exit-code "no-changes=2"

It seems like it would be easier to add new values, but I don't know if it would actually provide any real benefit.

@angrycub angrycub force-pushed the f-plan-exit-codes branch from 23e1df6 to 44327cf Compare April 12, 2022 20:14
@angrycub angrycub self-assigned this Apr 12, 2022
@angrycub angrycub added type/enhancement theme/pack/execution Relates to running, planning, and, stopping packs theme/cli Relates to the CLI in general labels Apr 12, 2022
@angrycub angrycub merged commit 0d97c6d into main Apr 12, 2022
@angrycub angrycub deleted the f-plan-exit-codes branch April 12, 2022 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/cli Relates to the CLI in general theme/pack/execution Relates to running, planning, and, stopping packs type/enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nomad-pack plan has an exit code of 1
2 participants