Skip to content

Commit

Permalink
support provider new argument sign_version
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaozhu36 committed Jan 17, 2024
1 parent 0f97bcc commit 39d0748
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions alicloud/connectivity/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type Config struct {
RamRoleExternalId string
RamRoleSessionExpiration int
Endpoints *sync.Map
SignVersion *sync.Map
RKvstoreEndpoint string
EcsEndpoint string
RdsEndpoint string
Expand Down
31 changes: 30 additions & 1 deletion alicloud/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ func Provider() terraform.ResourceProvider {
DefaultFunc: schema.EnvDefaultFunc("ALICLOUD_ACCOUNT_ID", os.Getenv("ALICLOUD_ACCOUNT_ID")),
Description: descriptions["account_id"],
},
"assume_role": assumeRoleSchema(),
"assume_role": assumeRoleSchema(),
"sign_version": signVersionSchema(),
"fc": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -1927,6 +1928,14 @@ func providerConfigure(d *schema.ResourceData, p *schema.Provider) (interface{},
config.CassandraEndpoint = strings.TrimSpace(endpoints["cassandra"].(string))
}

var signVersion sync.Map
config.SignVersion = &signVersion
for _, version := range d.Get("sign_version").(*schema.Set).List() {
for key, val := range version.(map[string]interface{}) {
signVersion.Store(key, val)
}
}

if config.RamRoleArn != "" {
config.AccessKey, config.SecretKey, config.SecurityToken, err = getAssumeRoleAK(config)
if err != nil {
Expand Down Expand Up @@ -2327,6 +2336,26 @@ func assumeRoleSchema() *schema.Schema {
}
}

func signVersionSchema() *schema.Schema {
return &schema.Schema{
Type: schema.TypeSet,
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"oss": {
Type: schema.TypeString,
Optional: true,
},
"sls": {
Type: schema.TypeString,
Optional: true,
},
},
},
}
}

func endpointsSchema() *schema.Schema {
return &schema.Schema{
Type: schema.TypeSet,
Expand Down

0 comments on commit 39d0748

Please sign in to comment.