MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / newCASBackendUpdateAWSS3Cmd

Function newCASBackendUpdateAWSS3Cmd

app/cli/cmd/casbackend_update_s3.go:25–85  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23)
24
25func newCASBackendUpdateAWSS3Cmd() *cobra.Command {
26 var backendName, accessKeyID, secretAccessKey, region string
27 cmd := &cobra.Command{
28 Use: "aws-s3",
29 Short: "Update a AWS S3 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 "accessKeyID": accessKeyID,
52 "secretAccessKey": secretAccessKey,
53 "region": region,
54 },
55 Default: isDefaultCASBackendUpdateOption,
56 Fallback: isFallbackCASBackendUpdateOption,
57 MaxBytes: parsedMaxBytes,
58 }
59
60 // this means that we are not updating credentials
61 if accessKeyID == "" && secretAccessKey == "" && region == "" {
62 opts.Credentials = nil
63 }
64
65 res, err := action.NewCASBackendUpdate(ActionOpts).Run(opts)
66 if err != nil {
67 return err
68 } else if res == nil {
69 return nil
70 }
71
72 return output.EncodeOutput(flagOutputFormat, res, casBackendItemTableOutput)
73 },
74 }
75
76 cmd.Flags().StringVar(&backendName, "name", "", "CAS Backend name")
77 err := cmd.MarkFlagRequired("name")
78 cobra.CheckErr(err)
79
80 cmd.Flags().StringVar(&accessKeyID, "access-key-id", "", "AWS Access Key ID")
81 cmd.Flags().StringVar(&secretAccessKey, "secret-access-key", "", "AWS Secret Access Key")
82 cmd.Flags().StringVar(&region, "region", "", "AWS region for the bucket")

Callers 1

newCASBackendUpdateCmdFunction · 0.85

Calls 7

NewCASBackendUpdateFunction · 0.92
EncodeOutputFunction · 0.92
parseMaxBytesOptionFunction · 0.85
captureUpdateFlagsFunction · 0.85
InfoMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected