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

provider/aws: Add JSON validation to the aws_sns_topic resource. #8902

Conversation

kwilczynski
Copy link
Contributor

This commit adds support for new helper function which is used to
normalise and validate JSON string.

Signed-off-by: Krzysztof Wilczynski [email protected]

@kwilczynski
Copy link
Contributor Author

Part of work which began in #8028.

@kwilczynski kwilczynski changed the title Add JSON validation to the aws_sns_topic resource. provider/aws: Add JSON validation to the aws_sns_topic resource. Sep 17, 2016
@kwilczynski
Copy link
Contributor Author

Acceptance test is passing:

$ make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSSNSTopic_'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2016/09/14 17:20:58 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSSNSTopic_ -timeout 120m
=== RUN   TestAccAWSSNSTopic_importBasic
--- PASS: TestAccAWSSNSTopic_importBasic (13.27s)
=== RUN   TestAccAWSSNSTopic_basic
--- PASS: TestAccAWSSNSTopic_basic (13.88s)
=== RUN   TestAccAWSSNSTopic_policy
--- PASS: TestAccAWSSNSTopic_policy (15.33s)
=== RUN   TestAccAWSSNSTopic_withIAMRole
--- PASS: TestAccAWSSNSTopic_withIAMRole (27.96s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/aws    70.456s

@@ -61,7 +62,7 @@ func resourceAwsSnsTopic() *schema.Resource {
log.Printf("[WARN] Error compacting JSON for Policy in SNS Topic")
return ""
}
value := normalizeJson(buffer.String())
value, _ := normalizeJsonString(buffer.String())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we need the error checking here (as discussed in slack)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be replaced with way simpler StateFunc, all these other code here is not really needed.

@kwilczynski kwilczynski force-pushed the feature/json-validation-aws_sns_topic branch from 9b5e320 to 59e247a Compare September 21, 2016 18:56
@kwilczynski kwilczynski changed the title provider/aws: Add JSON validation to the aws_sns_topic resource. [WIP] provider/aws: Add JSON validation to the aws_sns_topic resource. Sep 21, 2016
This commit adds support for new helper function which is used to
normalise and validate JSON string.

Signed-off-by: Krzysztof Wilczynski <[email protected]>
@kwilczynski kwilczynski force-pushed the feature/json-validation-aws_sns_topic branch 2 times, most recently from 30ba89c to 09f8b4a Compare September 22, 2016 07:45
@kwilczynski kwilczynski changed the title [WIP] provider/aws: Add JSON validation to the aws_sns_topic resource. provider/aws: Add JSON validation to the aws_sns_topic resource. Sep 22, 2016
This commit also removes unnecessary code from the StateFunc function,
and reduces it so that it only uses the normalizeJsonString helper.

Signed-off-by: Krzysztof Wilczynski <[email protected]>
@kwilczynski kwilczynski force-pushed the feature/json-validation-aws_sns_topic branch from 09f8b4a to b5934cb Compare September 22, 2016 08:00
@stack72
Copy link
Contributor

stack72 commented Sep 22, 2016

I have just fixed this up locally :) There was an issue with extra imports

builtin/providers/aws/resource_aws_sns_topic.go:4: imported and not used: "bytes"
builtin/providers/aws/resource_aws_sns_topic.go:5: imported and not used: "encoding/json"
% make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSSNSTopic_'                                                                           2 ↵
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2016/09/22 09:05:49 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSSNSTopic_ -timeout 120m
=== RUN   TestAccAWSSNSTopic_importBasic
--- PASS: TestAccAWSSNSTopic_importBasic (18.46s)
=== RUN   TestAccAWSSNSTopic_basic
--- PASS: TestAccAWSSNSTopic_basic (17.98s)
=== RUN   TestAccAWSSNSTopic_policy
--- PASS: TestAccAWSSNSTopic_policy (19.45s)
=== RUN   TestAccAWSSNSTopic_withIAMRole
--- PASS: TestAccAWSSNSTopic_withIAMRole (27.03s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/aws    82.936s

@stack72
Copy link
Contributor

stack72 commented Sep 22, 2016

Manually merged :)

@stack72 stack72 closed this Sep 22, 2016
@kwilczynski
Copy link
Contributor Author

@stack72 thank you! I wasn't able to push fast enough from the train :)

@ghost
Copy link

ghost commented Apr 22, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants