@@ -61,16 +61,6 @@ type AssumeRole struct {
6161 TransitiveTagKeys []string
6262}
6363
64- type AssumeRoleWithWebIdentity struct {
65- RoleARN string
66- Duration time.Duration
67- Policy string
68- PolicyARNs []string
69- SessionName string
70- WebIdentityToken string
71- WebIdentityTokenFile string
72- }
73-
7464func (c Config ) CustomCABundleReader () (* bytes.Reader , error ) {
7565 if c .CustomCABundle == "" {
7666 return nil , nil
@@ -137,19 +127,34 @@ func (c Config) ResolveSharedCredentialsFiles() ([]string, error) {
137127 return v , nil
138128}
139129
140- func (c AssumeRoleWithWebIdentity ) ResolveWebIdentityTokenFile () (string , error ) {
130+ type AssumeRoleWithWebIdentity struct {
131+ RoleARN string
132+ Duration time.Duration
133+ Policy string
134+ PolicyARNs []string
135+ SessionName string
136+ WebIdentityToken string
137+ WebIdentityTokenFile string
138+ }
139+
140+ func (c AssumeRoleWithWebIdentity ) resolveWebIdentityTokenFile () (string , error ) {
141141 v , err := expand .FilePath (c .WebIdentityTokenFile )
142142 if err != nil {
143143 return "" , fmt .Errorf ("expanding web identity token file: %w" , err )
144144 }
145145 return v , nil
146146}
147147
148+ func (c AssumeRoleWithWebIdentity ) HasValidTokenSource () bool {
149+ return c .WebIdentityToken != "" || c .WebIdentityTokenFile != ""
150+ }
151+
152+ // Implements `stscreds.IdentityTokenRetriever`
148153func (c AssumeRoleWithWebIdentity ) GetIdentityToken () ([]byte , error ) {
149154 if c .WebIdentityToken != "" {
150155 return []byte (c .WebIdentityToken ), nil
151156 }
152- webIdentityTokenFile , err := c .ResolveWebIdentityTokenFile ()
157+ webIdentityTokenFile , err := c .resolveWebIdentityTokenFile ()
153158 if err != nil {
154159 return nil , err
155160 }
0 commit comments