-
Notifications
You must be signed in to change notification settings - Fork 2k
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 config command and config validate subcommand to nomad CLI #9198
cli: add config command and config validate subcommand to nomad CLI #9198
Conversation
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 very much for this @th0m.
I would be curious of your thoughts, as well as others, around the command nomad config validate
rather than nomad config-validate
? In my mind, this allows for additional config based sub-commands in the future thus providing future flexibility while keeping the experience consistent.
Makes sense to me @jrasell, happy to change it. |
501babd
to
85b7249
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.
Thanks for the update. I have suggested a couple of changes along with a question regarding the error handling which I would be keen to get your feedback on as a target user for this command.
command/config_validate_test.go
Outdated
} | ||
defer os.Remove(fh) | ||
|
||
ui := new(cli.MockUi) |
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.
ui := new(cli.MockUi) | |
ui := cli.NewMockUi() |
command/config_validate_test.go
Outdated
t.Fatalf("err: %s", err) | ||
} | ||
|
||
ui := new(cli.MockUi) |
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.
ui := new(cli.MockUi) | |
ui := cli.NewMockUi() |
command/config_validate_test.go
Outdated
t.Fatalf("err: %s", err) | ||
} | ||
|
||
ui := new(cli.MockUi) |
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.
ui := new(cli.MockUi) | |
ui := cli.NewMockUi() |
command/config_validate.go
Outdated
if err != nil { | ||
c.Ui.Error(fmt.Sprintf( | ||
"Error loading configuration from %s: %s", path, err)) | ||
return 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.
I am curious on your thoughts here around the use of multierror? In the event of multiple files having validation issues, the command can output all the errors in a single run, rather than needing the operator to run the command multiple times to fix each issue which is displayed.
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.
Great idea, I'll use multierror.
@jrasell @th0m It may be good to refactor the isValidConfig call so that it can be used here. Currently, the command just validates the config can be parsed, but it may have settings that will cause Nomad not to be able to start: |
85b7249
to
0993c5a
Compare
0993c5a
to
793f7e8
Compare
793f7e8
to
45ec419
Compare
@dadgar following your suggestion I've made the @jrasell I think I have addressed all your comments, can you please re-review? Thanks both. |
@jrasell sorry about the repeated ping but in case you missed my previous message this PR is now ready for review 🙂 |
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.
Looking pretty good @th0m! I've left some comments but mostly it's just tightening up language at this point.
c8f821f
to
0cfb338
Compare
Thank you @tgross, I have committed both of your suggestions and squashed the three commits into one. |
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
Thanks @tgross! |
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
This command is similar to the
consul validate
command and can be used to perform configuration validation before actually restarting Nomad and risking a failure if there is an issue in the configuration.Also added three test cases to the
command
test suite: