MCPcopy Create free account
hub / github.com/clouditor/clouditor / NewListCertificationTargetsCommand

Function NewListCertificationTargetsCommand

cli/commands/cloud/cloud.go:81–118  ·  view source on GitHub ↗

NewListCertificationTargetsCommand returns a cobra command for the `list` subcommand

()

Source from the content-addressed store, hash-verified

79
80// NewListCertificationTargetsCommand returns a cobra command for the `list` subcommand
81func NewListCertificationTargetsCommand() *cobra.Command {
82 cmd := &cobra.Command{
83 Use: "list",
84 Short: "Lists all target certification targets",
85 RunE: func(cmd *cobra.Command, args []string) error {
86 var (
87 err error
88 session *cli.Session
89 client orchestrator.OrchestratorClient
90 res *orchestrator.ListCertificationTargetsResponse
91 target []*orchestrator.CertificationTarget
92 )
93
94 if session, err = cli.ContinueSession(); err != nil {
95 fmt.Printf("Error while retrieving the session. Please re-authenticate.\n")
96 return nil
97 }
98
99 client = orchestrator.NewOrchestratorClient(session)
100
101 target, err = api.ListAllPaginated(&orchestrator.ListCertificationTargetsRequest{}, client.ListCertificationTargets, func(res *orchestrator.ListCertificationTargetsResponse) []*orchestrator.CertificationTarget {
102 return res.Targets
103 })
104
105 // Build a response with all certification targets
106 res = &orchestrator.ListCertificationTargetsResponse{
107 Targets: target,
108 }
109
110 return session.HandleResponse(res, err)
111 },
112 ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
113 return []string{}, cobra.ShellCompDirectiveNoFileComp
114 },
115 }
116
117 return cmd
118}
119
120// NewGetCertificationTargetCommand returns a cobra command for the `get` subcommand
121func NewGetCertificationTargetCommand() *cobra.Command {

Callers 2

AddCommandsFunction · 0.85

Calls 4

ContinueSessionFunction · 0.92
NewOrchestratorClientFunction · 0.92
ListAllPaginatedFunction · 0.92
HandleResponseMethod · 0.80

Tested by 1