Skip to content

Commit 3e27c4d

Browse files
committed
Using environment for Obo Token
1 parent 6fb324f commit 3e27c4d

File tree

1 file changed

+8
-38
lines changed

1 file changed

+8
-38
lines changed

oci/provider.go

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"io/ioutil"
99
"math"
1010
"os"
11-
"path/filepath"
1211
"regexp"
1312
"strconv"
1413
"strings"
@@ -778,18 +777,6 @@ func checkIncompatibleAttrsForApiKeyAuth(d *schema.ResourceData) ([]string, bool
778777
return apiKeyConfigAttributesToUnset, len(apiKeyConfigAttributesToUnset) == 0
779778
}
780779

781-
func getCertificateFileBytes(certificateFileFullPath string) (pemRaw []byte, err error) {
782-
absFile, err := filepath.Abs(certificateFileFullPath)
783-
if err != nil {
784-
return nil, fmt.Errorf("can't form absolute path of %s: %v", certificateFileFullPath, err)
785-
}
786-
787-
if pemRaw, err = ioutil.ReadFile(absFile); err != nil {
788-
return nil, fmt.Errorf("can't read %s: %v", certificateFileFullPath, err)
789-
}
790-
return
791-
}
792-
793780
func ProviderConfig(d *schema.ResourceData) (interface{}, error) {
794781
clients := &OracleClients{configuration: map[string]string{}}
795782

@@ -892,34 +879,17 @@ func getConfigProviders(d *schema.ResourceData, auth string) ([]oci_common.Confi
892879
return nil, fmt.Errorf("can not get %s from Terraform configuration (InstancePrincipalWithCerts)", regionAttrName)
893880
}
894881

895-
defaultCertsDir, err := os.Getwd()
896-
if err != nil {
897-
return nil, fmt.Errorf("can not get working directory for current os platform")
898-
}
882+
leafCertificate := getEnvSettingWithBlankDefault("ip_cert")
883+
leafCertificateBytes := []byte(leafCertificate)
899884

900-
certsDir := filepath.Clean(getEnvSettingWithDefault("test_certificates_location", defaultCertsDir))
901-
leafCertificateBytes, err := getCertificateFileBytes(filepath.Join(certsDir, "ip_cert.pem"))
902-
if err != nil {
903-
return nil, fmt.Errorf("can not read leaf certificate from %s", filepath.Join(certsDir, "ip_cert.pem"))
904-
}
885+
leafPrivateKey := getEnvSettingWithBlankDefault("ip_key")
886+
leafPrivateKeyBytes := []byte(leafPrivateKey)
905887

906-
leafPrivateKeyBytes, err := getCertificateFileBytes(filepath.Join(certsDir, "ip_key.pem"))
907-
if err != nil {
908-
return nil, fmt.Errorf("can not read leaf private key from %s", filepath.Join(certsDir, "ip_key.pem"))
909-
}
888+
leafPassphrase := getEnvSettingWithBlankDefault("INTEGRATION_PASS_PHRASE")
889+
leafPassphraseBytes := []byte(leafPassphrase)
910890

911-
leafPassphraseBytes := []byte{}
912-
if _, err := os.Stat(certsDir + "/leaf_passphrase"); !os.IsNotExist(err) {
913-
leafPassphraseBytes, err = getCertificateFileBytes(filepath.Join(certsDir + "leaf_passphrase"))
914-
if err != nil {
915-
return nil, fmt.Errorf("can not read leafPassphraseBytes from %s", filepath.Join(certsDir+"leaf_passphrase"))
916-
}
917-
}
918-
919-
intermediateCertificateBytes, err := getCertificateFileBytes(filepath.Join(certsDir, "intermediate.pem"))
920-
if err != nil {
921-
return nil, fmt.Errorf("can not read intermediate certificate from %s", filepath.Join(certsDir, "intermediate.pem"))
922-
}
891+
intermediateCertificate := getEnvSettingWithBlankDefault("intermediate")
892+
intermediateCertificateBytes := []byte(intermediateCertificate)
923893

924894
intermediateCertificatesBytes := [][]byte{
925895
intermediateCertificateBytes,

0 commit comments

Comments
 (0)