common

package
v1.81.64 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	PROVIDER_READ_RETRY_TIMEOUT  = "TENCENTCLOUD_READ_RETRY_TIMEOUT"
	PROVIDER_WRITE_RETRY_TIMEOUT = "TENCENTCLOUD_WRITE_RETRY_TIMEOUT"
	PROVIDER_WAIT_READ_TIMEOUT   = "TENCENTCLOUD_WAIT_READ_TIMEOUT"

	SWEEPER_NEED_PROTECT            = "SWEEPER_NEED_PROTECT"
	TENCENTCLOUD_COMMON_TIME_LAYOUT = "2006-01-02 15:04:05"
)
View Source
const COMMA_SP = ","
View Source
const FILED_SP = "#"
View Source
const InternalError = "InternalError"

InternalError common internalError, do not add in retryableErrorCode, because when some product return this error, retry won't fix anything.

View Source
const LogIdKey = contextLogId("logId")

Variables

View Source
var ContextNil context.Context = nil
View Source
var NeedProtect = getEnvDefault(SWEEPER_NEED_PROTECT, 0)

NeedProtect ... const writeRetryTimeout = 5 * time.Minute

View Source
var ReadRetryTimeout = time.Duration(readRetry) * time.Minute
View Source
var WaitReadTimeout = time.Duration(waitRead) * time.Second
View Source
var WriteRetryTimeout = time.Duration(writeRetry) * time.Minute

Functions

func Base64ToString

func Base64ToString(config string) (string, error)

func BuildStateChangeConf

func BuildStateChangeConf(pending, target []string, timeout, delay time.Duration, refresh resource.StateRefreshFunc) *resource.StateChangeConf

func BuildTagResourceName

func BuildTagResourceName(serviceType, resourceType, region, id string) string

BuildTagResourceName builds the Tencent Cloud specific name of a resource description. The format is `qcs:project_id:service_type:region:account:resource`. For more information, go to https://cloud.tencent.com/document/product/598/10606.

func CheckNil

func CheckNil(object interface{}, fields map[string]string) (nilFields []string)

func FindIntListIndex

func FindIntListIndex(list []int, elem int) int

func GetListDiffs

func GetListDiffs(o []int, n []int) (adds []int, lacks []int)

func GetListIncrement

func GetListIncrement(o []int, n []int) (result []int, err error)

func GetLogId

func GetLogId(ctx context.Context) string

GetLogId get logId for trace, return a new logId if ctx is nil

func InconsistentCheck

func InconsistentCheck(d *schema.ResourceData, meta interface{}) func()

InconsistentCheck for Provider produced inconsistent result after apply

func IsContains

func IsContains(array interface{}, value interface{}) bool

IsContains returns whether value is within array

func IsExpectError

func IsExpectError(err error, expectError []string) bool

IsExpectError returns whether error is expected error

func IsNil

func IsNil(v interface{}) bool

IsNil Determine whether i is empty

func IsString

func IsString(data interface{}) bool

IsString Determine whether data is a string

func LogElapsed

func LogElapsed(mark ...string) func()

LogElapsed log func elapsed time, using in defer

func MatchAny

func MatchAny(value interface{}, matches ...interface{}) bool

func MonthBetweenTwoDates

func MonthBetweenTwoDates(start, end string) int

func ParseTimeFromCommonLayout

func ParseTimeFromCommonLayout(t *string) time.Time

func ReadFromFile

func ReadFromFile(file string) ([]byte, error)

ReadFromFile return file content

func RetryError

func RetryError(err error, additionRetryableError ...string) *resource.RetryError

RetryError returns retry error

func RetryWithContext

func RetryWithContext(
	ctx context.Context,
	timeout time.Duration,
	f func(context.Context) (interface{}, error),
	additionRetryableError ...string) (interface{}, error)

RetryWithContext retries the function `f` when the error it returns satisfies `predicate`. `f` is retried until `timeout` expires.

func ShortRegionNameParse added in v1.81.60

func ShortRegionNameParse(shortRegion string) string

func StringToBase64

func StringToBase64(config string) string

func StringToTime

func StringToTime(t string) time.Time

StringToTime string to time.Time

func ValidateAllowedIntValue

func ValidateAllowedIntValue(ints []int) schema.SchemaValidateFunc

func ValidateAllowedStringValue

func ValidateAllowedStringValue(ss []string) schema.SchemaValidateFunc

func ValidateAllowedStringValueIgnoreCase

func ValidateAllowedStringValueIgnoreCase(ss []string) schema.SchemaValidateFunc

func ValidateAsConfigPassword

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

func ValidateAsScheduleTimestamp

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

func ValidateCIDRNetworkAddress

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

validateCIDRNetworkAddress ensures that the string value is a valid CIDR that represents a network address - it adds an error otherwise

func ValidateCidrIp

func ValidateCidrIp(v interface{}, k string) (ws []string, errs []error)

func ValidateCosBucketLifecycleTimestamp

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

func ValidateCosBucketName

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

Only support lowercase letters, numbers and "-". It cannot be longer than 60 characters. specification: https://cloud.tencent.com/document/product/436/13312

func ValidateImageID

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

func ValidateInstanceType

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

func ValidateIntegerInRange

func ValidateIntegerInRange(min, max int64) schema.SchemaValidateFunc

NOTE not exactly strict, but ok for now

func ValidateIntegerMin

func ValidateIntegerMin(min int) schema.SchemaValidateFunc

func ValidateIp

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

func ValidateKeyPairName

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

func ValidateLowCase

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

func ValidateMysqlPassword

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

func ValidateNameRegex

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

func ValidateNotEmpty

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

func ValidatePort

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

func ValidatePortRange

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

func ValidateStringLengthInRange

func ValidateStringLengthInRange(min, max int) schema.SchemaValidateFunc

func ValidateStringNumber

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

func ValidateStringPrefix

func ValidateStringPrefix(prefix ...string) schema.SchemaValidateFunc

check if string has given prefix, if no one prefix matches, errors will have error

func ValidateStringSuffix

func ValidateStringSuffix(suffix ...string) schema.SchemaValidateFunc

check if string has given suffix, if no one suffix matches, errors will have error

func ValidateTime

func ValidateTime(layout string) schema.SchemaValidateFunc

func ValidateTkeGpuDriverVersion

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

func ValidateYaml

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

func WriteToFile

func WriteToFile(filePath string, data interface{}) error

WriteToFile write data to file

func YamlParser

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

YamlParser yaml syntax Parser

Types

type GoRoutineLimit

type GoRoutineLimit struct {
	Count int
	Chan  chan struct{}
}

GoRoutineLimit ...

func NewGoRoutine

func NewGoRoutine(num int) *GoRoutineLimit

func (*GoRoutineLimit) Run

func (g *GoRoutineLimit) Run(f func())

type ProviderMeta

type ProviderMeta interface {
	// GetAPIV3Conn 返回访问云 API 的客户端连接对象
	GetAPIV3Conn() *connectivity.TencentCloudClient
}

ProviderMeta Provider 元信息

Jump to

Keyboard shortcuts

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