-
Notifications
You must be signed in to change notification settings - Fork 38
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
[envsec] Add List function to envsec library #252
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome!
} | ||
|
||
return envsec.PrintEnvVars( | ||
vars, cmd.OutOrStdout(), flags.ShowValues, flags.Format) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unrelated to this PR:
I just noticed that the help message for --format
isn't completely helpful. It could specify what the valid options are Display the key values in key=value format. Must be one of: table | dotenv | json".
envsec/pkg/envsec/list.go
Outdated
project, err := e.ProjectConfig() | ||
if project == nil { | ||
return nil, err | ||
} | ||
|
||
authClient, err := e.authClient() | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
tok, err := authClient.LoginFlowIfNeededForOrg(ctx, project.OrgID.String()) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
store.Identify(ctx, e, tok) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems repeated from the envsec.SetStore
code above. Is it needed?
// A string that uniquely identifies the organization to which the environment belongs. | ||
OrgID string | ||
// A name that uniquely identifies the environment within the project. | ||
// Usually one of: 'dev', 'prod'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or preview
@@ -30,14 +32,18 @@ func newSSMStore(ctx context.Context, config *SSMConfig) (*SSMStore, error) { | |||
return store, nil | |||
} | |||
|
|||
func (s *SSMStore) List(ctx context.Context, envID EnvID) ([]EnvVar, error) { | |||
func (s *SSMStore) Identify(context.Context, *envsec.Envsec, *session.Token) { | |||
// TODO: implement |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add a panic("TODO: implement SSMStore.Identify")
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really want it to panic since it does identity in a different way (via standard AWS credential chain). If we make it panic here it will break.
Summary
This adds a
List
andPrintEnvVars
functions to the envsec library. It allows a 3rd party (e.g. devbox) app to use envsec functionality more easily.I refactored stores as much as I could to make this easy to use, but it's still a bit tangled. Specifically, the envsec package uses the jetpack API internally a bunch. In theory, we could make most of these functions part of the
store
. That way other stores can implement their owninit
orwhoami
specifics depending on their capabilities. This is left for later.Once this is merged, devbox will be able to:
envsec.List
in order to fetch secrets (instead of the current implementation which calls the envsec CLI).devbox secrets list
command that fetches and prints secrets.How was it tested?