Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaozhu36 committed Nov 14, 2024
1 parent 33d3d06 commit efb72a4
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 66 deletions.
100 changes: 44 additions & 56 deletions alicloud/connectivity/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ var loadSdkfromRemoteMutex = sync.Mutex{}
var loadSdkEndpointMutex = sync.Mutex{}

// The main version number that is being run at the moment.
var providerVersion = "1.233.1"
var providerVersion = "1.234.0"

// Temporarily maintain map for old ecs client methods and store special endpoint information
var EndpointMap = map[string]string{
Expand Down Expand Up @@ -5669,65 +5669,29 @@ func (client *AliyunClient) NewPaiworkspaceClient() (*roa.Client, error) {
}
return conn, nil
}

type ossCredentials struct {
client *AliyunClient
}

func (defCre *ossCredentials) GetAccessKeyID() string {
value, err := defCre.client.teaSdkConfig.Credential.GetAccessKeyId()
if err == nil && value != nil {
return *value
}
return defCre.client.config.AccessKey
}

func (defCre *ossCredentials) GetAccessKeySecret() string {
value, err := defCre.client.teaSdkConfig.Credential.GetAccessKeySecret()
if err == nil && value != nil {
return *value
func (client *AliyunClient) NewVpcipamClient() (*rpc.Client, error) {
productCode := "vpcipam"
endpoint := ""
if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" {
if err := client.loadEndpoint(productCode); err != nil {
endpoint = fmt.Sprintf("vpcipam.%s.aliyuncs.com", client.config.RegionId)
client.config.Endpoints.Store(productCode, endpoint)
log.Printf("[ERROR] loading %s endpoint got an error: %#v. Using the endpoint %s instead.", productCode, err, endpoint)
}
}
return defCre.client.config.SecretKey
}

func (defCre *ossCredentials) GetSecurityToken() string {
value, err := defCre.client.teaSdkConfig.Credential.GetSecurityToken()
if err == nil && value != nil {
return *value
if v, ok := client.config.Endpoints.Load(productCode); ok && v.(string) != "" {
endpoint = v.(string)
}
return defCre.client.config.SecurityToken
}

type ossCredentialsProvider struct {
client *AliyunClient
}

func (defBuild *ossCredentialsProvider) GetCredentials() oss.Credentials {
return &ossCredentials{client: defBuild.client}
}

func (client *AliyunClient) GetRetryTimeout(defaultTimeout time.Duration) time.Duration {

maxRetryTimeout := client.config.MaxRetryTimeout
if maxRetryTimeout != 0 {
return time.Duration(maxRetryTimeout) * time.Second
if endpoint == "" {
return nil, fmt.Errorf("[ERROR] missing the product %s endpoint.", productCode)
}

return defaultTimeout
}

func (client *AliyunClient) GenRoaParam(action, method, version, path string) *openapi.Params {
return &openapi.Params{
Action: tea.String(action),
Version: tea.String(version),
Protocol: tea.String(client.config.Protocol),
Pathname: tea.String(path),
Method: tea.String(method),
AuthType: tea.String("AK"),
Style: tea.String("ROA"),
ReqBodyType: tea.String("formData"),
BodyType: tea.String("json"),
sdkConfig := client.teaSdkConfig
sdkConfig.SetEndpoint(endpoint)
conn, err := rpc.NewClient(&sdkConfig)
if err != nil {
return nil, fmt.Errorf("unable to initialize the %s client: %#v", productCode, err)
}
return conn, nil
}
func (client *AliyunClient) NewGwlbClient() (*rpc.Client, error) {
productCode := "gwlb"
Expand All @@ -5753,6 +5717,30 @@ func (client *AliyunClient) NewGwlbClient() (*rpc.Client, error) {
}
return conn, nil
}
func (client *AliyunClient) NewEsaClient() (*rpc.Client, error) {
productCode := "dcdnservices"
endpoint := ""
if v, ok := client.config.Endpoints.Load(productCode); !ok || v.(string) == "" {
if err := client.loadEndpoint(productCode); err != nil {
endpoint = fmt.Sprintf("%s", client.config.RegionId)
client.config.Endpoints.Store(productCode, endpoint)
log.Printf("[ERROR] loading %s endpoint got an error: %#v. Using the endpoint %s instead.", productCode, err, endpoint)
}
}
if v, ok := client.config.Endpoints.Load(productCode); ok && v.(string) != "" {
endpoint = v.(string)
}
if endpoint == "" {
return nil, fmt.Errorf("[ERROR] missing the product %s endpoint.", productCode)
}
sdkConfig := client.teaSdkConfig
sdkConfig.SetEndpoint(endpoint)
conn, err := rpc.NewClient(&sdkConfig)
if err != nil {
return nil, fmt.Errorf("unable to initialize the %s client: %#v", productCode, err)
}
return conn, nil
}

type ossCredentials struct {
client *AliyunClient
Expand Down
3 changes: 1 addition & 2 deletions alicloud/data_source_alicloud_wafv3_domains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package alicloud

import (
"fmt"
"os"
"strings"
"testing"

Expand Down Expand Up @@ -229,6 +228,6 @@ EOF
enable_details = true
%s
}
`, rand, os.Getenv("ALICLOUD_REGION"), strings.Join(pairs, "\n "))
`, rand, "cn-hangzhou", strings.Join(pairs, "\n "))
return config
}
5 changes: 1 addition & 4 deletions alicloud/resource_alicloud_waf_domain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"testing"

"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 @@ -37,10 +35,9 @@ func testSweepWafDomains(region string) error {
wafInstanceIds := make([]string, 0)
domainIds := make([]string, 0)
request := make(map[string]interface{})
var err error
action := "DescribeInstanceInfos"

response, err := conn.DoRequest(StringPointer(action), nil, StringPointer("POST"), StringPointer("2019-09-10"), StringPointer("AK"), nil, request, &util.RuntimeOptions{})
response, err := client.RpcPost("waf-openapi", "2019-09-10", action, nil, request, false)
if err != nil {
log.Printf("[ERROR] Failed to retrieve waf instance in service list: %s", err)
}
Expand Down
7 changes: 3 additions & 4 deletions website/docs/d/waf_domains.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ description: |-
Provides a datasource to retrieve domain names.
---

# alicloud\_waf\_domains
# alicloud_waf_domains

Provides a WAF datasource to retrieve domains.

For information about WAF and how to use it, see [What is Alibaba Cloud WAF](https://www.alibabacloud.com/help/doc-detail/28517.htm).

-> **NOTE:** Available in 1.86.0+ .
-> **NOTE:** Available since v1.86.0.

## Example Usage

```
```terraform
data "alicloud_waf_domains" "default" {
instance_id = "waf-cf-xxxxx"
}
Expand Down Expand Up @@ -61,4 +61,3 @@ The following attributes are exported in addition to the arguments listed above:
* `source_ips` - List of the IP address or domain of the origin server to which the specified domain points.
* `version` - The system data identifier that is used to control optimistic locking.
* `write_time` - The timeout period for a WAF exclusive cluster write connection. Unit: seconds.
```

0 comments on commit efb72a4

Please sign in to comment.