MCPcopy Index your code
hub / github.com/jetify-com/devbox / cacheCredentialsCmd

Function cacheCredentialsCmd

internal/boxcli/cache.go:116–146  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

114}
115
116func cacheCredentialsCmd() *cobra.Command {
117 flags := credentialsFlags{}
118 cmd := &cobra.Command{
119 Use: "credentials",
120 Short: "Output S3 cache credentials",
121 Hidden: true,
122 Args: cobra.ExactArgs(0),
123 RunE: func(cmd *cobra.Command, args []string) error {
124 creds, err := nixcache.CachedCredentials(cmd.Context())
125 if err != nil {
126 return err
127 }
128
129 if flags.format == "sh" {
130 fmt.Printf("export AWS_ACCESS_KEY_ID=%q\n", creds.AccessKeyID)
131 fmt.Printf("export AWS_SECRET_ACCESS_KEY=%q\n", creds.SecretAccessKey)
132 fmt.Printf("export AWS_SESSION_TOKEN=%q\n", creds.SessionToken)
133 return nil
134 }
135
136 out, err := json.Marshal(creds)
137 if err != nil {
138 return err
139 }
140 _, err = cmd.OutOrStdout().Write(out)
141 return err
142 },
143 }
144 cmd.Flags().StringVar(&flags.format, "format", "json", "Output format, either json or sh")
145 return cmd
146}
147
148func cacheEnableCmd() *cobra.Command {
149 cmd := &cobra.Command{

Callers 1

cacheCmdFunction · 0.85

Calls 2

CachedCredentialsFunction · 0.92
WriteMethod · 0.80

Tested by

no test coverage detected