|
8 | 8 | "io/ioutil" |
9 | 9 | "math" |
10 | 10 | "os" |
11 | | - "path/filepath" |
12 | 11 | "regexp" |
13 | 12 | "strconv" |
14 | 13 | "strings" |
@@ -778,18 +777,6 @@ func checkIncompatibleAttrsForApiKeyAuth(d *schema.ResourceData) ([]string, bool |
778 | 777 | return apiKeyConfigAttributesToUnset, len(apiKeyConfigAttributesToUnset) == 0 |
779 | 778 | } |
780 | 779 |
|
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 | | - |
793 | 780 | func ProviderConfig(d *schema.ResourceData) (interface{}, error) { |
794 | 781 | clients := &OracleClients{configuration: map[string]string{}} |
795 | 782 |
|
@@ -892,34 +879,17 @@ func getConfigProviders(d *schema.ResourceData, auth string) ([]oci_common.Confi |
892 | 879 | return nil, fmt.Errorf("can not get %s from Terraform configuration (InstancePrincipalWithCerts)", regionAttrName) |
893 | 880 | } |
894 | 881 |
|
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) |
899 | 884 |
|
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) |
905 | 887 |
|
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) |
910 | 890 |
|
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) |
923 | 893 |
|
924 | 894 | intermediateCertificatesBytes := [][]byte{ |
925 | 895 | intermediateCertificateBytes, |
|
0 commit comments