Skip to content

Commit

Permalink
Add note on why we trim upbound token
Browse files Browse the repository at this point in the history
Signed-off-by: Hasan Turken <[email protected]>
  • Loading branch information
turkenh committed May 28, 2024
1 parent df40dcf commit c9bfe04
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/kube/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,15 @@ func (b *IdentityAwareBuilder) restForProviderConfig(ctx context.Context, pc kco
return nil, errors.Errorf("%s is not supported as identity source for identity type %s",
xpv1.CredentialsSourceInjectedIdentity, kconfig.IdentityTypeUpboundTokens)
default:
tkn, err := resource.CommonCredentialExtractor(ctx, id.Source, b.local, id.CommonCredentialSelectors)
staticToken, err := resource.CommonCredentialExtractor(ctx, id.Source, b.local, id.CommonCredentialSelectors)
if err != nil {
return nil, errors.Wrap(err, errExtractUpboundCredentials)
}

if err := upbound.WrapRESTConfig(ctx, rc, strings.TrimSpace(string(tkn)), b.store); err != nil {
// We trim the token to remove any leading/trailing whitespace
// which may have been added especially when stringData field
// is used while creating the secret.
if err := upbound.WrapRESTConfig(ctx, rc, strings.TrimSpace(string(staticToken)), b.store); err != nil {
return nil, errors.Wrap(err, errInjectUpboundCredentials)
}
}
Expand Down

0 comments on commit c9bfe04

Please sign in to comment.