Skip to content
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: resolve the access key to the secret value #3207

Merged
merged 1 commit into from
Sep 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions internal/connector/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ type ListenerOptions struct {
}

func Run(ctx context.Context, options Options) error {
basicSecretStorage := map[string]secrets.SecretStorage{
"env": secrets.NewEnvSecretProviderFromConfig(secrets.GenericConfig{}),
"file": secrets.NewFileSecretProviderFromConfig(secrets.FileConfig{}),
"plaintext": secrets.NewPlainSecretProviderFromConfig(secrets.GenericConfig{}),
}

accessKey, err := secrets.GetSecret(options.Server.AccessKey, basicSecretStorage)
if err != nil {
return err
}
options.Server.AccessKey = accessKey

k8s, err := kubernetes.NewKubernetes()
if err != nil {
return err
Expand Down Expand Up @@ -92,12 +104,6 @@ func Run(ctx context.Context, options Options) error {
return certCache.Certificate()
}

basicSecretStorage := map[string]secrets.SecretStorage{
"env": secrets.NewEnvSecretProviderFromConfig(secrets.GenericConfig{}),
"file": secrets.NewFileSecretProviderFromConfig(secrets.FileConfig{}),
"plaintext": secrets.NewPlainSecretProviderFromConfig(secrets.GenericConfig{}),
}

u, err := urlx.Parse(options.Server.URL)
if err != nil {
return fmt.Errorf("invalid server url: %w", err)
Expand Down Expand Up @@ -128,11 +134,6 @@ func Run(ctx context.Context, options Options) error {
return errors.New("unexpected type for http.DefaultTransport")
}

accessKey, err := secrets.GetSecret(options.Server.AccessKey, basicSecretStorage)
if err != nil {
return err
}

ctx, cancel := context.WithCancel(ctx)
defer cancel()

Expand Down