Skip to content

Commit

Permalink
Make namespace a top-level command
Browse files Browse the repository at this point in the history
We call namespaces RegistryNamespace in the API because they live
inside the registry.

Users of the CLI don't have to care where namespaces are stored,
and there isn't a great argument for keeping `registry` at the
top-level which further nests namespaces.
  • Loading branch information
Zachary Scott committed Aug 2, 2018
1 parent dc10296 commit e8f77a8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
19 changes: 6 additions & 13 deletions cmd/registry.go → cmd/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,13 @@ import (
"github.com/spf13/cobra"
)

func newRegistryCommand() *cobra.Command {
registryCmd := &cobra.Command{
Use: "registry",
Short: "Operate on the registry",
}

namespaceCommand := &cobra.Command{
func newNamespaceCommand() *cobra.Command {
namespaceCmd := &cobra.Command{
Use: "namespace",
Short: "Operate on orb namespaces (create, etc.)",
Short: "Operate on namespaces",
}

createNamespaceCommand := &cobra.Command{
createCmd := &cobra.Command{
Use: "create [name] [vcs] [org-name]",
Short: "create an namespace",
RunE: createNamespace,
Expand All @@ -29,11 +24,9 @@ func newRegistryCommand() *cobra.Command {
// "org-name", "", "organization name (required)"
// "vcs", "github", "organization vcs, e.g. 'github', 'bitbucket'"

namespaceCommand.AddCommand(createNamespaceCommand)

registryCmd.AddCommand(namespaceCommand)
namespaceCmd.AddCommand(createCmd)

return registryCmd
return namespaceCmd
}

func createNamespace(cmd *cobra.Command, args []string) error {
Expand Down
6 changes: 3 additions & 3 deletions cmd/registry_test.go → cmd/namespace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/onsi/gomega/ghttp"
)

var _ = Describe("Registry integration tests", func() {
var _ = Describe("Namespace integration tests", func() {
var (
testServer *ghttp.Server
token string = "testtoken"
Expand All @@ -29,7 +29,7 @@ var _ = Describe("Registry integration tests", func() {
Describe("registering a namespace", func() {
BeforeEach(func() {
command = exec.Command(pathCLI,
"registry", "namespace", "create",
"namespace", "create",
"-t", token,
"-e", testServer.URL(),
"foo-ns",
Expand Down Expand Up @@ -94,7 +94,7 @@ var _ = Describe("Registry integration tests", func() {
Describe("when creating / reserving a namespace", func() {
BeforeEach(func() {
command = exec.Command(pathCLI,
"registry", "namespace", "create",
"namespace", "create",
"-t", token,
"-e", testServer.URL(),
"foo-ns",
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func MakeCommands() *cobra.Command {
rootCmd.AddCommand(newDiagnosticCommand())
rootCmd.AddCommand(newSetupCommand())
rootCmd.AddCommand(newUpdateCommand())
rootCmd.AddCommand(newRegistryCommand())
rootCmd.AddCommand(newNamespaceCommand())
rootCmd.PersistentFlags().BoolP("verbose", "v", false, "Enable verbose logging.")
rootCmd.PersistentFlags().StringP("endpoint", "e", defaultEndpoint, "the endpoint of your CircleCI GraphQL API")
rootCmd.PersistentFlags().StringP("token", "t", "", "your token for using CircleCI")
Expand Down

0 comments on commit e8f77a8

Please sign in to comment.