Skip to content

Commit

Permalink
fix creds, remove unused file (#7)
Browse files Browse the repository at this point in the history
* fix creds, remove unused file

* use defined constant keys
  • Loading branch information
rsafonseca authored Jul 5, 2024
1 parent 5f1bbe8 commit cfc0667
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 215 deletions.
196 changes: 0 additions & 196 deletions cluster/local/integration_tests.sh

This file was deleted.

25 changes: 6 additions & 19 deletions internal/clients/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package clients

import (
"context"
"encoding/json"
"strings"

"github.com/crossplane/crossplane-runtime/pkg/resource"
"github.com/crossplane/upjet/pkg/terraform"
Expand Down Expand Up @@ -115,29 +115,16 @@ func TerraformSetupBuilder(version, providerSource, providerVersion string) terr
ps.Configuration[keyHeaders] = pc.Spec.Headers
}

data, err := resource.CommonCredentialExtractor(ctx, pc.Spec.Credentials.Source, client, pc.Spec.Credentials.CommonCredentialSelectors)
token, err := resource.CommonCredentialExtractor(ctx, pc.Spec.Credentials.Source, client, pc.Spec.Credentials.CommonCredentialSelectors)
if err != nil {
return ps, errors.Wrap(err, errExtractCredentials)
}

creds := map[string]any{}
if err := json.Unmarshal(data, &creds); err != nil {
return ps, errors.Wrap(err, errUnmarshalCredentials)
}
ps.Configuration = map[string]any{}
ps.Configuration[keyAddress] = pc.Spec.Address
ps.Configuration[keySkipTLSVerify] = pc.Spec.SkipTLSVerify
ps.Configuration[keyToken] = strings.TrimSuffix(string(token), "\n")

// Set credentials in Terraform
// provider configuration
credsKeys := [...]string{keyToken, keyTokenName, keyCaCertFile,
keyCaCertDir, keyAuthLoginUserpass, keyAuthLoginAWS,
keyAuthLoginCert, keyAuthLoginGCP, keyAuthLoginKerberos,
keyAuthLoginRadius, keyAuthLoginOCI, keyAuthLoginOIDC,
keyAuthLoginJWT, keyAuthLoginAzure, keyAuthLogin, keyClientAuth}

for _, key := range credsKeys {
if v, ok := creds[key]; ok {
ps.Configuration[key] = v
}
}
return ps, nil
}
}

0 comments on commit cfc0667

Please sign in to comment.