Skip to content

feat: refactor deployment config - #6347

Merged
ammario merged 89 commits into
mainfrom
bigcli
Mar 7, 2023
Merged

ammario merged 89 commits into
mainfrom
bigcli

Conversation

@ammario

@ammario ammario commented Feb 25, 2023 •

Copy link
Copy Markdown
Member

This PR introduces a new bigcli package and refactors coder server to use it instead of cobra/viper. It enables non-janky long-help formatting, doc generation, and YAML support. As a follow-up, I will convert the rest of the coder CLI to use bigcli. After a month or two of stability, we can open source bigcli, probably replacing the defunct coder/cli.

The line of codes should be around net zero, but the new code will be much easier to understand, maintain, and extend.

Breaking changes:

  • Removed long-deprecated Experimental flag

TODO

  • Support Git Auth
  • Manually confirm that environment variable and flag names match old implementation

Follow-on issues:

High-priority-cleanup

  • Generate CLI docs again
  • Convert the rest of the CLI to bigcli
  • Refactor rest of cli/server_test.go to use "clitest.Start" for better cleanup and error reporting
  • Regenerate golden files

Other

  • Document / Validate YAML works
  • Send back telemetry for each server option, plus how they're set. This makes it easier to make / communicate breaking changes.
  • Document how Support Links work in the YAML
  • Generate all Deployment setting pages and navigation from Options array

Comment thread cli/bigcli/value.go Fixed

@mafredri mafredri left a comment

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.

I haven't taken a look at the actual CLI output, but so far this seems like an improvement over what we have. I'd like to see the re-introduction of golden files (for the server command) so that visual changes are always verified.

It looks like a few things are still missing for this to be mergeable, so just leaving comments for now.

PS. I'm not sold on the name, what makes it big? 😆.

Comment thread cli/bigcli/bigcli.go Resolved
Comment thread cli/bigcli/command.go
return strings.Join(names, " ")
}

// FullName returns usage of the command, preceded

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.

Suggested change
// FullName returns usage of the command, preceded
// FullUsage returns usage of the command, preceded

Comment thread cli/bigcli/command.go Outdated

// FullName returns usage of the command, preceded
// by the usage of its parents.
func (c *Command) FullUsage() string {

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.

When do we need to show parent command usage in addition to current command usage?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We do so in the help template, perhaps not validly.

Comment thread cli/bigcli/option.go
type OptionSet []Option

// Add adds the given Options to the OptionSet.
func (s *OptionSet) Add(opts ...Option) {

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.

Consider updating function signature, since this is a set, we should do some verification/erroring here. Alternatively we may consider renaming, whichever makes more sense.

Comment thread cli/bigcli/option.go

// ParseEnv parses the given environment variables into the OptionSet.
func (s *OptionSet) ParseEnv(globalPrefix string, environ []string) error {
var merr *multierror.Error

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.

Should we consider using errors.Join instead? (I see we have one or two other uses of multierr currently, but we could nip that in the bud unless they give us something we need.

Comment thread cli/config/file.go Resolved
Comment thread cli/usage.go Resolved
Comment thread cli/usage.tpl Resolved
Comment thread coderd/users_test.go Resolved
Comment thread codersdk/deployment.go Resolved
@ammario

ammario commented Mar 6, 2023 •

Copy link
Copy Markdown
Member Author

PS. I'm not sold on the name, what makes it big? 😆.

Struggled to find a good name, but big because it's meant to support bigger CLIs lol. If we think it's not very clear, I'm also down to use a more "cute" name like serpent (following on the cobra/viper snake theme).

I'd like to see the re-introduction of golden files (for the server command) so that visual changes are always verified.

I added this as a high priority follow-up.

@ammario
ammario requested a review from kylecarbs March 6, 2023 19:19
@ammario ammario mentioned this pull request Mar 7, 2023
10 of 18 tasks

@kylecarbs kylecarbs left a comment

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.

Some manual stuff testing:

image
^See the lack of space between running and Coder

image
^It says "Git Authentication Providers" randomly

image
^It's worth manually checking if this is still working by default. I know the value was false before, but somehow internally I think it was actually true.

image
This is in the deployment settings.

Comment thread cli/root_test.go Resolved
Comment thread cli/clibase/bigcli.go Resolved
Comment thread cli/clibase/env.go Resolved
@ammario
ammario merged commit 3b73321 into main Mar 7, 2023
@ammario
ammario deleted the bigcli branch March 7, 2023 21:10
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants