Skip to content

Commit 4ea88ae

Browse files
committed
chore: Expanding lll coverage to runner-creds
1 parent 94d5d2d commit 4ea88ae

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ linters:
114114
# trying to get this merged in.
115115
- linters:
116116
- lll
117-
path-except: '^(internal/awshelper/|internal/cas/|internal/cli/commands/(backend/(delete|migrate)|catalog/tui/command|exec|find|help|list|stack)/|internal/cloner/|internal/configbridge/|internal/engine/|internal/errorconfig/|internal/errors/|internal/experiment/|internal/gcphelper/|internal/git/|internal/os/exec/|internal/prepare/|internal/runner/(common|graph|run/creds/providers/(amazonsts|externalcmd))/|internal/stacks/(generate|output)/|internal/tf/cache/(controllers|middleware)/|internal/tips/|internal/vfs/|internal/worktrees/|pkg/log/(format/placeholders|writer)/)'
117+
path-except: '^(internal/awshelper/|internal/cas/|internal/cli/commands/(backend/(delete|migrate)|catalog/tui/command|exec|find|help|list|stack)/|internal/cloner/|internal/configbridge/|internal/engine/|internal/errorconfig/|internal/errors/|internal/experiment/|internal/gcphelper/|internal/git/|internal/os/exec/|internal/prepare/|internal/runner/(common|graph|run/creds)/|internal/stacks/(generate|output)/|internal/tf/cache/(controllers|middleware)/|internal/tips/|internal/vfs/|internal/worktrees/|pkg/log/(format/placeholders|writer)/)'
118118
paths:
119119
- docs
120120
- _ci

internal/runner/run/creds/getter.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ func NewGetter() *Getter {
2222
}
2323

2424
// ObtainAndUpdateEnvIfNecessary obtains credentials through different providers and sets them to the provided env map.
25-
func (getter *Getter) ObtainAndUpdateEnvIfNecessary(ctx context.Context, l log.Logger, env map[string]string, authProviders ...providers.Provider) error {
25+
func (getter *Getter) ObtainAndUpdateEnvIfNecessary(
26+
ctx context.Context,
27+
l log.Logger,
28+
env map[string]string,
29+
authProviders ...providers.Provider,
30+
) error {
2631
for _, provider := range authProviders {
2732
creds, err := provider.GetCredentials(ctx, l)
2833
if err != nil {
@@ -35,7 +40,8 @@ func (getter *Getter) ObtainAndUpdateEnvIfNecessary(ctx context.Context, l log.L
3540

3641
for providerName, prevCreds := range getter.obtainedCreds {
3742
if prevCreds.Name == creds.Name {
38-
l.Warnf("%s credentials obtained using %s are overwritten by credentials obtained using %s.", creds.Name, providerName, provider.Name())
43+
l.Warnf("%s credentials obtained using %s are overwritten by credentials obtained using %s.",
44+
creds.Name, providerName, provider.Name())
3945
}
4046
}
4147

@@ -51,9 +57,17 @@ func (getter *Getter) ObtainAndUpdateEnvIfNecessary(ctx context.Context, l log.L
5157
// credentials, and populates env before HCL parsing.
5258
// Use when sops_decrypt_file() or get_aws_account_id() may appear in locals.
5359
// See https://github.com/gruntwork-io/terragrunt/issues/5515
54-
func ObtainCredsForParsing(ctx context.Context, l log.Logger, authProviderCmd string, env map[string]string, shellOpts *shell.ShellOptions) (*Getter, error) {
60+
func ObtainCredsForParsing(
61+
ctx context.Context,
62+
l log.Logger,
63+
authProviderCmd string,
64+
env map[string]string,
65+
shellOpts *shell.ShellOptions,
66+
) (*Getter, error) {
5567
g := NewGetter()
56-
if err := g.ObtainAndUpdateEnvIfNecessary(ctx, l, env, externalcmd.NewProvider(l, authProviderCmd, shellOpts)); err != nil {
68+
69+
provider := externalcmd.NewProvider(l, authProviderCmd, shellOpts)
70+
if err := g.ObtainAndUpdateEnvIfNecessary(ctx, l, env, provider); err != nil {
5771
return nil, err
5872
}
5973

0 commit comments

Comments
 (0)