common

package
v1.36.7 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MPL-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DataSourceTooFewDiag  = diag.Errorf("your query returned no results. Please change your search criteria and try again.")
	DataSourceTooManyDiag = diag.Errorf("your query returned more than one result. Please change your search criteria and try again.")
)
View Source
var Descriptions = map[string]string{
	"access_key": "The access key for API operations. You can retrieve this\n" +
		"from the 'My Credential' section of the console.",

	"secret_key": "The secret key for API operations. You can retrieve this\n" +
		"from the 'My Credential' section of the console.",

	"auth_url": "The Identity authentication URL.",

	"region": "The OpenTelekomCloud region to connect to.",

	"user_name": "Username to login with.",

	"user_id": "User ID to login with.",

	"tenant_id": "The ID of the Tenant (Identity v2) or Project (Identity v3)\n" +
		"to login with.",

	"tenant_name": "The name of the Tenant (Identity v2) or Project (Identity v3)\n" +
		"to login with.",

	"password": "Password to login with.",

	"token": "Authentication token to use as an alternative to username/password.",

	"security_token": "Security token to use for OBS federated authentication.",

	"domain_id": "The ID of the Domain to scope to (Identity v3).",

	"domain_name": "The name of the Domain to scope to (Identity v3).",

	"insecure": "Trust self-signed certificates.",

	"cacert_file": "A Custom CA certificate.",

	"endpoint_type": "The catalog endpoint type to use.",

	"cert": "A client certificate to authenticate with.",

	"key": "A client private key to authenticate with.",

	"swauth": "Use Swift's authentication system instead of Keystone. Only used for\n" +
		"interaction with Swift.",

	"agency_name": "The name of agency",

	"agency_domain_name": "The name of domain who created the agency (Identity v3).",

	"delegated_project": "The name of delegated project (Identity v3).",

	"cloud": "An entry in a `clouds.yaml` file to use.",

	"max_retries": "How many times HTTP connection should be retried until giving up.",

	"max_backoff_retries": "How many times HTTP request should be retried when rate limit reached",

	"backoff_retry_timeout": "Timeout in seconds for backoff retry",

	"passcode": "One-time MFA passcode",
}
View Source
var SuccessHTTPCodes = []int{200, 201, 202, 203, 204, 205, 206, 207, 208, 226}

Functions

func AddValueSpecs

func AddValueSpecs(body map[string]interface{}) map[string]interface{}

AddValueSpecs expands the 'value_specs' object and removes 'value_specs' from the request body.

func Base64IfNot

func Base64IfNot(src string) string

func BuildComponentID added in v1.23.12

func BuildComponentID(parts ...string) string

func BuildRequest

func BuildRequest(opts interface{}, parent string) (map[string]interface{}, error)

BuildRequest takes an opts struct and builds a request body for Gophercloud to execute

func CheckDeleted

func CheckDeleted(d *schema.ResourceData, err error, msg string) error

CheckDeleted checks the error to see if it's a 404 (Not Found) and, if so, sets the resource ID to the empty string instead of throwing an error.

func CheckDeletedDiag added in v1.29.0

func CheckDeletedDiag(d *schema.ResourceData, err error, msg string) diag.Diagnostics

CheckDeletedDiag checks the error to see if it's a 404 (Not Found) and, if so, sets the resource ID to the empty string instead of throwing an error.

func CheckForRetryableError

func CheckForRetryableError(err error) *resource.RetryError

func CheckNull added in v1.35.2

func CheckNull(element string, d *schema.ResourceData) bool

CheckNull returns true if schema parameter is empty

func CheckYamlString

func CheckYamlString(yamlString interface{}) (string, error)

Takes a value containing YAML string and passes it through the YAML parser. Returns either a parsing error or original YAML string.

func ClientFromCtx added in v1.26.0

func ClientFromCtx(ctx context.Context, keyClient string, fallbackFunc ContextCreatingFunction) (*golangsdk.ServiceClient, error)

func CompareJsonTemplateAreEquivalent added in v1.35.4

func CompareJsonTemplateAreEquivalent(tem1, tem2 string) (bool, error)

func Contains added in v1.23.11

func Contains(tagSlice []tags.ResourceTag, tag tags.ResourceTag) bool

func CtxWithClient added in v1.26.0

func CtxWithClient(parent context.Context, client *golangsdk.ServiceClient, keyClient ClientCtxKey) context.Context

func ExpandResourceTags

func ExpandResourceTags(tagMap map[string]interface{}) []tags.ResourceTag

ExpandResourceTags returns the tags for the given map of data.

func ExpandToStringListBySet added in v1.36.7

func ExpandToStringListBySet(v *schema.Set) []string

ExpandToStringListBySet takes the result for a set of strings and returns a []string

func ExpandToStringSlice

func ExpandToStringSlice(v []interface{}) []string

func FilterSliceWithField added in v1.36.3

func FilterSliceWithField(all interface{}, filter map[string]interface{}) ([]interface{}, error)

FilterSliceWithField can filter the slice all through a map filter. If the field is a nested value, using dot(.) to split them, e.g. "SubBlock.SubField". If value in the map is zero, it will be ignored.

func FirstOneSet

func FirstOneSet(res map[string]interface{}, k1, k2 string) (interface{}, error)

FirstOneSet select first nonempty string or returns error if both are empty

func FlattenStringList

func FlattenStringList(list []*string) []interface{}

Takes list of pointers to strings. Expand to an array of raw strings and returns a []interface{} to keep compatibility w/ schema.NewSetschema.NewSet

func GetAllAvailableZones added in v1.23.2

func GetAllAvailableZones(d *schema.ResourceData) []string

func GetHashOrEmpty

func GetHashOrEmpty(v interface{}) string

func GetSetChanges added in v1.26.3

func GetSetChanges(d *schema.ResourceData, key string) (removed, added *schema.Set)

GetSetChanges returns a pair of sets describing removed and added items

func HasFilledOpt

func HasFilledOpt(d *schema.ResourceData, param string) bool

The result may be not correct when the type of param is string and user config it to 'param=""' but, there is no other way.

func ImportAsManaged

func ImportAsManaged(_ context.Context, d *schema.ResourceData, _ interface{}) ([]*schema.ResourceData, error)

func ImportByPath added in v1.24.4

func ImportByPath(attributes ...string) schema.StateContextFunc

ImportByPath can be used to import resource by complex ID (e.g. identity protocol by `<provider>/<identity>` or CCE addon by `<cluster_id>/<addon_id>`)

Usage in schema:

StateContext: common.ImportByPath("provider", "protocol"),

func InstallScriptEncode

func InstallScriptEncode(script string) string

func InstallScriptHashSum

func InstallScriptHashSum(script string) string

func IntSlice added in v1.26.2

func IntSlice(v interface{}) []int

IntSlice is used to wrap single integer element in slice

func IsEmptyValue

func IsEmptyValue(v reflect.Value) (bool, error)

func IsResourceNotFound

func IsResourceNotFound(err error) bool

func LooksLikeJsonString

func LooksLikeJsonString(s interface{}) bool

func MapResourceProp

func MapResourceProp(d *schema.ResourceData, prop string) map[string]interface{}

MapResourceProp converts ResourceData property into a map

func MapValueSpecs

func MapValueSpecs(d cfg.SchemaOrDiff) map[string]string

MapValueSpecs converts ResourceData into a map

func MultipleCustomizeDiffs

func MultipleCustomizeDiffs(funcs ...schema.CustomizeDiffFunc) schema.CustomizeDiffFunc
func NavigateValue(d interface{}, index []string, arrayIndex map[string]int) (interface{}, error)

func NormalizeJsonString

func NormalizeJsonString(jsonString interface{}) (string, error)

Takes a value containing JSON string and passes it through the JSON parser to normalize it, returns either a parsing error or normalized JSON string.

func ReplaceVars

func ReplaceVars(d *schema.ResourceData, linkTmpl string, kv map[string]string) (string, error)

func ReplaceVarsForTest

func ReplaceVarsForTest(rs *terraform.ResourceState, linkTmpl string) (string, error)

func RetryContextWithWaitForState added in v1.36.0

func RetryContextWithWaitForState(param *RetryContextWithWaitForStateParam) (interface{}, error)

RetryContextWithWaitForState The RetryFunc will be called first if the error of the return is nil, the retry will be ended and the res of the return will be returned if the retry of the return is true, the RetryFunc will be retried, and the WaitFunc will be called if it is not nil if the retry of the return is false, the retry will be ended and the error of the retry func will be returned

func SetComplexID added in v1.26.1

func SetComplexID(d *schema.ResourceData, attributes ...string) error

SetComplexID setting ID from multiple attributes by names

SetComplexID(d, "provider", "protocol")

will set ID from components:

"<provider>/<protocol>"

func SetIDComponents added in v1.26.1

func SetIDComponents(d *schema.ResourceData, attributes ...string) error

SetIDComponents setting attributes from complex ID, e.g.:

SetIDComponents(d, "provider", "protocol")

will set fields from ID formatted as

<provider>/<protocol>

func SortVersions

func SortVersions(src []string) []string

SortVersions sorts versions from newer to older. If non-version-like string will be found in the slice, slice will be sorted as string slice in reversed order (z-a)

func StrSlice added in v1.26.2

func StrSlice(v interface{}) []string

StrSlice is used to wrap single string element in slice

func StrSliceContains

func StrSliceContains(haystack []string, needle string) bool

StrSliceContains checks if a given string is contained in a slice When anybody asks why Go needs generics, here you go.

func StringInSlice added in v1.23.8

func StringInSlice(str string, slice []string) bool

func StringToInt added in v1.36.7

func StringToInt(i *string) *int

StringToInt convert the string to int, and return the pointer of int value

func SuppressCaseInsensitive

func SuppressCaseInsensitive(_, old, new string, _ *schema.ResourceData) bool

func SuppressComputedFixedWhenFloatingIp

func SuppressComputedFixedWhenFloatingIp(_, old, new string, d *schema.ResourceData) bool

SuppressComputedFixedWhenFloatingIp suppress changes if we get a fixed ip when not expecting one, if we have a floating ip (generates fixed ip).

func SuppressDiffAll

func SuppressDiffAll(_, _, _ string, _ *schema.ResourceData) bool

SuppressDiffAll suppress all changes?

func SuppressEmptyStringSHA added in v1.24.3

func SuppressEmptyStringSHA(k, old, new string, d *schema.ResourceData) bool

func SuppressEqualZoneNames

func SuppressEqualZoneNames(_, old, new string, _ *schema.ResourceData) bool

func SuppressEquivalentAwsPolicyDiffs

func SuppressEquivalentAwsPolicyDiffs(_, old, new string, _ *schema.ResourceData) bool

func SuppressExternalGateway

func SuppressExternalGateway(_, old, new string, _ *schema.ResourceData) bool

SuppressExternalGateway suppress changes if we don't specify an external gateway, but one is specified for us

func SuppressLBWhitelistDiffs

func SuppressLBWhitelistDiffs(_, old, new string, _ *schema.ResourceData) bool

func SuppressMinDisk

func SuppressMinDisk(_, old, new string, _ *schema.ResourceData) bool

SuppressMinDisk suppress changes if we get a computed min_disk_gb if value is unspecified (default 0)

func SuppressRdsNameDiffs

func SuppressRdsNameDiffs(_, old, new string, _ *schema.ResourceData) bool

func SuppressSmartVersionDiff

func SuppressSmartVersionDiff(_, old, new string, _ *schema.ResourceData) bool

func SuppressStrippedNewLines added in v1.23.8

func SuppressStrippedNewLines(_, old, new string, _ *schema.ResourceData) bool

func TagsSchema

func TagsSchema() *schema.Schema

TagsSchema returns the schema to use for tags.

func TagsToMap

func TagsToMap(tags []tags.ResourceTag) map[string]string

TagsToMap returns the list of tags into a map.

func UpdateResourceTags

func UpdateResourceTags(client *golangsdk.ServiceClient, d *schema.ResourceData, resourceType, id string) error

UpdateResourceTags is a helper to update the tags for a resource. It expects the tags field to be named "tags"

func ValidateASGroupListenerID

func ValidateASGroupListenerID(v interface{}, k string) (ws []string, errors []error)

func ValidateAntiDdosAppTypeID

func ValidateAntiDdosAppTypeID(v interface{}, k string) (ws []string, errors []error)

func ValidateAntiDdosCleaningAccessPosID

func ValidateAntiDdosCleaningAccessPosID(v interface{}, k string) (ws []string, errors []error)

func ValidateAntiDdosHttpRequestPosID

func ValidateAntiDdosHttpRequestPosID(v interface{}, k string) (ws []string, errors []error)

func ValidateAntiDdosTrafficPosID

func ValidateAntiDdosTrafficPosID(v interface{}, k string) (ws []string, errors []error)

func ValidateCIDR

func ValidateCIDR(v interface{}, k string) (ws []string, errors []error)

func ValidateCTSEventName added in v1.32.0

func ValidateCTSEventName(v interface{}, k string) (ws []string, errors []error)

func ValidateDDSStartTime

func ValidateDDSStartTime(v interface{}, _ string) (ws []string, errors []error)

func ValidateEmail added in v1.31.0

func ValidateEmail(v interface{}, k string) (ws []string, errors []error)

func ValidateIP

func ValidateIP(v interface{}, k string) (ws []string, errors []error)

func ValidateIntRange

func ValidateIntRange(v interface{}, k string, l int, h int) (ws []string, errors []error)

ValidateIntRange Deprecated Use validation.IntBetween instead

func ValidateJsonString

func ValidateJsonString(v interface{}, k string) (ws []string, errors []error)

func ValidateK8sTagsMap

func ValidateK8sTagsMap(v interface{}, k string) (ws []string, errors []error)

func ValidateName

func ValidateName(v interface{}, k string) (ws []string, errors []error)

func ValidateRFC3339Timestamp added in v1.35.14

func ValidateRFC3339Timestamp(v interface{}, _ string) (ws []string, errors []error)

func ValidateStackTemplate

func ValidateStackTemplate(v interface{}, k string) (ws []string, errors []error)

func ValidateStringList

func ValidateStringList(v interface{}, k string, l []string) (ws []string, errors []error)

ValidateStringList Deprecated Use validation.StringInSlice instead

func ValidateSubnet

func ValidateSubnet(argName string) schema.CustomizeDiffFunc

func ValidateTags added in v1.23.5

func ValidateTags(v interface{}, k string) (ws []string, errors []error)

func ValidateTrueOnly

func ValidateTrueOnly(v interface{}, k string) (ws []string, errors []error)

func ValidateVBSBackupName

func ValidateVBSBackupName(v interface{}, k string) (ws []string, errors []error)

func ValidateVBSPolicyFrequency

func ValidateVBSPolicyFrequency(v interface{}, k string) (ws []string, errors []error)

func ValidateVBSPolicyName

func ValidateVBSPolicyName(v interface{}, k string) (ws []string, errors []error)

func ValidateVBSPolicyRetainBackup

func ValidateVBSPolicyRetainBackup(v interface{}, k string) (ws []string, errors []error)

func ValidateVBSPolicyRetentionNum

func ValidateVBSPolicyRetentionNum(v interface{}, k string) (ws []string, errors []error)

func ValidateVBSPolicyStatus

func ValidateVBSPolicyStatus(v interface{}, k string) (ws []string, errors []error)

func ValidateVBSTagKey

func ValidateVBSTagKey(v interface{}, k string) (ws []string, errors []error)

func ValidateVBSTagValue

func ValidateVBSTagValue(v interface{}, k string) (ws []string, errors []error)

func ValidateVPC

func ValidateVPC(argName string) schema.CustomizeDiffFunc

func ValidateVolumeType

func ValidateVolumeType(argName string) schema.CustomizeDiffFunc

Types

type ClientCtxKey added in v1.26.0

type ClientCtxKey string

type ContextCreatingFunction added in v1.26.0

type ContextCreatingFunction func() (*golangsdk.ServiceClient, error)

type RetryContextWithWaitForStateParam added in v1.36.0

type RetryContextWithWaitForStateParam struct {
	Ctx context.Context
	// The func that need to be retried
	RetryFunc RetryFunc
	// The wait func when the retry which returned by the retry func is true
	WaitFunc resource.StateRefreshFunc
	// The target of the wait func
	WaitTarget []string
	// The pending of the wait func
	WaitPending []string
	// The timeout of the retry func and wait func
	Timeout time.Duration
	// The delay timeout of the retry func and wait func
	DelayTimeout time.Duration
	// The poll interval of the retry func and wait func
	PollInterval time.Duration
}

type RetryFunc added in v1.36.0

type RetryFunc func() (res interface{}, retry bool, err error)

RetryFunc is the function retried until it succeeds. The first return parameter is the result of the retry func. The second return parameter indicates whether a retry is required. The last return parameter is the error of the func.

type StringSearcher

type StringSearcher interface {
	AddToIndex(keys ...string)
	Contains(key string) bool
}

StringSearcher is string search structure with internal cache This allows single iteration from base slice for multiple string searches

func NewStringSearcher

func NewStringSearcher() StringSearcher

Create new StringSearcher instance

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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