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

Already on GitHub?Sign in to your account

Merged
kylecarbs merged 21 commits intomainfromcreateproject
Feb 12, 2022
Merged

Conversation

kylecarbs
Copy link
Member

No description provided.

bryphe-coder reacted with hooray emoji
@codecov
Copy link

codecovbot commentedFeb 11, 2022
edited
Loading

Codecov Report

Merging#246 (f9814be) intomain (df13fef) willincrease coverage by1.08%.
The diff coverage is64.75%.

Impacted file tree graph

@@            Coverage Diff             @@##             main     #246      +/-   ##==========================================+ Coverage   67.24%   68.33%   +1.08%==========================================  Files         124      126       +2       Lines        6516     6898     +382       Branches       69       69              ==========================================+ Hits         4382     4714     +332+ Misses       1712     1707       -5- Partials      422      477      +55
FlagCoverage Δ
unittest-go-macos-latest66.38% <64.62%> (+1.15%)⬆️
unittest-go-ubuntu-latest67.61% <64.12%> (+1.19%)⬆️
unittest-go-windows-latest66.54% <65.04%> (+0.61%)⬆️
unittest-js65.24% <ø> (ø)
Impacted FilesCoverage Δ
coderd/projectversion.go55.22% <ø> (-7.98%)⬇️
codersdk/projects.go70.65% <ø> (-0.23%)⬇️
codersdk/workspaces.go64.03% <0.00%> (-9.71%)⬇️
cli/workspacecreate.go47.36% <47.36%> (ø)
coderd/provisionerjobs.go60.10% <56.19%> (-6.22%)⬇️
coderd/projectimport.go59.39% <59.39%> (ø)
cli/projectcreate.go52.40% <60.15%> (+48.80%)⬆️
provisionerd/provisionerd.go69.35% <63.79%> (-0.57%)⬇️
cli/projects.go76.27% <64.10%> (-23.73%)⬇️
coderd/provisionerdaemons.go57.23% <64.10%> (+4.10%)⬆️
... and26 more

Continue to review full report at Codecov.

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

"github.com/coder/coder/cli"
"github.com/coder/coder/cli/config"
"github.com/coder/coder/codersdk"
"github.com/coder/coder/provisioner/echo"
Copy link
Contributor

Choose a reason for hiding this comment

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

Neat 🎉


// Validates and computes the value for parameters; setting the value on "parameterByName".
func (c*compute)injectScope(ctx context.Context,scopeParams database.GetParameterValuesByScopeParams)error {
scopedParameters,err:=c.db.GetParameterValuesByScope(ctx,scopeParams)
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder ifscopedParameters can benull if there is asql.ErrNoRows, like we saw with projects?

kylecarbs reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

It can be, but in Go you can iterate over a nil array without issue!

}
require.NoError(t,err)
// #nosec
path:=filepath.Join(directory,header.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we should have a check here to sanitize theheader.Name - making sure we can't specify paths like.. that might move up the filesystem. There might be a vulnerability where you could construct atar that has a header with improper paths (like../../) - and let you write a file over an existing file.

This would be bad, for example, if a malicious actor could write over a critical config file, a binary (ie, they overwrite ourprovisionerd with a malicious version that uploads secrets).

Kind of a similar to the example called out here:securego/gosec#439 (comment)

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yes, and we handle this from provisionerd. But I didn't feel it was necessary forclitest.

We should abstract the tar/untar logic out so it's in one place, then add tests for that specific functionality.

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.

Looks good to me overall - I had onesecurity concern and a few small nits.

Looking forward to having this in so we can have the end-to-end flow going next week!


funcprojectCreate()*cobra.Command {
return&cobra.Command{
var (

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 ascoder <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 aboutkubectl 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)

Copy link
MemberAuthor

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.

Choose a reason for hiding this comment

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

kubectl hasexec 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 thecoder 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 individually

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

Copy link
MemberAuthor

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 workspacetest

and expect the same visual output as

coder describe usertest

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!

}

_,err=runPrompt(cmd,&promptui.Prompt{
_,err=prompt(cmd,&promptui.Prompt{

Choose a reason for hiding this comment

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

is there an easy way to run this noninteractively, as in a script? for examplecoder project create abc --org Coder --create-workspace=true

I'd suggest inverting this logic and assuming noninteractive mode, unless the user types-i or--interactive, as the noninteractive mode is usually more common for CLI commands

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I wanted to map out the user experience before making it non-interactive. It should work how you mentioned. With flags that allow the prompts to be bypassed.

Is defaulting to interactive bad if we detect a TTY? I'm not sure if it's expected, but it would be cool.

Choose a reason for hiding this comment

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

Yeah, I think the best argument against making it non-interactive by default is the principle of least astonishment, that most tools don't do that. But there are examples of tools that do default to doing things interactive, likenpm init - so we could just merge this as-is and see what it feels like

One thing I think would be useful, though, is to make sure we're testing a non-interactive use case, ideally as part of our test suite, since that will likely be something people will want (and that people are already doing with v1)

kylecarbs reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Entirely agree!

@kylecarbskylecarbs marked this pull request as ready for reviewFebruary 12, 2022 19:22
@kylecarbskylecarbs merged commit154b9bc intomainFeb 12, 2022
@kylecarbskylecarbs deleted the createproject branchFebruary 12, 2022 19:34
matifali pushed a commit that referenced this pull requestJul 29, 2025
Related PRs:#246#229---------Co-authored-by: DevCats <christofer@coder.com>
gcp-cherry-pick-botbot pushed a commit that referenced this pull requestJul 29, 2025
Related PRs:#246#229---------Co-authored-by: DevCats <christofer@coder.com>
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

No one assigned

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