-
Notifications
You must be signed in to change notification settings - Fork 892
feat: Add "coder" CLI #221
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
Conversation
Codecov Report
@@ Coverage Diff @@
## main #221 +/- ##
==========================================
- Coverage 68.43% 67.14% -1.29%
==========================================
Files 111 120 +9
Lines 6003 6484 +481
Branches 67 67
==========================================
+ Hits 4108 4354 +246
- Misses 1507 1711 +204
- Partials 388 419 +31
Continue to review full report at Codecov.
|
cli/config/file_test.go
Outdated
require.NoError(t, err) | ||
data, err := root.Session().Read() | ||
require.NoError(t, err) | ||
require.Equal(t, "test", string(data)) |
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 didn't realize GH actions could push failures inline - that's kind of cool (re: lint errors on this line)
Long: ` ▄█▀ ▀█▄ | ||
▄▄ ▀▀▀ █▌ ██▀▀█▄ ▐█ | ||
▄▄██▀▀█▄▄▄ ██ ██ █▀▀█ ▐█▀▀██ ▄█▀▀█ █▀▀ | ||
█▌ ▄▌ ▐█ █▌ ▀█▄▄▄█▌ █ █ ▐█ ██ ██▀▀ █ | ||
██████▀▄█ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀▀ ▀▀▀▀ ▀ | ||
` + color.New(color.Underline).Sprint("Self-hosted developer workspaces on your infra") + ` |
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.
Nice 😎
return coderd.Organization{}, nil | ||
} | ||
// For now, we won't use the config to set this. | ||
// Eventually, we will support changing using "coder switch <org>" |
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.
Sounds good.
} | ||
|
||
client := codersdk.New(serverURL) | ||
hasInitialUser, err := client.HasInitialUser(cmd.Context()) |
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.
That's cool that it guides you through set-up the first time you login, if there isn't a user available yet.
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.
Agreed! I wanted the full flow to be available. I added tests now too!
} | ||
|
||
func createClient(cmd *cobra.Command) (*codersdk.Client, error) { | ||
root := createConfig(cmd) |
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.
It looks like we're sticking with the write-token-to-file approach - do you think it's worth logging an issue to use platform-specific tools like Keychain
, wincred
, SecretStore
, etc to persist the credentials? For example, using the credential helpers here: https://github.com/docker/docker-credential-helpers ?
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 think it's wise to use something else, yeah. I was going to do this post-black triangle. I'll make an issue!
|
||
func login() *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "login <url>", |
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.
We should have tests in place that run the CLI on Windows / Linux / Mac - maybe that would be a good-first-issue for getting someone on-boarded in the repo?
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 actually just made some! I wasn't sure how to scaffold it, but I think it's OK for now.
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 guess having support for a fake db should make these tests easier now!
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.
Just a few questions, but overall this looks great. Looking forward to being able to create projects so that we can run through the full flow!
cli/projectcreate.go
Outdated
fmt.Fprintf(cmd.OutOrStdout(), "%s %s\n", color.HiGreenString("[parse]"), log.Output) | ||
} | ||
|
||
fmt.Printf("Projects %+v %+v\n", projects, organization) |
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.
Wow, GH actions is able to inline the test failures too. It looks like there are some failures here that are caught in CI.
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 sure where projects
is getting populated here. Do we need to make an extra call w/ the job ID from ImportProvisionerJob to get it?
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.
Yeah, I adjusted this a bit to make more sense for the state it's in. It's kinda in a mergeable state, but not really.
@@ -0,0 +1,161 @@ | |||
package cli |
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.
Should this be added to our Makefile
? Like make bin/coder
?
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.
Yes! I'll add.
|
||
func login() *cobra.Command { | ||
return &cobra.Command{ | ||
Use: "login <url>", |
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 guess having support for a fake db should make these tests easier now!
I already know I'll have to abstract the terminal console out for Windows, but I really don't want to 😢 |
Scaffolds the base of the CLI, and establishes a basic design for the IO.