Documentation ¶
Index ¶
- Constants
- Variables
- func Base64ToString(config string) (string, error)
- func BuildStateChangeConf(pending, target []string, timeout, delay time.Duration, ...) *resource.StateChangeConf
- func BuildTagResourceName(serviceType, resourceType, region, id string) string
- func CheckNil(object interface{}, fields map[string]string) (nilFields []string)
- func CheckResourceNameKeep(name string) string
- func CheckResourcePersist(name, createTime string) bool
- func CurrentTimeMillisecond() int64
- func DaysSinceCreation(createTime string) (string, error)
- func EqualArrayIgnoreOrder(sliceA, sliceB []string) bool
- func FindIntListIndex(list []int, elem int) int
- func GenerateCsvFile(filePath string, header []string) error
- func GetArrayIntersect(sliceA, sliceB []string) []string
- func GetListDiffs(o []int, n []int) (adds []int, lacks []int)
- func GetListIncrement(o []int, n []int) (result []int, err error)
- func GetLogId(ctx context.Context) string
- func GetResourceCreatorAccountInfo(client *connectivity.TencentCloudClient, resourceCreateAction string, ...) map[string]*ResourceAccountInfo
- func GetSubAccountUserName(client *connectivity.TencentCloudClient, uin string) string
- func InconsistentCheck(d *schema.ResourceData, meta interface{}) func()
- func IsContains(array interface{}, value interface{}) bool
- func IsDefaultSearchLogStartTimestampAfter(parsedTime time.Time) bool
- func IsExpectError(err error, expectError []string) bool
- func IsNil(v interface{}) bool
- func IsString(data interface{}) bool
- func LogElapsed(mark ...string) func()
- func MatchAny(value interface{}, matches ...interface{}) bool
- func MonthBetweenTwoDates(start, end string) int
- func NewResourceLifeCycleHandleFuncContext(parent context.Context, logID string, d *schema.ResourceData, meta interface{}) context.Context
- func ParseTimeFromCommonLayout(t *string) time.Time
- func ParsedTime(createTime string) (*time.Time, error)
- func ProcessNonKeepResources(client *connectivity.TencentCloudClient, nonKeepResources []*ResourceInstance, ...)
- func ProcessResources(client *connectivity.TencentCloudClient, resources []*ResourceInstance, ...)
- func ProcessScanCloudResources(client *connectivity.TencentCloudClient, ...)
- func ProviderMetaFromContext(ctx context.Context) interface{}
- func ReadFromFile(file string) ([]byte, error)
- func RemoveArrayIntersect(sliceA, elementsToRemove []string) []string
- func ResourceDataFromContext(ctx context.Context) *schema.ResourceData
- func RetryError(err error, additionRetryableError ...string) *resource.RetryError
- func RetryWithContext(ctx context.Context, timeout time.Duration, ...) (interface{}, error)
- func ShortRegionNameParse(shortRegion string) string
- func StringToBase64(config string) string
- func StringToTime(t string) time.Time
- func ValidateAllowedIntValue(ints []int) schema.SchemaValidateFunc
- func ValidateAllowedStringValue(ss []string) schema.SchemaValidateFunc
- func ValidateAllowedStringValueIgnoreCase(ss []string) schema.SchemaValidateFunc
- func ValidateAsConfigPassword(v interface{}, k string) (ws []string, errors []error)
- func ValidateAsScheduleTimestamp(v interface{}, k string) (ws []string, errors []error)
- func ValidateCIDRNetworkAddress(v interface{}, k string) (ws []string, errors []error)
- func ValidateCidrIp(v interface{}, k string) (ws []string, errs []error)
- func ValidateCosBucketLifecycleTimestamp(v interface{}, k string) (ws []string, errors []error)
- func ValidateCosBucketName(v interface{}, k string) (ws []string, errors []error)
- func ValidateImageID(v interface{}, k string) (ws []string, errors []error)
- func ValidateInstanceType(v interface{}, k string) (ws []string, errors []error)
- func ValidateIntegerInRange(min, max int64) schema.SchemaValidateFunc
- func ValidateIntegerMin(min int) schema.SchemaValidateFunc
- func ValidateIp(v interface{}, k string) (ws []string, errors []error)
- func ValidateKeyPairName(v interface{}, k string) (ws []string, errors []error)
- func ValidateLowCase(v interface{}, k string) (ws []string, errors []error)
- func ValidateMysqlPassword(v interface{}, k string) (ws []string, errors []error)
- func ValidateNameRegex(v interface{}, k string) (ws []string, errors []error)
- func ValidateNotEmpty(v interface{}, k string) (ws []string, errors []error)
- func ValidatePort(v interface{}, k string) (ws []string, errors []error)
- func ValidatePortRange(v interface{}, k string) (ws []string, errors []error)
- func ValidateStringLengthInRange(min, max int) schema.SchemaValidateFunc
- func ValidateStringNumber(v interface{}, k string) (ws []string, errors []error)
- func ValidateStringPrefix(prefix ...string) schema.SchemaValidateFunc
- func ValidateStringSuffix(suffix ...string) schema.SchemaValidateFunc
- func ValidateTime(layout string) schema.SchemaValidateFunc
- func ValidateTkeGpuDriverVersion(v interface{}, k string) (ws []string, errors []error)
- func ValidateYaml(v interface{}, k string) (ws []string, errors []error)
- func WriteCsvFileData(dirPath string, header []string, data [][]string) error
- func WriteToFile(filePath string, data interface{}) error
- func YamlParser(config string) (map[interface{}]interface{}, error)
- type CAMResponse
- type ContextData
- func (d *ContextData) Delete(key string)
- func (d *ContextData) Get(key string) interface{}
- func (d *ContextData) GetBool(key string) (ret bool, ok bool)
- func (d *ContextData) GetInt(key string) (ret int, ok bool)
- func (d *ContextData) GetInt64(key string) (ret int64, ok bool)
- func (d *ContextData) GetString(key string) (ret string, ok bool)
- func (d *ContextData) GetUInt(key string) (ret uint, ok bool)
- func (d *ContextData) GetUInt64(key string) (ret uint64, ok bool)
- func (d *ContextData) Set(key string, v interface{})
- type GoRoutineLimit
- type ProviderMeta
- type ResourceAccountInfo
- type ResourceInstance
Constants ¶
const ( // DefaultSearchLogStartTimestamp sync logs start time 2023-11-07 16:41:00 DefaultSearchLogStartTimestamp int64 = 1699346460000 DefaultTopicId = "aef50d54-b17d-4782-8618-a7873203ec29" QueryGrammarRule = " AND " )
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" )
const ( SweeperResourceScanDir = "../../../tmp/resource_scan/" SweeperNonKeepResourceScanDir = "../../../tmp/non_keep_resource_scan/" )
const ( KeepResource = "keep" NonKeepResource = "non-keep" SystemUserName = "system" )
const COMMA_SP = ","
const FILED_SP = "#"
const InternalError = "InternalError"
InternalError common internalError, do not add in retryableErrorCode, because when some product return this error, retry won't fix anything.
const LogIdKey = contextLogId("logId")
Variables ¶
var ContextNil context.Context = nil
var NeedProtect = getEnvDefault(SWEEPER_NEED_PROTECT, 0)
NeedProtect ... const writeRetryTimeout = 5 * time.Minute
var NonKeepResourceScanHeader = []string{"ResourceType", "ResourceName", "InstanceId", "InstanceName", "PrincipalId", "UserName"}
var ReadRetryTimeout = time.Duration(readRetry) * time.Minute
var ResourceScanHeader = []string{"资源类型", "资源名称", "实例ID", "实例名称", "分类", "创建时长(天)", "创建者用户ID", "创建者用户名"}
var TimeFormats = []string{ time.RFC3339, "2006-01-02 15:04:05", }
TimeFormats add all possible time formats
var WaitReadTimeout = time.Duration(waitRead) * time.Second
var WriteRetryTimeout = time.Duration(writeRetry) * time.Minute
Functions ¶
func Base64ToString ¶
func BuildStateChangeConf ¶
func BuildStateChangeConf(pending, target []string, timeout, delay time.Duration, refresh resource.StateRefreshFunc) *resource.StateChangeConf
func BuildTagResourceName ¶
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 CheckResourceNameKeep ¶ added in v1.81.72
CheckResourceNameKeep check whether to keep resource name
func CheckResourcePersist ¶ added in v1.81.72
CheckResourcePersist check whether to persist resource
func CurrentTimeMillisecond ¶ added in v1.81.73
func CurrentTimeMillisecond() int64
CurrentTimeMillisecond get the current millisecond timestamp
func DaysSinceCreation ¶ added in v1.81.72
DaysSinceCreation compute resource creation duration
func EqualArrayIgnoreOrder ¶ added in v1.81.121
func FindIntListIndex ¶
func GenerateCsvFile ¶ added in v1.81.72
GenerateCsvFile generate when csv file does not exist
func GetArrayIntersect ¶ added in v1.81.121
func GetResourceCreatorAccountInfo ¶ added in v1.81.73
func GetResourceCreatorAccountInfo(client *connectivity.TencentCloudClient, resourceCreateAction string, resources []*ResourceInstance) map[string]*ResourceAccountInfo
GetResourceCreatorAccountInfo get resource creator user info
func GetSubAccountUserName ¶ added in v1.81.73
func GetSubAccountUserName(client *connectivity.TencentCloudClient, uin string) string
GetSubAccountUserName get sub account user name
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 IsDefaultSearchLogStartTimestampAfter ¶ added in v1.81.92
IsDefaultSearchLogStartTimestampAfter check whether the resource creation time is after the default search log start time
func IsExpectError ¶
IsExpectError returns whether error is expected error
func LogElapsed ¶
func LogElapsed(mark ...string) func()
LogElapsed log func elapsed time, using in defer
func MonthBetweenTwoDates ¶
func NewResourceLifeCycleHandleFuncContext ¶ added in v1.81.93
func NewResourceLifeCycleHandleFuncContext( parent context.Context, logID string, d *schema.ResourceData, meta interface{}, ) context.Context
NewResourceLifeCycleHandleFuncContext 创建一个资源生命周期处理方法上下文
func ParsedTime ¶ added in v1.81.72
ParsedTime parse time
func ProcessNonKeepResources ¶ added in v1.81.72
func ProcessNonKeepResources(client *connectivity.TencentCloudClient, nonKeepResources []*ResourceInstance, resourceCreateAction string)
ProcessNonKeepResources Processing scanned non-keep cloud resources
func ProcessResources ¶ added in v1.81.72
func ProcessResources(client *connectivity.TencentCloudClient, resources []*ResourceInstance, resourceCreateAction string)
ProcessResources Process all scanned cloud resources
func ProcessScanCloudResources ¶ added in v1.81.72
func ProcessScanCloudResources(client *connectivity.TencentCloudClient, resources, nonKeepResources []*ResourceInstance, resourceCreateAction string)
func ProviderMetaFromContext ¶ added in v1.81.93
ProviderMetaFromContext 从上下文获取 provider meta
func RemoveArrayIntersect ¶ added in v1.81.121
func ResourceDataFromContext ¶ added in v1.81.93
func ResourceDataFromContext(ctx context.Context) *schema.ResourceData
ResourceDataFromContext 从上下文获取资源数据
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 StringToBase64 ¶
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 ValidateCIDRNetworkAddress ¶
validateCIDRNetworkAddress ensures that the string value is a valid CIDR that represents a network address - it adds an error otherwise
func ValidateCidrIp ¶
func ValidateCosBucketName ¶
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 ValidateInstanceType ¶
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 ValidateKeyPairName ¶
func ValidateLowCase ¶
func ValidateMysqlPassword ¶
func ValidateNameRegex ¶
func ValidateNotEmpty ¶
func ValidatePort ¶
func ValidatePortRange ¶
func ValidateStringLengthInRange ¶
func ValidateStringLengthInRange(min, max int) schema.SchemaValidateFunc
func ValidateStringNumber ¶
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 ValidateYaml ¶
func WriteCsvFileData ¶ added in v1.81.72
WriteCsvFileData write data to csv file
func WriteToFile ¶
WriteToFile write data to file
func YamlParser ¶
YamlParser yaml syntax Parser
Types ¶
type CAMResponse ¶ added in v1.81.117
type CAMResponse struct { TmpSecretId string `json:"TmpSecretId"` TmpSecretKey string `json:"TmpSecretKey"` ExpiredTime int64 `json:"ExpiredTime"` Expiration string `json:"Expiration"` Token string `json:"Token"` Code string `json:"Code"` }
func GetAuthFromCAM ¶ added in v1.81.117
func GetAuthFromCAM(roleName string) (camResp *CAMResponse, err error)
type ContextData ¶ added in v1.81.133
type ContextData struct {
// contains filtered or unexported fields
}
ContextData 上下文临时数据
func DataFromContext ¶ added in v1.81.133
func DataFromContext(ctx context.Context) *ContextData
DataFromContext 从上下文获取 data
func (*ContextData) Get ¶ added in v1.81.133
func (d *ContextData) Get(key string) interface{}
Get 获取键
func (*ContextData) GetBool ¶ added in v1.81.133
func (d *ContextData) GetBool(key string) (ret bool, ok bool)
GetBool 获取 bool 数据键
func (*ContextData) GetInt ¶ added in v1.81.133
func (d *ContextData) GetInt(key string) (ret int, ok bool)
GetInt 获取 int 数据键
func (*ContextData) GetInt64 ¶ added in v1.81.133
func (d *ContextData) GetInt64(key string) (ret int64, ok bool)
GetInt64 获取 int64 数据键
func (*ContextData) GetString ¶ added in v1.81.133
func (d *ContextData) GetString(key string) (ret string, ok bool)
GetString 获取 string 数据键
func (*ContextData) GetUInt ¶ added in v1.81.133
func (d *ContextData) GetUInt(key string) (ret uint, ok bool)
GetUInt 获取 uint 数据键
func (*ContextData) GetUInt64 ¶ added in v1.81.133
func (d *ContextData) GetUInt64(key string) (ret uint64, ok bool)
GetUInt64 获取 uint64 数据键
func (*ContextData) Set ¶ added in v1.81.133
func (d *ContextData) Set(key string, v interface{})
Set 设置值
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 元信息
type ResourceAccountInfo ¶ added in v1.81.73
type ResourceAccountInfo struct { ResourceType string // 资源类型 ResourceName string // 资源名称 AccountId string // 主账号ID PrincipalId string // 用户ID UserName string // 用户名 }
ResourceAccountInfo 资源账户信息
func ParseLogJsonData ¶ added in v1.81.73
func ParseLogJsonData(jsonData string) *ResourceAccountInfo