Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redis: Improves the invoking redis api method and supports refreshing credential automatically #7737

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
257 changes: 125 additions & 132 deletions alicloud/connectivity/client.go

Large diffs are not rendered by default.

293 changes: 271 additions & 22 deletions alicloud/connectivity/endpoint.go

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions alicloud/connectivity/helper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package connectivity

import "strings"

func ConvertKebabToSnake(s string) string {
return strings.ReplaceAll(s, "-", "_")
}
11 changes: 2 additions & 9 deletions alicloud/data_source_alicloud_kvstore_instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"time"

"github.com/PaesslerAG/jsonpath"
util "github.com/alibabacloud-go/tea-utils/service"
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"

"github.com/aliyun/terraform-provider-alicloud/alicloud/connectivity"
Expand Down Expand Up @@ -437,17 +436,11 @@ func dataSourceAlicloudKvstoreInstancesRead(d *schema.ResourceData, meta interfa
}

var response map[string]interface{}
conn, err := client.NewRedisaClient()
if err != nil {
return WrapError(err)
}

var err error
for {
runtime := util.RuntimeOptions{}
runtime.SetAutoretry(true)
wait := incrementalWait(3*time.Second, 3*time.Second)
err = resource.Retry(5*time.Minute, func() *resource.RetryError {
response, err = conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2015-01-01"), StringPointer("AK"), nil, request, &runtime)
response, err = client.RpcPost("R-kvstore", "2015-01-01", action, nil, request, true)
if err != nil {
if NeedRetry(err) {
wait()
Expand Down
172 changes: 168 additions & 4 deletions alicloud/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1908,6 +1908,12 @@ func providerConfigure(d *schema.ResourceData, p *schema.Provider) (interface{},
for _, endpointsSetI := range endpointsSet.List() {
endpoints := endpointsSetI.(map[string]interface{})
for key, val := range endpoints {
// Compatible with the deprecated endpoint setting
if val == nil || val.(string) == "" {
if v, ok := deprecatedEndpointMap[key]; ok {
val = endpoints[v]
}
}
endpointInit.Store(key, val)
}
config.EcsEndpoint = strings.TrimSpace(endpoints["ecs"].(string))
Expand Down Expand Up @@ -2559,6 +2565,12 @@ func endpointsSchema() *schema.Schema {
Default: "",
Description: descriptions["beebot_endpoint"],
},
"chatbot": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["beebot_endpoint"],
},

"eflo": {
Type: schema.TypeString,
Expand All @@ -2573,7 +2585,12 @@ func endpointsSchema() *schema.Schema {
Default: "",
Description: descriptions["srvcatalog_endpoint"],
},

"servicecatalog": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["srvcatalog_endpoint"],
},
"cloudfirewall": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -2622,6 +2639,12 @@ func endpointsSchema() *schema.Schema {
Default: "",
Description: descriptions["cbs_endpoint"],
},
"dbs": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["cbs_endpoint"],
},

"vpcpeer": {
Type: schema.TypeString,
Expand All @@ -2636,6 +2659,12 @@ func endpointsSchema() *schema.Schema {
Default: "",
Description: descriptions["dysms_endpoint"],
},
"sms": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["dysms_endpoint"],
},

"edas": {
Type: schema.TypeString,
Expand All @@ -2650,7 +2679,12 @@ func endpointsSchema() *schema.Schema {
Default: "",
Description: descriptions["edasschedulerx_endpoint"],
},

"schedulerx2": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["edasschedulerx_endpoint"],
},
"ehs": {
Type: schema.TypeString,
Optional: true,
Expand All @@ -2672,6 +2706,12 @@ func endpointsSchema() *schema.Schema {
Description: descriptions["ddosbasic_endpoint"],
},

"antiddos_public": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["ddosbasic_endpoint"],
},
"smartag": {
Type: schema.TypeString,
Optional: true,
Expand All @@ -2685,6 +2725,12 @@ func endpointsSchema() *schema.Schema {
Default: "",
Description: descriptions["oceanbase_endpoint"],
},
"oceanbasepro": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["oceanbase_endpoint"],
},

"gaplus": {
Type: schema.TypeString,
Expand All @@ -2706,6 +2752,12 @@ func endpointsSchema() *schema.Schema {
Default: "",
Description: descriptions["edsuser_endpoint"],
},
"eds_user": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["edsuser_endpoint"],
},

"acr": {
Type: schema.TypeString,
Expand Down Expand Up @@ -2751,6 +2803,12 @@ func endpointsSchema() *schema.Schema {
Default: "",
Description: descriptions["quickbi_endpoint"],
},
"quickbi_public": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["quickbi_endpoint"],
},
"vod": {
Type: schema.TypeString,
Optional: true,
Expand All @@ -2769,6 +2827,12 @@ func endpointsSchema() *schema.Schema {
Default: "",
Description: descriptions["gds_endpoint"],
},
"gdb": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["gds_endpoint"],
},
"dbfs": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -2824,6 +2888,12 @@ func endpointsSchema() *schema.Schema {
Default: "",
Description: descriptions["swas_endpoint"],
},
"swas_open": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["swas_endpoint"],
},

"imm": {
Type: schema.TypeString,
Expand All @@ -2850,6 +2920,12 @@ func endpointsSchema() *schema.Schema {
Default: "",
Description: descriptions["alidfs_endpoint"],
},
"dfs": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["alidfs_endpoint"],
},

"ens": {
Type: schema.TypeString,
Expand Down Expand Up @@ -2904,7 +2980,12 @@ func endpointsSchema() *schema.Schema {
Default: "",
Description: descriptions["dataworkspublic_endpoint"],
},

"dataworks_public": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["dataworkspublic_endpoint"],
},
"hcs_sgw": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -2937,6 +3018,12 @@ func endpointsSchema() *schema.Schema {
Default: "",
Description: descriptions["gwsecd_endpoint"],
},
"ecd": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["gwsecd_endpoint"],
},
"scdn": {
Type: schema.TypeString,
Optional: true,
Expand All @@ -2956,14 +3043,26 @@ func endpointsSchema() *schema.Schema {
Default: "",
Description: descriptions["serverless_endpoint"],
},

"sae": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["serverless_endpoint"],
},
"hbr": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["hbr_endpoint"],
},

"amqp": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["onsproxy_endpoint"],
},

"onsproxy": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -3025,6 +3124,11 @@ func endpointsSchema() *schema.Schema {
Default: "",
Description: descriptions["resourcesharing_endpoint"],
},
"resourcesharing": {
Type: schema.TypeString,
Optional: true,
Default: "",
},
"ga": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -3277,6 +3381,12 @@ func endpointsSchema() *schema.Schema {
Default: "",
Description: descriptions["drds_endpoint"],
},
"polardbx": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["drds_endpoint"],
},
"dds": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -3307,6 +3417,12 @@ func endpointsSchema() *schema.Schema {
Default: "",
Description: descriptions["fc_endpoint"],
},
"fc_open": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["fc_endpoint"],
},
"apigateway": {
Type: schema.TypeString,
Optional: true,
Expand All @@ -3319,12 +3435,28 @@ func endpointsSchema() *schema.Schema {
Default: "",
Description: descriptions["datahub_endpoint"],
},
"devops_rdc": {
Type: schema.TypeString,
Optional: true,
Default: "",
},
"mns": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["mns_endpoint"],
},
"mns_open": {
Type: schema.TypeString,
Optional: true,
Default: "",
Description: descriptions["mns_endpoint"],
},
"rocketmq": {
Type: schema.TypeString,
Optional: true,
Default: "",
},
"location": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -3539,6 +3671,38 @@ func endpointsToHash(v interface{}) int {
return hashcode.String(buf.String())
}

// deprecatedEndpointMap is used to map old service name to new service name
// key: new endpoint key
// value: deprecated endpoint key
var deprecatedEndpointMap = map[string]string{
"resourcesharing": "ressharing",
"ga": "gaplus",
"dms_enterprise": "dmsenterprise",
"sgw": "hcs_sgw",
"amqp": "onsproxy",
"cassandra": "cds",
"cloudfw": "cloudfirewall",
"sae": "serverless",
"r_kvstore": "redisa",
"ecd": "gwsecd",
"dataworks_public": "dataworkspublic",
"dfs": "alidfs",
"swas_open": "swas",
"quickbi_public": "quickbi",
"gdb": "gds",
"cr": "acr",
"eds_user": "edsuser",
"antiddos_public": "ddosbasic",
"schedulerx2": "edasschedulerx",
"ehpc": "ehs",
"sms": "dysms",
"dbs": "cbs",
"mns_open": "mns",
"servicecatalog": "srvcatalog",
"oceanbasepro": "oceanbase",
"chatbot": "beebot",
}

func getConfigFromProfile(d *schema.ResourceData, ProfileKey string) (interface{}, error) {

if providerConfig == nil {
Expand Down
Loading
Loading