NewRegisterCertificationTargetCommand returns a cobra command for the `discover` subcommand
()
| 40 | |
| 41 | // NewRegisterCertificationTargetCommand returns a cobra command for the `discover` subcommand |
| 42 | func NewRegisterCertificationTargetCommand() *cobra.Command { |
| 43 | cmd := &cobra.Command{ |
| 44 | Use: "register [name]", |
| 45 | Short: "Registers a new target certification target", |
| 46 | Args: cobra.ExactArgs(1), |
| 47 | RunE: func(cmd *cobra.Command, args []string) error { |
| 48 | var ( |
| 49 | err error |
| 50 | session *cli.Session |
| 51 | client orchestrator.OrchestratorClient |
| 52 | res *orchestrator.CertificationTarget |
| 53 | ) |
| 54 | |
| 55 | if session, err = cli.ContinueSession(); err != nil { |
| 56 | fmt.Printf("Error while retrieving the session. Please re-authenticate.\n") |
| 57 | return nil |
| 58 | } |
| 59 | |
| 60 | client = orchestrator.NewOrchestratorClient(session) |
| 61 | |
| 62 | name := args[0] |
| 63 | |
| 64 | res, err = client.RegisterCertificationTarget(context.Background(), &orchestrator.RegisterCertificationTargetRequest{ |
| 65 | CertificationTarget: &orchestrator.CertificationTarget{ |
| 66 | Name: name, |
| 67 | }, |
| 68 | }) |
| 69 | |
| 70 | return session.HandleResponse(res, err) |
| 71 | }, |
| 72 | ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { |
| 73 | return []string{"aws", "azure"}, cobra.ShellCompDirectiveNoFileComp |
| 74 | }, |
| 75 | } |
| 76 | |
| 77 | return cmd |
| 78 | } |
| 79 | |
| 80 | // NewListCertificationTargetsCommand returns a cobra command for the `list` subcommand |
| 81 | func NewListCertificationTargetsCommand() *cobra.Command { |