common

package
v0.2.22 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PROVIDER_WRITE_RETRY_TIMEOUT = "ZENLAYERCLOUD_WRITE_RETRY_TIMEOUT"
	PROVIDER_READ_RETRY_TIMEOUT  = "ZENLAYERCLOUD_READ_RETRY_TIMEOUT"
	PROVIDER_BMC_CREATE_TIMEOUT  = "ZENLAYERCLOUD_BMC_CREATE_TIMEOUT"
	PROVIDER_BMC_UPDATE_TIMEOUT  = "ZENLAYERCLOUD_BMC_UPDATE_TIMEOUT"
	PROVIDER_VM_CREATE_TIMEOUT   = "ZENLAYERCLOUD_VM_CREATE_TIMEOUT"
	PROVIDER_VM_UPDATE_TIMEOUT   = "ZENLAYERCLOUD_VM_UPDATE_TIMEOUT"
	PROVIDER_ZGA_CREATE_TIMEOUT  = "ZENLAYERCLOUD_ZGA_CREATE_TIMEOUT"
	PROVIDER_ZGA_UPDATE_TIMEOUT  = "ZENLAYERCLOUD_ZGA_UPDATE_TIMEOUT"
)
View Source
const (
	ServiceNotAvailable = "SERVICE_TEMPORARY_UNAVAILABLE"
	InternalServerError = "INTERNAL_SERVER_ERROR"
	ReadTimedOut        = "REQUEST_TIMED_OUT"
	ResourceNotFound    = "OPERATION_FAILED_RESOURCE_NOT_FOUND"
	OperationTimeout    = "INVALID_OPERATION_TIMEOUT"
)

Variables

View Source
var BmcCreateTimeout = time.Duration(getEnvDefault(PROVIDER_BMC_CREATE_TIMEOUT, 90)) * time.Minute
View Source
var BmcUpdateTimeout = time.Duration(getEnvDefault(PROVIDER_BMC_UPDATE_TIMEOUT, 90)) * time.Minute
View Source
var ReadRetryTimeout = time.Duration(readRetry) * time.Minute
View Source
var VmCreateTimeout = time.Duration(getEnvDefault(PROVIDER_VM_CREATE_TIMEOUT, 90)) * time.Minute
View Source
var VmUpdateTimeout = time.Duration(getEnvDefault(PROVIDER_VM_UPDATE_TIMEOUT, 90)) * time.Minute
View Source
var ZgaCreateTimeout = time.Duration(getEnvDefault(PROVIDER_ZGA_CREATE_TIMEOUT, 90)) * time.Minute
View Source
var ZgaUpdateTimeout = time.Duration(getEnvDefault(PROVIDER_ZGA_UPDATE_TIMEOUT, 90)) * time.Minute

Functions

func DataResourceIdHash

func DataResourceIdHash(ids []string) string

func Error

func Error(msg string, args ...interface{}) error

func GetTags added in v0.2.18

func GetTags(d *schema.ResourceData, k string) map[string]string

func IsContains

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

func IsExpectError

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

func LogApiRequest

func LogApiRequest(ctx context.Context, action string, request interface{}, response interface{}, err error)

func LogElapsed

func LogElapsed(ctx context.Context, mark ...string) func()

func NonEmptySetFieldValidFunc

func NonEmptySetFieldValidFunc(keys ...string) schema.CustomizeDiffFunc

func ParseResourceId

func ParseResourceId(id string, length int) (parts []string, err error)

func ParseTagChanges added in v0.2.18

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

func QueryAllPaginatedResource

func QueryAllPaginatedResource[T any](ctx context.Context, queryFunc QueryPaginatedFunc[T]) ([]T, error)

func RetryError

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

func String

func String(s string) int

func TagsToMap added in v0.2.18

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

func ToIntList

func ToIntList(value []interface{}) []int

func ToJsonString

func ToJsonString(data interface{}) string

func ToStringList

func ToStringList(value []interface{}) []string

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 WriteToFile

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

Types

type GoRoutineLimit

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

func NewGoRoutine

func NewGoRoutine(num int) *GoRoutineLimit

func (*GoRoutineLimit) Run

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

type QueryPaginatedFunc

type QueryPaginatedFunc[T any] func(ctx context.Context, pageNum, pageSize int) (items []T, total int, err error)

Jump to

Keyboard shortcuts

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