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: CloudFront post-merge review updates #6196

Merged
merged 6 commits into from
Apr 19, 2016

Conversation

vancluever
Copy link
Contributor

Hey guys,

Here are the updates to address the code review issues in #5221. Each commit has been pretty well annotated and each commit is kind of an issue in its own, but I can squash if need be.

The updates:

  • Fixed the hashing for ACM and IAM certificate parameters.
  • Added error handling to complex structure setting
  • Fixed primitives to pass pointers in instead of dereferenced values
  • Doc updates so that examples are properly indented
  • Removed delete retention to ensure that tests play well with Travis

@catsby catsby self-assigned this Apr 15, 2016
@@ -940,3 +974,28 @@ func flattenActiveTrustedSigners(ats *cloudfront.ActiveTrustedSigners) flatmap.M
m["items"] = s
return flatmap.Flatten(m)
}

// fullOK does a proper type-switch on an interface value and returns true
// if the underlying type contains a zero value. float is ommitted as it is
Copy link
Contributor

Choose a reason for hiding this comment

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

and returns true if the underlying type contains a zero value

It looks like it's returning false for default values

@catsby
Copy link
Contributor

catsby commented Apr 19, 2016

Looks good! One question on the fullOK function and docs, other than that great work 😄

@catsby catsby added bug waiting-response An issue/pull request is waiting for a response from the community labels Apr 19, 2016
@catsby
Copy link
Contributor

catsby commented Apr 19, 2016

Ah, looks like TestAccAWSCloudFrontDistribution_S3Origin gave me a panic/nil pointer dereference, line 94 of the test file

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
    panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x8 pc=0x311a93]

goroutine 20 [running]:
panic(0x1066c20, 0xc82000e140)
    /usr/local/go/src/runtime/panic.go:464 +0x3e6
testing.tRunner.func1(0xc820098a20)
    /usr/local/go/src/testing/testing.go:467 +0x192
panic(0x1066c20, 0xc82000e140)
    /usr/local/go/src/runtime/panic.go:426 +0x4e9
github.com/hashicorp/terraform/builtin/providers/aws.testAccCheckCloudFrontDistributionDestroy(0xc820358f30, 0x0, 0x0)
    /Users/clint/Projects/Go/src/github.com/hashicorp/terraform/builtin/providers/aws/resource_aws_cloudfront_distribution_test.go:94 +0x133
-->     if *dist.DistributionConfig.Enabled != false {
            return fmt.Errorf("CloudFront distribution should be disabled")
        }

@vancluever
Copy link
Contributor Author

vancluever commented Apr 19, 2016

@catsby, checking and fixing now. I'll just remove fullOK, you are right, it's too heavy-handed for this job as this is currently the only function using it. If other things prove to be an issue in hashing, I might look at how to do this better in general. It'd be neat if schema.ResourceData.GetOk() worked for general maps, for example, or more specifically if we had something like that for maps.

Chris Marchesi added 6 commits April 19, 2016 09:45
Adding necessary type assertion to values on the viewer_certificate hash
function to ensure that certain fields are indeed not zero string
values, versus simply zero interface{} values (aka nil, as is such for a
map[string]interface{}).
Handle errors better on calls to d.Set() in the
aws_cloudfront_distribution, namely in flattenDistributionConfig(). Also
caught a bug in the setting of the origin attribute, was incorrectly
attempting to set origins.
Change a few d.Set() for primitives in aws_cloudfront_distribution and
aws_cloudfront_origin_access_identity to use the pointer versus a
dereference.
Ran each example thru terraform fmt to fix indentation.
To play better with Travis and not bloat the test account with disabled
distributions.

Disable-only functionality has been retained - one can enable it with
the TF_TEST_CLOUDFRONT_RETAIN environment variable.
The call to resourceAwsCloudFrontDistributionWaitUntilDeployed() on
deletion of CloudFront distributions was not trapping error messages,
causing issues with waiter failure.
@vancluever
Copy link
Contributor Author

OK, all done. Also added a way to retain the disable-only functionality for tests via setting a TF_TEST_CLOUDFRONT_RETAIN environment variable - let me know your thoughts!

Also, found one more bug while I was at it - the delete waiter was not trapping error messages properly, so I've fixed that now (looks like it's taking abnormally long to disable distributions today).

@catsby
Copy link
Contributor

catsby commented Apr 19, 2016

Thanks! Looks good here and the acc tests are passing, gonna pull this in!

@catsby catsby merged commit 6ebac84 into hashicorp:master Apr 19, 2016
@vancluever
Copy link
Contributor Author

Thanks @catsby!

@vancluever vancluever deleted the paybyphone_cloudfront_review branch April 20, 2016 17:44
@ghost
Copy link

ghost commented Apr 26, 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 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug provider/aws waiting-response An issue/pull request is waiting for a response from the community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants