-
Notifications
You must be signed in to change notification settings - Fork 386
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
Add more validation and help to config #814
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.
This is pretty neat!
config/config.go
Outdated
DebuggerPort int `yaml:"debugger_port" help:"What port should the debugger (and other interactive sessions) use to communicate."` | ||
BuildkitRestartTimeoutS int `yaml:"buildkit_restart_timeout_s" help:"How long to wait for buildkit to (re)start, in seconds."` | ||
BuildkitAdditionalArgs []string `yaml:"buildkit_additional_args" help:"Additional args to pass to buildkit when it starts. Useful for custom certs, or user namespace complications."` | ||
BuildkitAdditionalConfig string `yaml:"buildkit_additional_config" help:"Additional config to use when starting the buildkit container; like mounting volumes."` |
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.
Actually mounting volumes would be done through BuilkditAdditionalArgs
. An example might be "using self-signed certificates"
I got a panic when I ran this:
If it's relevant, I don't have a |
I think there's a missing newline required somewhere in the code:
|
@@ -810,17 +810,37 @@ func newEarthlyApp(ctx context.Context, console conslogging.ConsoleLogger) *eart | |||
Usage: "Edits your Earthly configuration file", | |||
Hidden: true, // Experimental. | |||
Action: app.actionConfig, | |||
Description: `This command takes a path, and a value and sets it in your configuration file. | |||
UsageText: `This command takes a path, and a value and sets it in your configuration file. |
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 a standard usage, but there isn't an Examples
section. This kept the flow while being slightly wrong? Willing to reverse or hard-code in the examples section if needed. Also I could make the UsageText
include the current english description,, and the Description
include the examples.
Sample, as it is now:
NAME:
earthly config - Edits your Earthly configuration file
USAGE:
This command takes a path, and a value and sets it in your configuration file.
As the configuration file is YAML, the key must be a valid key within the file. You can specify sub-keys by using "." to separate levels.
If the sub-key you wish to use has a "." in it, you can quote that subsection, like this: git."github.com".
Values must be valid YAML, and also be deserializable into the key you wish to assign them to.
This means you can set higher level objects using a compact style, or single values with simple values.
Only one key/value can be set per invocation.
To get help with a specific key, do "config [key] --help". Or, visit https://docs.earthly.dev/earthly-config for more details.
DESCRIPTION:
Set your cache size:
config global.cache_size_mb 1234
Set additional buildkit args, using a YAML array:
config global.buildkit_additional_args ['userns', '--host']
Set a key containing a period:
config git."example.com".password hunter2
Configure a server called example.com which stored git repos under /var/git/repos/name-of-repo.git and allowed access over ssh using port 2222 with the git username, you can configure earthly to recognize it as example.com/name-of-repo by configuring it with:
config git "{example: {pattern: 'example.com/([^/]+)', substitute: 'ssh://git@example.com:2222/var/git/repos/\$1.git', auth: ssh}}"
OPTIONS:
--dry-run Print the changed config file to the consile instead of writing it out (default: false)
--help, -h show help (default: false)
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.
looks awesome!
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 made your sentence a bulleted list:
Set up a whole custom git repository for a server called example.com, using a single-line YAML literal:
* which stores git repos under /var/git/repos/name-of-repo.git
* allows access over ssh
* using port 2222
* sets the username to git
* is recognized to earthly as example.com/name-of-repo
config git "{example: {pattern: 'example.com/([^/]+)', substitute: 'ssh://git@example.com:2222/var/git/repos/\$1.git', auth: ssh}}"
Adds help text for main command, and for keys (at the expense of being able to set a value to
--help
.Adds validation to ensure you can set the key to that value.