Skip to content
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

[CIRCLE-12217] Create namespace #28

Merged
merged 1 commit into from
Jul 25, 2018
Merged

[CIRCLE-12217] Create namespace #28

merged 1 commit into from
Jul 25, 2018

Conversation

hannahhenderson
Copy link
Contributor

@hannahhenderson hannahhenderson commented Jul 20, 2018

This PR adds "create namespace" to the list of orb commands (or, more specifically createns, which is open to alternate naming suggestions).

I used a lot of copy-pasting to make this work, thank you @eric-hu . I also benefited from some good old, "Please help me see the forest, oh :rubberduck: @johnswanson, because at this point in time I can only see the trees," unsticking.

Which is all to say, this PR works as expected, but I believe it is a good candidate for some DRY refactoring.

CIRCLE-12217

Examples of this in action in dev:
Ignore the weird UUID output in earlier responses, I deleted some print lines
Also, "GITHUB" and "BITBUCKET" can now be lower case
screen shot 2018-07-24 at 10 16 38 am

Help lists this information:
screen shot 2018-07-24 at 11 11 32 am

@zzak
Copy link
Contributor

zzak commented Jul 20, 2018

@hannahhenderson I will do a formal review soon, but I think we should make --name a positional argument.

@johnswanson
Copy link
Contributor

This is all UX, not go code review :)

What about orb ns create? (Similar to docker network ls, docker network rm, docker network create--specifying the thing you're operating on, then a command to run) Alternatively, orb create-ns?

I also think we should wire it up so you can do:

go run main.go orb create-ns --org "circleci" foo

rather than having to manually look up your org ID. This will require another roundtrip to query for the ID of the org called circleci, but I don't think we can force the user to look up the ID for their orgs :)

Super awesome to see this working!

api/api.go Outdated
messages := []string{}

for i := range response.Errors {
messages = append(messages, response.Errors[i].Message)
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like you are not using the type field here. You should either use it, or drop it from the GQL request.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

api/api.go Outdated

}

func createNamespaceQuery(ctx context.Context, logger *logger.Logger, name string, ownerId string, response interface{}, query string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

can you in-line this function into OrbCreateNamespace please? - I asked Eric to do the same at #27 (comment)

Indeed if we merge Eric's PR and you re-base on top you can re-use his new Errors struct to remove (response CreateNamespaceResponse) ToError()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hannahhenderson
Copy link
Contributor Author

@johnswanson I think that not forcing folks to use a namespaceId when they're adding orbs makes sense, because we are enforcing uniqueness on namespace names.

Organization names aren't unique. Does it make more sense to add a separate "get organization id" CLI call (name + vcs type necessary), or to add all of that info to this call?

api/api.go Outdated

err := graphQLclient.Run(ctx, request, &response)

fmt.Println(response)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you want to delete this line before merging? (In my editor, doing this would also get rid of the "fmt" import at the top on save. I think a default go tool does that, but not sure which.)

@johnswanson johnswanson changed the title [CIRCLE-12217] Create namespace [CIRCLE-12217] WIP: Create namespace Jul 24, 2018
@hannahhenderson hannahhenderson force-pushed the create-namespace branch 2 times, most recently from a4910b0 to a9d0184 Compare July 24, 2018 17:51
Takes a positional 'name' argument and two flags:
'org-name' and (org)'vcs'

Modify appendPostHandler to accept a struct of information
@hannahhenderson hannahhenderson changed the title [CIRCLE-12217] WIP: Create namespace [CIRCLE-12217] Create namespace Jul 24, 2018
@codecov-io
Copy link

codecov-io commented Jul 24, 2018

Codecov Report

Merging #28 into master will increase coverage by 1.41%.
The diff coverage is 53.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #28      +/-   ##
==========================================
+ Coverage   40.82%   42.23%   +1.41%     
==========================================
  Files          11       11              
  Lines         703      715      +12     
==========================================
+ Hits          287      302      +15     
+ Misses        393      390       -3     
  Partials       23       23
Impacted Files Coverage Δ
cmd/orb.go 30.04% <53.33%> (+5.45%) ⬆️
cmd/root.go 75% <0%> (+0.49%) ⬆️
cmd/config.go 46.93% <0%> (+3.83%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7643b5e...4356630. Read the comment docs.

@zzak zzak dismissed marcomorain’s stale review July 25, 2018 04:01

Review was addressed in 4356630

Copy link
Contributor

@zzak zzak left a comment

Choose a reason for hiding this comment

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

LGTM, merging and will follow up with a PR for some minor changes of my own.

@zzak zzak merged commit 41b2030 into master Jul 25, 2018
@zzak zzak mentioned this pull request Jul 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants