-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move
namespace
as a sub-command under new registry
command
This includes `namespace create`, so: $ circleci registry namespace create ....
- Loading branch information
Zachary Scott
committed
Aug 1, 2018
1 parent
c08f7ef
commit 19f60ac
Showing
6 changed files
with
273 additions
and
232 deletions.
There are no files selected for viewing
This file contains 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 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 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,55 @@ | ||
package cmd | ||
|
||
import ( | ||
"context" | ||
"strings" | ||
|
||
"github.com/CircleCI-Public/circleci-cli/api" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func newRegistryCommand() *cobra.Command { | ||
registryCmd := &cobra.Command{ | ||
Use: "registry", | ||
Short: "Operate on the registry", | ||
} | ||
|
||
namespaceCommand := &cobra.Command{ | ||
Use: "namespace", | ||
Short: "Operate on orb namespaces (create, etc.)", | ||
} | ||
|
||
createNamespaceCommand := &cobra.Command{ | ||
Use: "create [name] [vcs] [org-name]", | ||
Short: "create an namespace", | ||
RunE: createNamespace, | ||
Args: cobra.ExactArgs(3), | ||
} | ||
|
||
// "org-name", "", "organization name (required)" | ||
// "vcs", "github", "organization vcs, e.g. 'github', 'bitbucket'" | ||
|
||
namespaceCommand.AddCommand(createNamespaceCommand) | ||
|
||
registryCmd.AddCommand(namespaceCommand) | ||
|
||
return registryCmd | ||
} | ||
|
||
func createNamespace(cmd *cobra.Command, args []string) error { | ||
var err error | ||
ctx := context.Background() | ||
|
||
response, err := api.CreateNamespace(ctx, Logger, args[0], args[2], strings.ToUpper(args[1])) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
if len(response.Errors) > 0 { | ||
return response.ToError() | ||
} | ||
|
||
Logger.Info("Namespace created") | ||
return nil | ||
} |
Oops, something went wrong.