Documentation
¶
Overview ¶
Package ocep creates a common.ConfigurationProvider which reads the configuration specified by oci-cli environment variables.
Example ¶
The most common use is to create a provider that can use the OCI CLI Environment variables as well as the providers from the sdk.
provider := ocep.DefaultConfigProvider()
client, _ := identity.NewIdentityClientWithConfigurationProvider(provider)
tenancyID, _ := provider.TenancyOCID()
req := identity.GetCompartmentRequest{
CompartmentId: common.String(tenancyID),
RequestMetadata: metadata,
}
resp, _ := client.GetCompartment(context.TODO(), req)
fmt.Printf("CompartmentId: %s\n", *resp.Id)
Index ¶
Examples ¶
Constants ¶
const ( EnvAuth = "OCI_CLI_AUTH" EnvConfigFile = "OCI_CLI_CONFIG_FILE" EnvFingerprint = "OCI_CLI_FINGERPRINT" EnvKeyContent = "OCI_CLI_KEY_CONTENT" EnvKeyFile = "OCI_CLI_KEY_FILE" EnvPassphrase = "OCI_CLI_PASSPHRASE" EnvProfile = "OCI_CLI_PROFILE" EnvRegion = "OCI_CLI_REGION" EnvSecurityTokenFile = "OCI_CLI_SECURITY_TOKEN_FILE" EnvTenancy = "OCI_CLI_TENANCY" EnvUser = "OCI_CLI_USER" )
The standard oci-cli environment variables we use
const ( ApiKeyType common.AuthenticationType = "api_key" SecurityTokenType common.AuthenticationType = "security_token" )
Variables ¶
var (
ErrNoKeyId = errors.New("could not determine KeyID")
)
Functions ¶
func DefaultConfigProvider ¶
func DefaultConfigProvider() common.ConfigurationProvider
DefaultConfigProvider returns a common.ConfigurationProvider containing providers for oci cli environment variables, as well as those returned by common.DefaultConfigProvider
Be aware that if you want AuthType to be set, it must be set with the EnvAuth environment variable. common.ComposingConfigurationProvider only calls AuthType on the first provider.
func OciCliEnvironmentConfigurationProvider ¶
func OciCliEnvironmentConfigurationProvider() common.ConfigurationProvider
OciCliEnvironmentConfigurationProvider returns a common.ConfigurationProvider that gets values from oci-cli environment variables
Example ¶
This example requires the OCI CLI environment variables to be set. The output will be your Tenancy OCID.
provider := ocep.OciCliEnvironmentConfigurationProvider()
client, _ := identity.NewIdentityClientWithConfigurationProvider(provider)
tenancyID, _ := provider.TenancyOCID()
req := identity.GetCompartmentRequest{
CompartmentId: common.String(tenancyID),
RequestMetadata: metadata,
}
resp, _ := client.GetCompartment(context.TODO(), req)
fmt.Printf("CompartmentId: %s\n", *resp.Id)