forked from gruntwork-io/terratest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
provider.go
55 lines (44 loc) · 1.68 KB
/
provider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package oci
import (
"os"
"testing"
"github.com/oracle/oci-go-sdk/common"
)
// You can set this environment variable to force Terratest to use a specific compartment.
const compartmentIDEnvVar = "TF_VAR_compartment_ocid"
// You can set this environment variable to force Terratest to use a specific availability domain
// rather than a random one. This is convenient when iterating locally.
const availabilityDomainEnvVar = "TF_VAR_availability_domain"
// You can set this environment variable to force Terratest to use a specific subnet.
const subnetIDEnvVar = "TF_VAR_subnet_ocid"
// You can set this environment variable to force Terratest to use a pass phrase.
const passPhraseEnvVar = "TF_VAR_pass_phrase"
// GetRootComparmentID gets an OCID of the root compartment (a.k.a. tenancy OCID).
func GetRootCompartmentID(t *testing.T) string {
tenancyID, err := GetRootCompartmentIDE(t)
if err != nil {
t.Fatal(err)
}
return tenancyID
}
// GetRootComparmentIDE gets an OCID of the root compartment (a.k.a. tenancy OCID).
func GetRootCompartmentIDE(t *testing.T) (string, error) {
configProvider := common.DefaultConfigProvider()
tenancyID, err := configProvider.TenancyOCID()
if err != nil {
return "", err
}
return tenancyID, nil
}
// GetCompartmentIDFromEnvVar returns the compartment OCID for use with testing.
func GetCompartmentIDFromEnvVar() string {
return os.Getenv(compartmentIDEnvVar)
}
// GetSubnetIDFromEnvVar returns the subnet OCID for use with testing.
func GetSubnetIDFromEnvVar() string {
return os.Getenv(subnetIDEnvVar)
}
// GetPassPhraseFromEnvVar returns the pass phrase for use with testing.
func GetPassPhraseFromEnvVar() string {
return os.Getenv(passPhraseEnvVar)
}