Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
kylecarbs merged 8 commits intomainfromcli
Feb 10, 2022
Merged

feat: Add "coder" CLI#221

kylecarbs merged 8 commits intomainfromcli
Feb 10, 2022

Conversation

kylecarbs
Copy link
Member

@kylecarbskylecarbs commentedFeb 9, 2022
edited
Loading

Scaffolds the base of the CLI, and establishes a basic design for the IO.

image

bryphe-coder reacted with hooray emojibryphe-coder reacted with rocket emoji
@kylecarbskylecarbs self-assigned thisFeb 9, 2022
@codecov
Copy link

codecovbot commentedFeb 9, 2022
edited
Loading

Codecov Report

Merging#221 (6aec3a1) intomain (277318b) willdecrease coverage by1.28%.
The diff coverage is52.69%.

Impacted file tree graph

@@            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
FlagCoverage Δ
unittest-go-macos-latest65.02% <52.69%> (-1.42%)⬇️
unittest-go-ubuntu-latest66.35% <52.69%> (-1.28%)⬇️
unittest-go-windows-latest66.07% <67.32%> (+0.09%)⬆️
unittest-js64.76% <ø> (ø)
Impacted FilesCoverage Δ
cli/projectcreate.go3.60% <3.60%> (ø)
codersdk/users.go68.96% <53.84%> (-2.66%)⬇️
cli/login.go54.90% <54.90%> (ø)
cli/config/file.go61.76% <61.76%> (ø)
cli/projectplan.go62.50% <62.50%> (ø)
cli/projectupdate.go62.50% <62.50%> (ø)
coderd/users.go59.68% <64.70%> (+0.36%)⬆️
cli/root.go69.74% <69.74%> (ø)
coderd/cmd/root.go81.69% <77.77%> (-4.43%)⬇️
cli/projects.go100.00% <100.00%> (ø)
... and6 more

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last update277318b...6aec3a1. Read thecomment docs.

require.NoError(t,err)
data,err:=root.Session().Read()
require.NoError(t,err)
require.Equal(t,"test",string(data))
Copy link
Contributor

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)

kylecarbs reacted with eyes emoji
Comment on lines +27 to +32
Long:` ▄█▀ ▀█▄
▄▄ ▀▀▀ █▌ ██▀▀█▄ ▐█
▄▄██▀▀█▄▄▄ ██ ██ █▀▀█ ▐█▀▀██ ▄█▀▀█ █▀▀
█▌ ▄▌ ▐█ █▌ ▀█▄▄▄█▌ █ █ ▐█ ██ ██▀▀ █
██████▀▄█ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀▀ ▀▀▀▀ ▀
`+color.New(color.Underline).Sprint("Self-hosted developer workspaces on your infra")+`
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice 😎

kylecarbs reacted with rocket emoji
return coderd.Organization{},nil
}
// For now, we won't use the config to set this.
// Eventually, we will support changing using "coder switch <org>"
Copy link
Contributor

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())
Copy link
Contributor

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.

Copy link
MemberAuthor

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!

}

funccreateClient(cmd*cobra.Command) (*codersdk.Client,error) {
root:=createConfig(cmd)
Copy link
Contributor

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 likeKeychain,wincred,SecretStore, etc to persist the credentials? For example, using the credential helpers here:https://github.com/docker/docker-credential-helpers ?

Copy link
MemberAuthor

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!


funclogin()*cobra.Command {
return&cobra.Command{
Use:"login <url>",
Copy link
Contributor

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?

Copy link
MemberAuthor

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.

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!

kylecarbs reacted with heart emoji
Copy link
Contributor

@bryphe-coderbryphe-coder left a 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!

fmt.Fprintf(cmd.OutOrStdout(),"%s %s\n",color.HiGreenString("[parse]"),log.Output)
}

fmt.Printf("Projects %+v %+v\n",projects,organization)
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure whereprojects is getting populated here. Do we need to make an extra call w/ the job ID from ImportProvisionerJob to get it?

Copy link
MemberAuthor

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'skinda in a mergeable state, but not really.

@@ -0,0 +1,161 @@
package cli
Copy link
Contributor

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 ourMakefile? Likemake bin/coder?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yes! I'll add.


funclogin()*cobra.Command {
return&cobra.Command{
Use:"login <url>",

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!

kylecarbs reacted with heart emoji
@kylecarbs
Copy link
MemberAuthor

I already know I'll have to abstract the terminal console out for Windows, but I really don't want to 😢

@kylecarbskylecarbs merged commit07fe5ce intomainFeb 10, 2022
@kylecarbskylecarbs deleted the cli branchFebruary 10, 2022 14:33
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

2 more reviewers

@jawnsyjawnsyjawnsy left review comments

@bryphe-coderbryphe-coderbryphe-coder approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

@kylecarbskylecarbs

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@kylecarbs@jawnsy@bryphe-coder

[8]ページ先頭

©2009-2025 Movatter.jp