@@ -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