Skip to content

Commit 5725c9f

Browse files
authored
fix data type of version in datasource ucloud_iam_policy_document (#159)
* fix version type in IAMPolicyDocument datasource
1 parent bbc4fa7 commit 5725c9f

7 files changed

+19
-13
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 1.38.3 (2023-11-22)
2+
3+
BUG FIXES:
4+
5+
* `datasource/ucloud_iam_policy_document`: fix data type of version.
6+
17
## 1.38.2 (2023-09-27)
28

39
FEATURES:

examples/rssd/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
ucloud = {
44
source = "ucloud/ucloud"
5-
version = "~>1.38.2"
5+
version = "~>1.38.3"
66
}
77
}
88
}

ucloud/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func (c *Config) Client() (*UCloudClient, error) {
7272
// enable auto retry with http/connection error
7373
cfg.MaxRetries = c.MaxRetries
7474
cfg.LogLevel = log.PanicLevel
75-
cfg.UserAgent = "Terraform-UCloud/1.38.2"
75+
cfg.UserAgent = "Terraform-UCloud/1.38.3"
7676
cfg.BaseUrl = c.BaseURL
7777

7878
cred := auth.NewCredential()

ucloud/data_source_ucloud_iam_policy_document.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ func dataSourceUCloudIAMPolicyDocument() *schema.Resource {
1212
Read: dataSourceUCloudIAMPolicyDocumentRead,
1313
Schema: map[string]*schema.Schema{
1414
"version": {
15-
Type: schema.TypeInt,
15+
Type: schema.TypeString,
1616
Optional: true,
17-
Default: 1,
18-
ValidateFunc: validation.IntInSlice([]int{1}),
17+
Default: "1",
18+
ValidateFunc: validation.StringInSlice([]string{"1"}, false),
1919
},
2020
"statement": {
2121
Type: schema.TypeList,
@@ -58,7 +58,7 @@ func dataSourceUCloudIAMPolicyDocument() *schema.Resource {
5858
}
5959
func dataSourceUCloudIAMPolicyDocumentRead(d *schema.ResourceData, meta interface{}) error {
6060
if v, ok := d.GetOk("statement"); ok {
61-
doc, err := assembleDataSourcePolicyJSON(v.([]interface{}), d.Get("version").(int))
61+
doc, err := assembleDataSourcePolicyJSON(v.([]interface{}), d.Get("version").(string))
6262
if err != nil {
6363
return err
6464
}
@@ -75,7 +75,7 @@ func dataSourceUCloudIAMPolicyDocumentRead(d *schema.ResourceData, meta interfac
7575
return nil
7676
}
7777

78-
func assembleDataSourcePolicyJSON(statements []interface{}, version int) (string, error) {
78+
func assembleDataSourcePolicyJSON(statements []interface{}, version string) (string, error) {
7979
document := PolicyDocument{Version: version}
8080
for _, v := range statements {
8181
var statement PolicyStatement
@@ -102,6 +102,6 @@ type PolicyStatement struct {
102102
Resource []string `json:"Resource"`
103103
}
104104
type PolicyDocument struct {
105-
Version int `json:"Version"`
105+
Version string `json:"Version"`
106106
Statement []PolicyStatement `json:"Statement"`
107107
}

ucloud/data_source_ucloud_iam_policy_document_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func TestAccUCloudIAMPolicyDocument_basic(t *testing.T) {
3636

3737
const testAccDataIAMPolicyDocumentConfig = `
3838
data "ucloud_iam_policy_document" foo {
39-
version = 1
39+
version = "1"
4040
statement {
4141
effect = "Allow"
4242
@@ -46,7 +46,7 @@ data "ucloud_iam_policy_document" foo {
4646
]
4747
4848
resource = [
49-
"ucs:uhost:*:<company-id>:instance/uhost-xxx",
49+
"ucs:uhost:*:123:instance/uhost-xxx",
5050
]
5151
}
5252
statement {

website/docs/d/iam_policy_document.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Generates an IAM policy document in JSON format for use with resources that expe
1414

1515
```hcl
1616
data "ucloud_iam_policy_document" foo {
17-
version = 1
17+
version = "1"
1818
statement {
1919
effect = "Allow"
2020

website/docs/index.html.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ terraform {
2323
required_providers {
2424
ucloud = {
2525
source = "ucloud/ucloud"
26-
version = "~>1.38.2"
26+
version = "~>1.38.3"
2727
}
2828
}
2929
}
@@ -91,7 +91,7 @@ terraform {
9191
required_providers {
9292
ucloud = {
9393
source = "ucloud/ucloud"
94-
version = "~>1.38.2"
94+
version = "~>1.38.3"
9595
}
9696
}
9797
}

0 commit comments

Comments
 (0)