Skip to content

[secrets] Implement ls, set, rm secrets #1713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 11, 2024

Conversation

mikeland73
Copy link
Contributor

@mikeland73 mikeland73 commented Jan 10, 2024

Summary

Implements secrets list, secrets set, and secrets rm.

Removed dependency on envsec binary.

Renamed envsec commands to secrets

TODO: Improve envsec interface to avoid having to use embedded struct.

How was it tested?

devbox secrets list
devbox secrets set foo=bar
devbox secrets set foo=barprod --environment prod
devbox run echo $\foo
devbox ls --environment prod

@mikeland73 mikeland73 requested review from loreto and savil January 10, 2024 01:13
@mikeland73 mikeland73 changed the title [secrets] Implement ls, set secrets [secrets] Implement ls, set, rm secrets Jan 10, 2024
Copy link
Collaborator

@savil savil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

neat!

cmd.AddCommand(secretsSetCmd(flags))
cmd.Hidden = true

flags.config.registerPersistent(cmd)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmd := &cobra.Command{
Use: "secrets",
Aliases: []string{"envsec"},
Short: "Interact with devbox secrets.",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of ...devbox secrets should it be Interact with secrets in jetpack cloud ?

return &cobra.Command{
Use: "set <NAME1>=<value1> [<NAME2>=<value2>]...",
Short: "Securely store one or more environment variables",
Long: "Securely store one or more environment variables. To test contents of a file as a secret use set=@<file>",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you test the file-upload scenario?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works!

"show",
"s",
false,
"Display the value of each environment variable (secrets included)",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels odd to mention environment variable when the command is devbox secrets.

Can this be: Display the value of the secret [default = false]?

"format",
"f",
"table",
"Display the key values in key=value format. Must be one of: table | dotenv | json",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Display the key values of each secret in the specified format, one of: table | dotenv | json. [default = table]" ?

}
}
} else if d.cfg.EnvFrom != "" {
return nil, usererr.New("unknown from_env value: %s", d.cfg.EnvFrom)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usererr.New("unknown from_env value: %s. Supported value is: envsec.", d.cfg.EnvFrom, )

Comment on lines 1290 to 1292
func (d *Devbox) Environment() string {
return d.environment
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this need to be made visible externally? Seems like its used in internal/devbox/secrets.go which can use d.environment

@mikeland73 mikeland73 merged commit 0600c4c into main Jan 11, 2024
@mikeland73 mikeland73 deleted the landau/implement-secrets-ls-set branch January 11, 2024 00:32
Copy link

sentry-io bot commented Jan 18, 2024

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ **Generic Error: <redacted errors.withStack>: <redacted errors.errorString> go.jetpack.io/devbox/internal/boxcli in secrets... View Issue
  • ‼️ **Generic Error: <redacted errors.withStack>: <redacted errors.errorString> go.jetpack.io/devbox/internal/boxcli in secrets... View Issue
  • ‼️ **Generic Error: <redacted *errors.withStack>: <redacted errors.withStack>: <redacted usererr.combined> go.jetpack.io/devbox/internal/boxcli/usererr in... View Issue

Did you find this useful? React with a 👍 or 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants