-
Notifications
You must be signed in to change notification settings - Fork 897
feat: Add "coder projects create" command #246
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
7167fa0
Refactor parameter parsing to return nil values if none computed
kylecarbs 65380db
Refactor parameter to allow for hiding redisplay
kylecarbs 94eb484
Refactor parameters to enable schema matching
kylecarbs a6ce22d
Refactor provisionerd to dynamically update parameter schemas
kylecarbs e53f0be
Refactor job update for provisionerd
kylecarbs 4466836
Handle multiple states correctly when provisioning a project
kylecarbs 8fe05d6
Add project import job resource table
kylecarbs 79a56b6
Basic creation flow works!
kylecarbs dc86c0e
Create project fully works!!!
kylecarbs bff96b6
Only show job status if completed
kylecarbs 8766a33
Add create workspace support
kylecarbs aac220f
Replace Netflix/go-expect with ActiveState
kylecarbs c493bf9
Fix linting errors
kylecarbs 485c07b
Use forked chzyer/readline
kylecarbs b5a774a
Add create workspace CLI
kylecarbs d2cbf36
Add CLI test
kylecarbs a8d00d8
Move jobs to their own APIs
kylecarbs 9c7746f
Merge branch 'main' into createproject
kylecarbs e4770bb
Remove go-expect
kylecarbs c6cee94
Fix requested changes
kylecarbs f9814be
Skip workspacecreate test on windows
kylecarbs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Refactor parameters to enable schema matching
- Loading branch information
commit 94eb484655a33d5e5d6899886330e84c83eae9c3
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package cli_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/Netflix/go-expect" | ||
"github.com/coder/coder/cli/clitest" | ||
"github.com/coder/coder/coderd/coderdtest" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestProjectCreate(t *testing.T) { | ||
t.Parallel() | ||
t.Run("InitialUserTTY", func(t *testing.T) { | ||
t.Parallel() | ||
console, err := expect.NewConsole(expect.WithStdout(clitest.StdoutLogs(t))) | ||
require.NoError(t, err) | ||
client := coderdtest.New(t) | ||
directory := t.TempDir() | ||
cmd, root := clitest.New(t, "projects", "create", "--directory", directory) | ||
_ = clitest.CreateInitialUser(t, client, root) | ||
cmd.SetIn(console.Tty()) | ||
cmd.SetOut(console.Tty()) | ||
go func() { | ||
err := cmd.Execute() | ||
require.NoError(t, err) | ||
}() | ||
|
||
matches := []string{ | ||
"organization?", "y", | ||
"name?", "", | ||
} | ||
for i := 0; i < len(matches); i += 2 { | ||
match := matches[i] | ||
value := matches[i+1] | ||
_, err = console.ExpectString(match) | ||
require.NoError(t, err) | ||
_, err = console.SendLine(value) | ||
require.NoError(t, err) | ||
} | ||
}) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'd propose structuring these commands as
coder <verb> <subject>
similar tokubectl
. When you demoed this command to me, that was what you had typed the first time, too, suggesting that it feels more "natural" - it also reads better that way, in my opinion.For example:
coder create project
The nice thing about
kubectl
is that most of the commands follow an identical pattern, sokubectl get pods
,kubectl get deployments
etc feel natural. Putting the verb after makes it more likely that they will diverge, which is always unexpected (e.g. cases wherekubectl project create
is a valid command butkubectl workspace create
is not)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 is a significantly more human approach. I'm trying to think of edge-cases in which that won't work, but I'm yet to find any!
Maybe discoverability would be hurt? eg. adding the root verb for a bespoke action a specific resource has could get really messy. I'm not sure how frequently we'll need to do that though.
ssh
andplan
are the only odd ones I can think of.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.
kubectl has
exec
andlogs
and a few other commands that don't follow the pattern, so we could havecoder ssh <workspace>
orcoder plan <workspace>
(if we anticipate that there will be other things we'll need to SSH into, we could also docoder ssh workspace <workspace>
or similar, of course - we don't have to implementcoder ssh project
, since that doesn't make much sense)Thinking about it now, one reason the
coder create
pattern might be helpful is because of persistent flags.kubectl
has a--file
flag that applies to allcreate
verbs, so you can implement it as a persistent flag oncreate
. On the other hand, if we have separatecreate
leaf commands, then we'd have to make sure we consistently implement--file
for everything individuallyThere 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 can also always make these changes after merging this PR, it's not urgent, but would be nice to do it before we publish things, because then we're on the hook to maintain stability of the interface
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 lose specificity and customization in output when we standardize using verbs first. eg. it'd be a bit weird for a user to run:
coder describe workspace test
and expect the same visual output as
coder describe user test
Maybe it's good to force us down a consistency route there though.
As you mentioned, we can polish this later. It's definitely a nice standardization forcing-function that provides consistency to our CLI experience!