Skip to content

Commit

Permalink
Move import-orb command into admin.go
Browse files Browse the repository at this point in the history
  • Loading branch information
aengelberg committed Oct 23, 2020
1 parent 7341e15 commit 961a66a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 12 deletions.
43 changes: 43 additions & 0 deletions cmd/admin.go
@@ -0,0 +1,43 @@
package cmd

import (
"github.com/CircleCI-Public/circleci-cli/api/graphql"
"github.com/CircleCI-Public/circleci-cli/settings"
"github.com/spf13/cobra"
)

func newAdminCommand(config *settings.Config) *cobra.Command {
opts := orbOptions{
cfg: config,
tty: createOrbInteractiveUI{},
}

importOrbCommand := &cobra.Command{
Use: "import-orb <namespace>[/<orb>[@<version>]]",
Short: "Import an orb version from circleci.com into a CircleCI Server installation",
RunE: func(_ *cobra.Command, _ []string) error {
return importOrb(opts)
},
Args: cobra.MinimumNArgs(1),
Hidden: true,
}
importOrbCommand.Flags().BoolVar(&opts.integrationTesting, "integration-testing", false, "Enable test mode to bypass interactive UI.")

adminCommand := &cobra.Command{
Use: "admin",
Short: "Administrative operations for a CircleCI Server installation.",
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
opts.args = args
opts.cl = graphql.NewClient(config.Host, config.Endpoint, config.Token, config.Debug)

// PersistentPreRunE overwrites the inherited persistent hook from rootCmd
// So we explicitly call it here to retain that behavior.
// As of writing this comment, that is only for daily update checks.
return rootCmdPreRun(rootOptions)
},
}

adminCommand.AddCommand(importOrbCommand)

return adminCommand
}
12 changes: 0 additions & 12 deletions cmd/orb.go
Expand Up @@ -263,17 +263,6 @@ Please note that at this time all orbs created in the registry are world-readabl
Args: cobra.ExactArgs(1),
}

importOrbCommand := &cobra.Command{
Use: "import <namespace>[/<orb>[@<version>]]",
Short: "(Server only) Import an orb version from circleci.com into a CircleCI Server installation",
RunE: func(_ *cobra.Command, _ []string) error {
return importOrb(opts)
},
Args: cobra.MinimumNArgs(1),
Hidden: true,
}
importOrbCommand.Flags().BoolVar(&opts.integrationTesting, "integration-testing", false, "Enable test mode to bypass interactive UI.")

orbPack := &cobra.Command{
Use: "pack <path>",
Short: "Pack an Orb with local scripts.",
Expand Down Expand Up @@ -349,7 +338,6 @@ Please note that at this time all orbs created in the registry are world-readabl

orbCommand.AddCommand(listCommand)
orbCommand.AddCommand(orbCreate)
orbCommand.AddCommand(importOrbCommand)
orbCommand.AddCommand(validateCommand)
orbCommand.AddCommand(processCommand)
orbCommand.AddCommand(publishCommand)
Expand Down

0 comments on commit 961a66a

Please sign in to comment.