()
| 23 | ) |
| 24 | |
| 25 | func newCASBackendUpdateOCICmd() *cobra.Command { |
| 26 | var backendName, username, password string |
| 27 | cmd := &cobra.Command{ |
| 28 | Use: "oci", |
| 29 | Short: "Update a OCI CAS Backend description, credentials, default status, or max bytes", |
| 30 | PreRunE: func(_ *cobra.Command, _ []string) error { |
| 31 | return parseMaxBytesOption() |
| 32 | }, |
| 33 | RunE: func(cmd *cobra.Command, args []string) error { |
| 34 | // capture flags only when explicitly set |
| 35 | if err := captureUpdateFlags(cmd); err != nil { |
| 36 | return err |
| 37 | } |
| 38 | |
| 39 | // If we are overriding/unsetting the default we ask for confirmation |
| 40 | if ok, err := handleDefaultUpdateConfirmation(ActionOpts, backendName); err != nil { |
| 41 | return err |
| 42 | } else if !ok { |
| 43 | log.Info("Aborting...") |
| 44 | return nil |
| 45 | } |
| 46 | |
| 47 | opts := &action.NewCASBackendUpdateOpts{ |
| 48 | Name: backendName, |
| 49 | Description: descriptionCASBackendUpdateOption, |
| 50 | Credentials: map[string]any{ |
| 51 | "username": username, |
| 52 | "password": password, |
| 53 | }, |
| 54 | Default: isDefaultCASBackendUpdateOption, |
| 55 | Fallback: isFallbackCASBackendUpdateOption, |
| 56 | MaxBytes: parsedMaxBytes, |
| 57 | } |
| 58 | |
| 59 | if username == "" && password == "" { |
| 60 | opts.Credentials = nil |
| 61 | } |
| 62 | |
| 63 | res, err := action.NewCASBackendUpdate(ActionOpts).Run(opts) |
| 64 | if err != nil { |
| 65 | return err |
| 66 | } else if res == nil { |
| 67 | return nil |
| 68 | } |
| 69 | |
| 70 | return output.EncodeOutput(flagOutputFormat, res, casBackendItemTableOutput) |
| 71 | }, |
| 72 | } |
| 73 | |
| 74 | cmd.Flags().StringVar(&backendName, "name", "", "CAS Backend name") |
| 75 | err := cmd.MarkFlagRequired("name") |
| 76 | cobra.CheckErr(err) |
| 77 | |
| 78 | cmd.Flags().StringVarP(&username, "username", "u", "", "registry username") |
| 79 | |
| 80 | cmd.Flags().StringVarP(&password, "password", "p", "", "registry password") |
| 81 | |
| 82 | return cmd |
no test coverage detected