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