util

package
v0.0.0-...-581a7fd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
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"
	// UseGCPIAM field name to denote in Json request
	UseGCPIAM = "USE_GCP_IAM"

	// 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"
	// IAMInstanceProfile field name to denote in Json request
	IAMInstanceProfile = "IAM_INSTANCE_PROFILE"

	// 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"

	// AzureStorageSasTokenEnv env variable name azure storage config
	AzureStorageSasTokenEnv = "AZURE_STORAGE_SAS_TOKEN"
)

Environment variable fields

View Source
const (

	// YBAAllowUniverseMinVersion specifies minimum version
	// required to use Universe resource via YBA CLI
	YBAAllowUniverseMinVersion = "2.17.1.0-b371"

	// YBAAllowBackupMinVersion specifies minimum version
	// required to use Scheduled Backup resource via YBA CLI
	YBAAllowBackupMinVersion = "2.18.1.0-b20"

	// YBAAllowEditProviderMinVersion specifies minimum version
	// required to Edit a Provider (onprem or cloud) resource
	// via YBA CLI
	YBAAllowNewProviderMinVersion = "2.18.0.0-b65"

	// YBAAllowFailureSubTaskListMinVersion specifies minimum version
	// required to fetch failed subtask message from YugabyteDB Anywhere
	YBAAllowFailureSubTaskListMinVersion = "2.19.0.0-b68"

	MinCLIStableVersion  = "2024.1.0.0-b4"
	MinCLIPreviewVersion = "2.21.0.0-b545"
)

Minimum YugabyteDB Anywhere versions to support operation

View Source
const (
	// ReadyUniverseState state
	ReadyUniverseState = "Ready"
	// PausedUniverseState state
	PausedUniverseState = "Paused"
	// PendingUniverseState state
	PendingUniverseState = "Pending"
	// WarningUniverseState state
	WarningUniverseState = "Warning"
	// BadUniverseState state
	BadUniverseState = "Error"
	// UnknownUniverseState state
	UnknownUniverseState = "Loading"
)

UniverseStates

View Source
const (
	// ReadyProviderState state
	ReadyProviderState = "READY"
	// UpdatingProviderState state
	UpdatingProviderState = "UPDATING"
	// ErrorroviderState state
	ErrorProviderState = "ERROR"
	// DeletingProviderState state
	DeletingProviderState = "DELETING"
)

ProviderStates

View Source
const (
	// CreateTaskStatus task status
	CreatedTaskStatus = "Created"
	// InitializingTaskStatus task status
	InitializingTaskStatus = "Initializing"
	// RunningTaskStatus task status
	RunningTaskStatus = "Running"
	// SuccessTaskStatus task status
	SuccessTaskStatus = "Success"
	// FailureTaskStatus task status
	FailureTaskStatus = "Failure"
	// UnknownTaskStatus task status
	UnknownTaskStatus = "Unknown"
	// AbortTaskStatus task status
	AbortTaskStatus = "Abort"
	// AbortedTaskStatus task status
	AbortedTaskStatus = "Aborted"
)

Allowed states for YugabyteDB Anywhere Tasks

View Source
const (
	// AddNode operation
	AddNode = "ADD"
	// StartNode operation
	StartNode = "START"
	// RebootNode operation
	RebootNode = "REBOOT"
	// StopNode operation
	StopNode = "STOP"
	// RemoveNode operation
	RemoveNode = "REMOVE"
	// ReprovisionNode operation
	ReprovisionNode = "REPROVISION"
	// ReleaseNode operation
	ReleaseNode = "RELEASE"
)

Node operations allowed on universe

View Source
const (
	// MasterServerType for master processes
	MasterServerType = "MASTER"
	// TserverServerType for tserver processes
	TserverServerType = "TSERVER"
	// ControllerServerType for YBC processes
	ControllerServerType = "CONTROLLER"
)

Server Type values

View Source
const (
	// UpgradeOperation type
	UpgradeOperation = "Upgrade"
	// EditOperation type
	EditOperation = "Edit"
)

Operation Type

View Source
const (
	// UniverseType resource
	UniverseType = "universe"
	// ProviderType resource
	ProviderType = "provider"
	// StorageConfigurationType resource
	StorageConfigurationType = "storage configuration"
)

Different resource types that are supported in CLI

View Source
const (
	// util.AWSProviderType type
	AWSProviderType = "aws"
	// AzureProviderType type
	AzureProviderType = "azu"
	// GCPProviderType type
	GCPProviderType = "gcp"
	// K8sProviderType type
	K8sProviderType = "kubernetes"
	// OnpremProviderType type
	OnpremProviderType = "onprem"
)

Different cloud provider types

View Source
const (
	// S3StorageConfigType type
	S3StorageConfigType = "S3"
	// AzureStorageConfigType type
	AzureStorageConfigType = "AZ"
	// GCSStorageConfigType type
	GCSStorageConfigType = "GCS"
	// NFSStorageConfigType type
	NFSStorageConfigType = "NFS"
)

Different storage configuration types

View Source
const (
	// PrimaryClusterType for primary cluster
	PrimaryClusterType = "PRIMARY"
	// ReadReplicaClusterType for rrs
	ReadReplicaClusterType = "ASYNC"
)

ClusterTypes for universe

View Source
const (
	// StorageCustomerConfigType field name to denote in request bodies
	StorageCustomerConfigType = "STORAGE"
)

Variables

This section is empty.

Functions

func AddCommandIfFeatureFlag

func AddCommandIfFeatureFlag(rootCmd *cobra.Command, cmd *cobra.Command, featureFlag FeatureFlag)

AddCommandIfFeatureFlag adds the command to root if feature flag is enabled

func AwsCredentialsFromEnv

func AwsCredentialsFromEnv() (awsCreds.Value, error)

AwsCredentialsFromEnv retrives values of "AWS_ACCESS_KEY_ID" and "AWS_SECRET_ACCESS_KEY" from env variables

func AwsInstanceTypesWithEphemeralStorageOnly

func AwsInstanceTypesWithEphemeralStorageOnly(instanceType string) bool

AwsInstanceTypesWithEphemeralStorageOnly returns true if the instance type has only ephemeral storage

func AzureStorageCredentialsFromEnv

func AzureStorageCredentialsFromEnv() (string, error)

AzureStorageCredentialsFromEnv retrives value of "AZURE_STORAGE_SAS_TOKEN" from env variables

func CompareYbVersions

func CompareYbVersions(v1 string, v2 string) (int, error)

CompareYbVersions returns -1 if version1 < version2, 0 if version1 = version2, 1 if version1 > version2

func CompletedStates

func CompletedStates() []string

CompletedStates returns set of states that mark the task as completed

func ConfirmCommand

func ConfirmCommand(message string, bypass bool) error

ConfirmCommand function will add an interactive comfirmation with the message provided

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, entityName,
	operation string) error

ErrorFromHTTPResponse extracts the error message from the HTTP response of the API

func ErrorFromResponseBody

func ErrorFromResponseBody(errorBlock YbaStructuredError) string

ErrorFromResponseBody is a function to extract error interfaces into string

func ErrorStates

func ErrorStates() []string

ErrorStates return set of states that mark state as failure

func GcpGetCredentialsAsMap

func GcpGetCredentialsAsMap() (map[string]interface{}, error)

GcpGetCredentialsAsMap returns the GCE JSON file contents as a map

func GcpGetCredentialsAsMapFromFilePath

func GcpGetCredentialsAsMapFromFilePath(filePath string) (map[string]interface{}, error)

GcpGetCredentialsAsMapFromFilePath returns the GCE JSON file contents as a map from the file path

func GcpGetCredentialsAsString

func GcpGetCredentialsAsString() (string, error)

GcpGetCredentialsAsString returns the GCE JSON file contents as a string

func GcpGetCredentialsAsStringFromFilePath

func GcpGetCredentialsAsStringFromFilePath(filePath string) (string, error)

GcpGetCredentialsAsStringFromFilePath returns the GCE JSON file contents as a string

func GetBoolPointer

func GetBoolPointer(in bool) *bool

GetBoolPointer returns a pointer to bool value

func GetFloat64Pointer

func GetFloat64Pointer(in float64) *float64

GetFloat64Pointer returns a pointer to float64 type

func GetInt32Pointer

func GetInt32Pointer(in int32) *int32

GetInt32Pointer returns a pointer to int32 value

func GetInt64Pointer

func GetInt64Pointer(in int64) *int64

GetInt64Pointer returns a pointer to int64 value

func GetStringPointer

func GetStringPointer(in string) *string

GetStringPointer returns a pointer to string value

func IncompleteStates

func IncompleteStates() []string

IncompleteStates return set of states for ongoing tasks

func IsFeatureFlagEnabled

func IsFeatureFlagEnabled(featureFlag FeatureFlag) bool

IsFeatureFlagEnabled checks if feature flag is set in the env variable

func IsOutputType

func IsOutputType(t string) bool

IsOutputType check if the output type is t

func IsVersionStable

func IsVersionStable(version string) bool

func IsYBVersion

func IsYBVersion(v string) (bool, error)

IsYBVersion checks if the given string is a valid YB version string

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 ReadSSHPrivateKey

func ReadSSHPrivateKey(filePath string) (*string, error)

ReadSSHPrivateKey retrives private key file contents from env variable

func StringMap

func StringMap(in map[string]interface{}) *map[string]string

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 StringSliceFromString

func StringSliceFromString(in []string) *[]string

StringSliceFromString accepts slice of string and returns a pointer to slice of string

func StringtoStringMap

func StringtoStringMap(in map[string]string) *map[string]string

StringtoStringMap accepts a string -> string map and returns pointer to string -> string map

func YAMLtoString

func YAMLtoString(filePath string) string

YAMLtoString reads yaml file and converts the data into a string

func YBARestrictBackupVersions

func YBARestrictBackupVersions() []string

YBARestrictBackupVersions are certain YugabyteDB Anywhere versions >= min version for backups that would not support the operation

func YBARestrictFailedSubtasksVersions

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 FeatureFlag

type FeatureFlag string

FeatureFlag string holds the defined feature flags that can be set

const (
	// TOOLS is a feature flag enabling doc generation
	TOOLS   FeatureFlag = "TOOLS"
	PREVIEW FeatureFlag = "PREVIEW"
)

func (FeatureFlag) String

func (f FeatureFlag) String() string

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 KuberenetesMetadata

type KuberenetesMetadata struct {
	Name string `yaml:"name"`
}

KuberenetesMetadata to extract image pull secret name

type KubernetesPullSecretYAML

type KubernetesPullSecretYAML struct {
	Metadata *KuberenetesMetadata `yaml:"metadata"`
}

KuberenetesPullSecretYAML to extract image pull secret name

type StringListListFlag

type StringListListFlag [][]string

StringListListFlag describes a list of list of strings

func (*StringListListFlag) Set

func (s *StringListListFlag) Set(value string) error

Set value adds the value string to a list of list of string

func (*StringListListFlag) String

func (s *StringListListFlag) String() string

String returns a string version of the JSON list of lists

func (*StringListListFlag) Type

func (s *StringListListFlag) Type() string

Type function describes the custom defined type

type YbaStructuredError

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL