Documentation ¶
Overview ¶
Copyright (c) Huawei Technologies Co., Ltd. 2021. All rights resvered.
The common package defines some common functions, which are mainly used for the functions of the following services.
The difference between common package and utils:
- Common functions under common are related to the project, and common functions are placed here.
- Utils are some stored tool functions, which are not related to the project. Such as: date conversion, type conversion.
Index ¶
- func CaseInsensitiveFunc() schema.SchemaDiffSuppressFunc
- func CheckDeleted(d *schema.ResourceData, err error, msg string) error
- func CheckDeletedDiag(d *schema.ResourceData, err error, msg string) diag.Diagnostics
- func CheckForRetryableError(err error) *resource.RetryError
- func GetAutoPay(d *schema.ResourceData) string
- func GetEipIDbyAddress(client *golangsdk.ServiceClient, address, epsID string) (string, error)
- func GetEnterpriseProjectID(d *schema.ResourceData, config *config.HcsConfig) string
- func GetRegion(d *schema.ResourceData, config *config.HcsConfig) string
- func HasFilledOpt(d *schema.ResourceData, param string) bool
- func MigrateEnterpriseProject(client *golangsdk.ServiceClient, ...) error
- func MigrateEnterpriseProjectWithoutWait(cfg *config.Config, d *schema.ResourceData, ...) error
- func NewCustomClient(insecure bool, endpoints ...string) *golangsdk.ServiceClient
- func SchemaAutoPay(conflicts []string) *schema.Schema
- func SchemaAutoRenew(conflicts []string) *schema.Schema
- func SchemaAutoRenewUpdatable(conflicts []string) *schema.Schema
- func SchemaChargingMode(conflicts []string) *schema.Schema
- func SchemaPeriod(conflicts []string) *schema.Schema
- func SchemaPeriodUnit(conflicts []string) *schema.Schema
- func TagsComputedSchema() *schema.Schema
- func TagsForceNewSchema() *schema.Schema
- func TagsSchema() *schema.Schema
- func UnsubscribePrePaidResource(d *schema.ResourceData, config *config.HcsConfig, resourceIDs []string) error
- func UpdateAutoRenew(c *golangsdk.ServiceClient, enabled, resourceId string) error
- func UpdateEcsInstanceKeyPair(ctx context.Context, ecsClient, kmsClient *golangsdk.ServiceClient, ...) error
- func ValidatePrePaidChargeInfo(d *schema.ResourceData) error
- func WaitOrderComplete(ctx context.Context, client *golangsdk.ServiceClient, orderId string, ...) error
- func WaitOrderResourceComplete(ctx context.Context, client *golangsdk.ServiceClient, orderId string, ...) (string, error)
- type ErrorResp
- type KeypairAuthOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CaseInsensitiveFunc ¶
func CaseInsensitiveFunc() schema.SchemaDiffSuppressFunc
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 ¶
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 GetAutoPay ¶
func GetAutoPay(d *schema.ResourceData) string
GetAutoPay is a method to return whether order is auto pay according to the user input. auto_pay parameter inputs and returns:
false: false true, empty: true
Before using this function, make sure the parameter behavior is auto pay (the default value is "true").
func GetEipIDbyAddress ¶
GetEipIDbyAddress returns the EIP ID of address when success.
func GetEnterpriseProjectID ¶
func GetEnterpriseProjectID(d *schema.ResourceData, config *config.HcsConfig) string
GetEnterpriseProjectID returns the enterprise_project_id that was specified in the resource. If it was not set, the provider-level value is checked. The provider-level value can either be set by the `enterprise_project_id` argument or by HCS_ENTERPRISE_PROJECT_ID.
func GetRegion ¶
func GetRegion(d *schema.ResourceData, config *config.HcsConfig) string
GetRegion returns the region that was specified ina the resource. If a region was not set, the provider-level region is checked. The provider-level region can either be set by the region argument or by HCS_REGION_NAME.
func HasFilledOpt ¶
func HasFilledOpt(d *schema.ResourceData, param string) bool
func MigrateEnterpriseProjectWithoutWait ¶
func MigrateEnterpriseProjectWithoutWait(cfg *config.Config, d *schema.ResourceData, opts enterpriseprojects.MigrateResourceOpts) error
MigrateEnterpriseProjectWithoutWait is a method that used to a migrate resource from an enterprise project to another. NOTE: Please read the following contents carefully before using this method.
- This method only sends an asynchronous request and does not guarantee the result.
func NewCustomClient ¶
NewCustomClient creates a custom client assembled from user-provided endpoints. URLs will be assembled according to the endpoints array, separated each element by slashes. for example, array ["https://www.example.com", "v2", "test", ...] will form the address "https://www.example.com/v2/test/.../". NOTE: You can decide whether to skip the SSL certificate check with the insecure parameter.
func SchemaAutoPay ¶
func SchemaAutoRenew ¶
func SchemaChargingMode ¶
func SchemaPeriod ¶
func SchemaPeriodUnit ¶
func TagsComputedSchema ¶
TagsComputedSchema returns the schema to use for tags as an attribute
func TagsForceNewSchema ¶
TagsForceNewSchema returns the schema to use for tags with ForceNew
func UnsubscribePrePaidResource ¶
func UnsubscribePrePaidResource(d *schema.ResourceData, config *config.HcsConfig, resourceIDs []string) error
UnsubscribePrePaidResource impl the action of unsubscribe resource
func UpdateAutoRenew ¶
func UpdateEcsInstanceKeyPair ¶
func UpdateEcsInstanceKeyPair(ctx context.Context, ecsClient, kmsClient *golangsdk.ServiceClient, opts *KeypairAuthOpts) error
func ValidatePrePaidChargeInfo ¶
func ValidatePrePaidChargeInfo(d *schema.ResourceData) error
func WaitOrderComplete ¶
func WaitOrderResourceComplete ¶
func WaitOrderResourceComplete(ctx context.Context, client *golangsdk.ServiceClient, orderId string, timeout time.Duration) (string, error)
WaitOrderResourceComplete is the method to wait for the resource to be generated. Notes: Note that this method needs to be used in conjunction with method "WaitOrderComplete", because the ID of some resources may not be generated when the order is not completed.
Types ¶
type KeypairAuthOpts ¶
type KeypairAuthOpts struct { // the ECS instance ID InstanceID string // the keypair name in used InUsedKeyPair string // the replaced keypair name NewKeyPair string // the private key of the keypair name in used, it's used to replace or unbind the keypair InUsedPrivateKey string // the root password of the ECS instance, it's used to bind a new keypair Password string // whether to disable SSH login on the VM DisablePassword bool // the timeout to wait for the task Timeout time.Duration }