reorder delegates check
This commit is contained in:
parent
cc168ec2d6
commit
f47db678df
|
@ -153,19 +153,9 @@ func (b *Backend) configure(ctx context.Context) error {
|
||||||
// Service Account Impersonation
|
// Service Account Impersonation
|
||||||
if v, ok := data.GetOk("impersonate_service_account"); ok {
|
if v, ok := data.GetOk("impersonate_service_account"); ok {
|
||||||
ServiceAccount := v.(string)
|
ServiceAccount := v.(string)
|
||||||
ts, err := impersonate.CredentialsTokenSource(ctx, impersonate.CredentialsConfig{
|
var delegates []string
|
||||||
TargetPrincipal: ServiceAccount,
|
|
||||||
Scopes: []string{storage.ScopeReadWrite},
|
|
||||||
}, credOptions...)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
opts = append(opts, option.WithTokenSource(ts))
|
|
||||||
|
|
||||||
if v, ok := data.GetOk("impersonate_service_account_delegates"); ok {
|
if v, ok := data.GetOk("impersonate_service_account_delegates"); ok {
|
||||||
var delegates []string
|
|
||||||
d := v.([]interface{})
|
d := v.([]interface{})
|
||||||
if len(delegates) > 0 {
|
if len(delegates) > 0 {
|
||||||
delegates = make([]string, len(d))
|
delegates = make([]string, len(d))
|
||||||
|
@ -173,17 +163,20 @@ func (b *Backend) configure(ctx context.Context) error {
|
||||||
for _, delegate := range d {
|
for _, delegate := range d {
|
||||||
delegates = append(delegates, delegate.(string))
|
delegates = append(delegates, delegate.(string))
|
||||||
}
|
}
|
||||||
ts, err := impersonate.CredentialsTokenSource(ctx, impersonate.CredentialsConfig{
|
|
||||||
TargetPrincipal: ServiceAccount,
|
|
||||||
Scopes: []string{storage.ScopeReadWrite},
|
|
||||||
Delegates: delegates,
|
|
||||||
}, credOptions...)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
opts = append(opts, option.WithTokenSource(ts))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ts, err := impersonate.CredentialsTokenSource(ctx, impersonate.CredentialsConfig{
|
||||||
|
TargetPrincipal: ServiceAccount,
|
||||||
|
Scopes: []string{storage.ScopeReadWrite},
|
||||||
|
Delegates: delegates,
|
||||||
|
}, credOptions...)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
opts = append(opts, option.WithTokenSource(ts))
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
opts = append(opts, credOptions...)
|
opts = append(opts, credOptions...)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue