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

Function NewUpdateCertificationTargetCommand

cli/commands/cloud/cloud.go:187–235  ·  view source on GitHub ↗

NewUpdateCertificationTargetCommand returns a cobra command for the `update` subcommand

()

Source from the content-addressed store, hash-verified

185
186// NewUpdateCertificationTargetCommand returns a cobra command for the `update` subcommand
187func NewUpdateCertificationTargetCommand() *cobra.Command {
188 cmd := &cobra.Command{
189 Use: "update",
190 Short: "Updates a target certification target",
191 RunE: func(cmd *cobra.Command, args []string) error {
192 var (
193 err error
194 session *cli.Session
195 client orchestrator.OrchestratorClient
196 res *orchestrator.CertificationTarget
197 )
198
199 if session, err = cli.ContinueSession(); err != nil {
200 fmt.Printf("Error while retrieving the session. Please re-authenticate.\n")
201 return nil
202 }
203
204 client = orchestrator.NewOrchestratorClient(session)
205
206 res, err = client.UpdateCertificationTarget(context.Background(), &orchestrator.UpdateCertificationTargetRequest{
207 CertificationTarget: &orchestrator.CertificationTarget{
208 Id: viper.GetString("id"),
209 Name: viper.GetString("name"),
210 Description: viper.GetString("description"),
211 },
212 })
213
214 return session.HandleResponse(res, err)
215 },
216 ValidArgsFunction: cli.DefaultArgsShellComp,
217 }
218
219 cmd.PersistentFlags().String("id", "", "the certification target id to update")
220 cmd.PersistentFlags().StringP("name", "n", "", "the name of the certification target")
221 cmd.PersistentFlags().StringP("description", "d", "", "an optional description")
222
223 _ = cmd.MarkPersistentFlagRequired("id")
224 _ = cmd.MarkPersistentFlagRequired("name")
225 _ = viper.BindPFlag("id", cmd.PersistentFlags().Lookup("id"))
226 _ = viper.BindPFlag("name", cmd.PersistentFlags().Lookup("name"))
227 _ = viper.BindPFlag("description", cmd.PersistentFlags().Lookup("description"))
228 _ = viper.BindPFlag("control-ids", cmd.PersistentFlags().Lookup("control-ids"))
229
230 _ = cmd.RegisterFlagCompletionFunc("id", cli.ValidArgsGetCertificationTargets)
231 _ = cmd.RegisterFlagCompletionFunc("name", cli.DefaultArgsShellComp)
232 _ = cmd.RegisterFlagCompletionFunc("description", cli.DefaultArgsShellComp)
233
234 return cmd
235}
236
237// NewGetMetricConfigurationCommand returns a cobra command for the `get-metric-configuration` subcommand
238// TODO(oxisto): Can we have something like cl cloud get <id> metric-configuration <id>?

Callers 2

AddCommandsFunction · 0.85

Calls 5

ContinueSessionFunction · 0.92
NewOrchestratorClientFunction · 0.92
HandleResponseMethod · 0.80
StringMethod · 0.45

Tested by 1