-
Notifications
You must be signed in to change notification settings - Fork 2
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
fix: override secrets from path #204
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Bence Csati <bcsati@cisco.com>
Signed-off-by: Bence Csati <bcsati@cisco.com>
Signed-off-by: Bence Csati <bcsati@cisco.com>
var ProviderTypes = []provider.Provider{ | ||
&file.Provider{}, | ||
&vault.Provider{}, | ||
&bao.Provider{}, | ||
&aws.Provider{}, | ||
&gcp.Provider{}, | ||
&azure.Provider{}, | ||
} |
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.
we can register provider factories here and create them elsewhere
var ProviderTypes = []provider.Provider{ | |
&file.Provider{}, | |
&vault.Provider{}, | |
&bao.Provider{}, | |
&aws.Provider{}, | |
&gcp.Provider{}, | |
&azure.Provider{}, | |
} | |
var factories = []provider.ProviderFactory{ | |
file.NewProvider, | |
vault.NewProvider, | |
// and the rest | |
} |
since all provider operations are handled through env store, we can create providers there on demand in store constructor, for example
type EnvStore struct {
data map[string]string
providers []provider.Provider
}
func NewEnvStore(ctx context.Context, config *common.Config) *EnvStore {
// load env data
environ := make(map[string]string, len(os.Environ()))
for _, env := range os.Environ() {
split := strings.SplitN(env, "=", 2)
name := split[0]
value := split[1]
environ[name] = value
}
// create providers
var providers []provider.Provider
for _, factory := range factories {
p, err := factory(ctx, config)
if err != nil {
return nil, fmt.Errorf("failed to create provider from factory: %w", err)
}
providers = append(providers, p)
}
return &EnvStore{
data: environ,
providers: providers,
}
}
You can now simply use provider slice to streamline all operations (including parallelization ops)
// Remove the vault paths since they have been processed | ||
delete(providerPaths, vault.ProviderName) | ||
providerSecrets = append(providerSecrets, vaultSecrets...) | ||
delete(providerPaths, "vault") |
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.
if you need to use the specific provider type, id suggest to keep using the exposed consts (in this case, vault.ProviderName
, or vault.ProviderType
for usage clarity
Overview
Fixes #202
Notes for reviewers
Functionality is manually tested with the following script: