Documentation ¶
Index ¶
- Constants
- Variables
- func AwsCredentialsFromEnv() (awsCreds.Value, error)
- func AzureStorageCredentialsFromEnv() (string, error)
- func CheckValidYBAVersion(ctx context.Context, c *client.APIClient, versions []string) (bool, string, error)
- func CompareYbVersions(v1 string, v2 string) (int, error)
- func ConvertMsToUnit(value int64, unit string) float64
- func ConvertUnitToMs(value float64, unit string) int64
- func CreateSingletonList(in interface{}) []interface{}
- func ErrorFromHTTPResponse(resp *http.Response, apiError error, entity, entityName, operation string) error
- func ErrorFromResponseBody(errorBlock YbaStructuredError) string
- func FileExist(filePath string) error
- func GcpGetCredentialsAsMap() (map[string]interface{}, error)
- func GcpGetCredentialsAsString() (string, error)
- func GetBoolPointer(in bool) *bool
- func GetFloat64Pointer(in float64) *float64
- func GetInt32Pointer(in int32) *int32
- func GetInt64Pointer(in int64) *int64
- func GetMsFromDurationString(duration string) (int64, string, bool, error)
- func GetStringPointer(in string) *string
- func GetUnitOfTimeFromDuration(duration time.Duration) string
- func GetUniversesForProvider(ctx context.Context, c *client.APIClient, cUUID, pUUID, universeName string) ([]client.UniverseResp, bool, error)
- func IsVersionAllowed(currentVersion, restrictedVersion string) (bool, error)
- func MapFromSingletonList(in []interface{}) map[string]interface{}
- func MapListFromInterfaceList(in []interface{}) []map[string]interface{}
- func ObfuscateString(s string, n int) string
- func ReadSSHPrivateKey(filePath string) (*string, error)
- func StringMap(in map[string]interface{}) *map[string]string
- func StringSlice(in []interface{}) *[]string
- func WaitForTask(ctx context.Context, tUUID string, cUUID string, c *client.APIClient, ...) error
- func YBARestrictBackupVersions() []string
- func YBARestrictFailedSubtasksVersions() []string
- type AzureCredentials
- type GCPCredentials
- type YbaStructuredError
Constants ¶
const ( // ResourceEntity identifies resources ResourceEntity = "Resource" // DataSourceEntity identifies data sources DataSourceEntity = "Data Source" // TestEntity identifies tests TestEntity = "Test" )
Entities
const ( // GCPCredentialsEnv env variable name for gcp provider/storage config/releases GCPCredentialsEnv = "GOOGLE_APPLICATION_CREDENTIALS" // GCSCredentialsJSON field name to denote in Json request GCSCredentialsJSON = "GCS_CREDENTIALS_JSON" // AWSAccessKeyEnv env variable name for aws provider/storage config/releases AWSAccessKeyEnv = "AWS_ACCESS_KEY_ID" // AWSSecretAccessKeyEnv env variable name for aws provider/storage config/releases AWSSecretAccessKeyEnv = "AWS_SECRET_ACCESS_KEY" // AzureSubscriptionIDEnv env variable name for azure provider AzureSubscriptionIDEnv = "AZURE_SUBSCRIPTION_ID" // AzureRGEnv env variable name for azure provider AzureRGEnv = "AZURE_RG" // AzureTenantIDEnv env variable name for azure provider AzureTenantIDEnv = "AZURE_TENANT_ID" // AzureClientIDEnv env variable name for azure provider AzureClientIDEnv = "AZURE_CLIENT_ID" // AzureClientSecretEnv env variable name for azure provider AzureClientSecretEnv = "AZURE_CLIENT_SECRET" // AzureNetworkSubscriptionIDEnv env variable name for azure provider AzureNetworkSubscriptionIDEnv = "AZURE_NETWORK_SUBSCRIPTION_ID" // AzureNetworkRGEnv env variable name for azure provider AzureNetworkRGEnv = "AZURE_NETWORK_RG" // AzureStorageSasTokenEnv env variable name azure storage config AzureStorageSasTokenEnv = "AZURE_STORAGE_SAS_TOKEN" )
Environment variable fields
const ( // YBAAllowUniverseMinVersion specifies minimum version // required to use Universe resource via YBA Terraform YBAAllowUniverseMinVersion = "2.17.1.0-b371" // YBAAllowBackupMinVersion specifies minimum version // required to use Scheduled Backup resource via YBA Terraform YBAAllowBackupMinVersion = "2.18.1.0-b20" // YBAAllowEditProviderMinVersion specifies minimum version // required to Edit a Provider (onprem or cloud) resource // via YBA Terraform YBAAllowEditProviderMinVersion = "2.18.0.0-b65" // YBAAllowFailureSubTaskListMinVersion specifies minimum version // required to fetch failed subtask message from YugabyteDB Anywhere YBAAllowFailureSubTaskListMinVersion = "2.18.1.0-b68" )
Minimum YugabyteDB Anywhere versions to support operation
Variables ¶
var ( // PendingTaskStates lists incomplete task states PendingTaskStates = []string{"Created", "Initializing", "Running"} // SuccessTaskStates lists successful task states SuccessTaskStates = []string{"Success"} )
Functions ¶
func AwsCredentialsFromEnv ¶
AwsCredentialsFromEnv retrives values of "AWS_ACCESS_KEY_ID" and "AWS_SECRET_ACCESS_KEY" from env variables
func AzureStorageCredentialsFromEnv ¶
AzureStorageCredentialsFromEnv retrives value of "AZURE_STORAGE_SAS_TOKEN" from env variables
func CheckValidYBAVersion ¶
func CheckValidYBAVersion(ctx context.Context, c *client.APIClient, versions []string) (bool, string, error)
CheckValidYBAVersion allows operation if version is higher than listed versions
func CompareYbVersions ¶
CompareYbVersions returns -1 if version1 < version2, 0 if version1 = version2, 1 if version1 > version2
func ConvertMsToUnit ¶
ConvertMsToUnit converts time from milliseconds to unit
func ConvertUnitToMs ¶
ConvertUnitToMs converts time from unit to milliseconds
func CreateSingletonList ¶
func CreateSingletonList(in interface{}) []interface{}
CreateSingletonList returns a list of single entry from an interface
func ErrorFromHTTPResponse ¶
func ErrorFromHTTPResponse(resp *http.Response, apiError error, entity, entityName, operation string) error
ErrorFromHTTPResponse extracts the error message from the HTTP response of the API
func ErrorFromResponseBody ¶ added in v0.1.6
func ErrorFromResponseBody(errorBlock YbaStructuredError) string
ErrorFromResponseBody is a function to extract error interfaces into string
func GcpGetCredentialsAsMap ¶
GcpGetCredentialsAsMap returns the GCE JSON file contents as a map
func GcpGetCredentialsAsString ¶
GcpGetCredentialsAsString returns the GCE JSON file contents as a string
func GetBoolPointer ¶
GetBoolPointer returns a pointer to bool value
func GetFloat64Pointer ¶
GetFloat64Pointer returns a pointer to float64 type
func GetInt32Pointer ¶
GetInt32Pointer returns a pointer to int32 value
func GetInt64Pointer ¶
GetInt64Pointer returns a pointer to int64 value
func GetMsFromDurationString ¶
GetMsFromDurationString retrieves the ms notation of the duration mentioned in the input string return value string holds the unit calculated from time.Duration Throws error on improper duration format
func GetStringPointer ¶
GetStringPointer returns a pointer to string value
func GetUnitOfTimeFromDuration ¶
GetUnitOfTimeFromDuration takes time.Duration as input and caluclates the unit specified in that duration
func GetUniversesForProvider ¶
func GetUniversesForProvider(ctx context.Context, c *client.APIClient, cUUID, pUUID, universeName string) ([]client.UniverseResp, bool, error)
GetUniversesForProvider fetches the list of universes corresponding to a particular provider. Currently edit operations are blocked if universes exists. For the current scenario, only on prem providers are editable, but to accomodate future changes to cloud provider resource, defining in the utils class
func IsVersionAllowed ¶ added in v0.1.6
IsVersionAllowed checks if a current version (>= Min version) is equal to the restricted version for the operation. Used in cases where certain preview build errors are not resolved and need to be blocked on YugabyteDB Anywhere Terraform provider
func MapFromSingletonList ¶
func MapFromSingletonList(in []interface{}) map[string]interface{}
MapFromSingletonList returns a map of string -> interface from a slice of interface
func MapListFromInterfaceList ¶
func MapListFromInterfaceList(in []interface{}) []map[string]interface{}
MapListFromInterfaceList returns a map of string -> interface from a slice of interface
func ObfuscateString ¶ added in v0.1.10
ObfuscateString masks sensitive strings in the state file
func ReadSSHPrivateKey ¶
ReadSSHPrivateKey retrives private key file contents from env variable
func StringMap ¶
StringMap accepts a string -> interface map and returns pointer to string -> string map
func StringSlice ¶
func StringSlice(in []interface{}) *[]string
StringSlice accepts array of interface and returns a pointer to slice of string
func WaitForTask ¶
func WaitForTask(ctx context.Context, tUUID string, cUUID string, c *client.APIClient, timeout time.Duration) error
WaitForTask waits for State change for a YBA task
func YBARestrictBackupVersions ¶ added in v0.1.6
func YBARestrictBackupVersions() []string
YBARestrictBackupVersions are certain YugabyteDB Anywhere versions >= min version for backups that would not support the operation
func YBARestrictFailedSubtasksVersions ¶ added in v0.1.6
func YBARestrictFailedSubtasksVersions() []string
YBARestrictFailedSubtasksVersions are certain YugabyteDB Anywhere versions >= min version for of fetching failed subtask lists that would not support the operation
Types ¶
type AzureCredentials ¶
type AzureCredentials struct { TenantID string `json:"tenant_id"` SubscriptionID string `json:"subscription_id"` ClientSecret string `json:"client_secret"` ClientID string `json:"client_id"` ResourceGroup string `json:"resource_group"` }
AzureCredentials required for cloud provider
func AzureCredentialsFromEnv ¶
func AzureCredentialsFromEnv() (AzureCredentials, error)
AzureCredentialsFromEnv retrives azure credentials from env variables
type GCPCredentials ¶
type GCPCredentials struct { AuthProviderX509CertURL string `json:"auth_provider_x509_cert_url,omitempty"` AuthURI string `json:"auth_uri,omitempty"` ClientEmail string `json:"client_email"` ClientID string `json:"client_id"` ClientX509CertURL string `json:"client_x509_cert_url"` PrivateKey string `json:"private_key"` PrivateKeyID string `json:"private_key_id"` ProjectID string `json:"project_id"` TokenURI string `json:"token_uri,omitempty"` Type string `json:"type"` }
GCPCredentials is a struct to hold values retrieved by parsing the GCE credentials json file
type YbaStructuredError ¶ added in v0.1.6
type YbaStructuredError struct { // User-visible unstructured error message Error *interface{} `json:"error,omitempty"` // Method for HTTP call that resulted in this error HTTPMethod *string `json:"httpMethod,omitempty"` // URI for HTTP request that resulted in this error RequestURI *string `json:"requestUri,omitempty"` // Mostly set to false to indicate failure Success *bool `json:"success,omitempty"` }
YbaStructuredError is a structure mimicking YBPError, with error being an interface{} to accomodate errors thrown as YBPStructuredError