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

fix data type of version in datasource ucloud_iam_policy_document #159

Merged
merged 5 commits into from
Nov 22, 2023
Merged
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.38.3 (2023-11-22)

BUG FIXES:

* `datasource/ucloud_iam_policy_document`: fix data type of version.

## 1.38.2 (2023-09-27)

FEATURES:
Expand Down
2 changes: 1 addition & 1 deletion examples/rssd/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
ucloud = {
source = "ucloud/ucloud"
version = "~>1.38.2"
version = "~>1.38.3"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion ucloud/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (c *Config) Client() (*UCloudClient, error) {
// enable auto retry with http/connection error
cfg.MaxRetries = c.MaxRetries
cfg.LogLevel = log.PanicLevel
cfg.UserAgent = "Terraform-UCloud/1.38.2"
cfg.UserAgent = "Terraform-UCloud/1.38.3"
cfg.BaseUrl = c.BaseURL

cred := auth.NewCredential()
Expand Down
12 changes: 6 additions & 6 deletions ucloud/data_source_ucloud_iam_policy_document.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ func dataSourceUCloudIAMPolicyDocument() *schema.Resource {
Read: dataSourceUCloudIAMPolicyDocumentRead,
Schema: map[string]*schema.Schema{
"version": {
Type: schema.TypeInt,
Type: schema.TypeString,
Optional: true,
Default: 1,
ValidateFunc: validation.IntInSlice([]int{1}),
Default: "1",
ValidateFunc: validation.StringInSlice([]string{"1"}, false),
},
"statement": {
Type: schema.TypeList,
Expand Down Expand Up @@ -58,7 +58,7 @@ func dataSourceUCloudIAMPolicyDocument() *schema.Resource {
}
func dataSourceUCloudIAMPolicyDocumentRead(d *schema.ResourceData, meta interface{}) error {
if v, ok := d.GetOk("statement"); ok {
doc, err := assembleDataSourcePolicyJSON(v.([]interface{}), d.Get("version").(int))
doc, err := assembleDataSourcePolicyJSON(v.([]interface{}), d.Get("version").(string))
if err != nil {
return err
}
Expand All @@ -75,7 +75,7 @@ func dataSourceUCloudIAMPolicyDocumentRead(d *schema.ResourceData, meta interfac
return nil
}

func assembleDataSourcePolicyJSON(statements []interface{}, version int) (string, error) {
func assembleDataSourcePolicyJSON(statements []interface{}, version string) (string, error) {
document := PolicyDocument{Version: version}
for _, v := range statements {
var statement PolicyStatement
Expand All @@ -102,6 +102,6 @@ type PolicyStatement struct {
Resource []string `json:"Resource"`
}
type PolicyDocument struct {
Version int `json:"Version"`
Version string `json:"Version"`
Statement []PolicyStatement `json:"Statement"`
}
4 changes: 2 additions & 2 deletions ucloud/data_source_ucloud_iam_policy_document_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestAccUCloudIAMPolicyDocument_basic(t *testing.T) {

const testAccDataIAMPolicyDocumentConfig = `
data "ucloud_iam_policy_document" foo {
version = 1
version = "1"
statement {
effect = "Allow"

Expand All @@ -46,7 +46,7 @@ data "ucloud_iam_policy_document" foo {
]

resource = [
"ucs:uhost:*:<company-id>:instance/uhost-xxx",
"ucs:uhost:*:123:instance/uhost-xxx",
]
}
statement {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/d/iam_policy_document.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Generates an IAM policy document in JSON format for use with resources that expe

```hcl
data "ucloud_iam_policy_document" foo {
version = 1
version = "1"
statement {
effect = "Allow"

Expand Down
4 changes: 2 additions & 2 deletions website/docs/index.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ terraform {
required_providers {
ucloud = {
source = "ucloud/ucloud"
version = "~>1.38.2"
version = "~>1.38.3"
}
}
}
Expand Down Expand Up @@ -91,7 +91,7 @@ terraform {
required_providers {
ucloud = {
source = "ucloud/ucloud"
version = "~>1.38.2"
version = "~>1.38.3"
}
}
}
Expand Down