Skip to content

Commit

Permalink
Merge in master and fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Stump committed Nov 15, 2018
2 parents f557b45 + e191bef commit d6748b7
Show file tree
Hide file tree
Showing 634 changed files with 42,271 additions and 6,390 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ website/vendor

# Keep windows files with windows line endings
*.winfile eol=crlf
/.vs
/.vs
node_modules
3 changes: 3 additions & 0 deletions .gometalinter.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{
"Deadline": "5m",
"Enable": [
"deadcode",
"errcheck",
"gofmt",
"ineffassign",
"interfacer",
"misspell",
"structcheck",
"unconvert",
"unparam",
"unused",
"varcheck",
"vet"
],
Expand Down
192 changes: 171 additions & 21 deletions CHANGELOG.md

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ fmt:
fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"

websitefmtcheck:
@sh -c "'$(CURDIR)/scripts/websitefmtcheck.sh'"

lint:
@echo "==> Checking source code against linters..."
@gometalinter ./$(PKG_NAME)
Expand Down
38 changes: 4 additions & 34 deletions aws/autoscaling_tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ func setAutoscalingTags(conn *autoscaling.AutoScaling, d *schema.ResourceData) e

if d.HasChange("tag") || d.HasChange("tags") {
oraw, nraw := d.GetChange("tag")
o := setToMapByKey(oraw.(*schema.Set), "key")
n := setToMapByKey(nraw.(*schema.Set), "key")
o := setToMapByKey(oraw.(*schema.Set))
n := setToMapByKey(nraw.(*schema.Set))

old, err := autoscalingTagsFromMap(o, resourceID)
if err != nil {
Expand Down Expand Up @@ -248,36 +248,6 @@ func autoscalingTagFromMap(attr map[string]interface{}, resourceID string) (*aut
return t, nil
}

// autoscalingTagsToMap turns the list of tags into a map.
func autoscalingTagsToMap(ts []*autoscaling.Tag) map[string]interface{} {
tags := make(map[string]interface{})
for _, t := range ts {
tag := map[string]interface{}{
"key": *t.Key,
"value": *t.Value,
"propagate_at_launch": *t.PropagateAtLaunch,
}
tags[*t.Key] = tag
}

return tags
}

// autoscalingTagDescriptionsToMap turns the list of tags into a map.
func autoscalingTagDescriptionsToMap(ts *[]*autoscaling.TagDescription) map[string]map[string]interface{} {
tags := make(map[string]map[string]interface{})
for _, t := range *ts {
tag := map[string]interface{}{
"key": *t.Key,
"value": *t.Value,
"propagate_at_launch": *t.PropagateAtLaunch,
}
tags[*t.Key] = tag
}

return tags
}

// autoscalingTagDescriptionsToSlice turns the list of tags into a slice.
func autoscalingTagDescriptionsToSlice(ts []*autoscaling.TagDescription) []map[string]interface{} {
tags := make([]map[string]interface{}, 0, len(ts))
Expand All @@ -292,11 +262,11 @@ func autoscalingTagDescriptionsToSlice(ts []*autoscaling.TagDescription) []map[s
return tags
}

func setToMapByKey(s *schema.Set, key string) map[string]interface{} {
func setToMapByKey(s *schema.Set) map[string]interface{} {
result := make(map[string]interface{})
for _, rawData := range s.List() {
data := rawData.(map[string]interface{})
result[data[key].(string)] = data
result[data["key"].(string)] = data
}

return result
Expand Down
30 changes: 30 additions & 0 deletions aws/autoscaling_tags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,33 @@ func TestIgnoringTagsAutoscaling(t *testing.T) {
}
}
}

// autoscalingTagsToMap turns the list of tags into a map.
func autoscalingTagsToMap(ts []*autoscaling.Tag) map[string]interface{} {
tags := make(map[string]interface{})
for _, t := range ts {
tag := map[string]interface{}{
"key": *t.Key,
"value": *t.Value,
"propagate_at_launch": *t.PropagateAtLaunch,
}
tags[*t.Key] = tag
}

return tags
}

// autoscalingTagDescriptionsToMap turns the list of tags into a map.
func autoscalingTagDescriptionsToMap(ts *[]*autoscaling.TagDescription) map[string]map[string]interface{} {
tags := make(map[string]map[string]interface{})
for _, t := range *ts {
tag := map[string]interface{}{
"key": *t.Key,
"value": *t.Value,
"propagate_at_launch": *t.PropagateAtLaunch,
}
tags[*t.Key] = tag
}

return tags
}
9 changes: 6 additions & 3 deletions aws/awserr.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ func isAWSErr(err error, code string, message string) bool {
return false
}

// Returns true if the error matches all these conditions:
// IsAWSErrExtended returns true if the error matches all conditions
// * err is of type awserr.Error
// * Error.Code() matches code
// * Error.Message() contains message
// * Error.OrigErr() contains origErrMessage
func isAWSErrExtended(err error, code string, message string, origErrMessage string) bool {
// Note: This function will be moved out of the aws package in the future.
func IsAWSErrExtended(err error, code string, message string, origErrMessage string) bool {
if !isAWSErr(err, code, message) {
return false
}
Expand All @@ -48,7 +49,9 @@ func retryOnAwsCode(code string, f func() (interface{}, error)) (interface{}, er
return resp, err
}

func retryOnAwsCodes(codes []string, f func() (interface{}, error)) (interface{}, error) {
// RetryOnAwsCodes retries AWS error codes for one minute
// Note: This function will be moved out of the aws package in the future.
func RetryOnAwsCodes(codes []string, f func() (interface{}, error)) (interface{}, error) {
var resp interface{}
err := resource.Retry(1*time.Minute, func() *resource.RetryError {
var err error
Expand Down
6 changes: 3 additions & 3 deletions aws/cloudfront_distribution_configuration_structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func expandDistributionConfig(d *schema.ResourceData) *cloudfront.DistributionCo
distributionConfig.CacheBehaviors = expandCacheBehaviorsDeprecated(d.Get("cache_behavior").(*schema.Set))
}
// This sets CallerReference if it's still pending computation (ie: new resource)
if v, ok := d.GetOk("caller_reference"); ok == false {
if v, ok := d.GetOk("caller_reference"); !ok {
distributionConfig.CallerReference = aws.String(time.Now().Format(time.RFC3339Nano))
} else {
distributionConfig.CallerReference = aws.String(v.(string))
Expand Down Expand Up @@ -524,7 +524,7 @@ func lambdaFunctionAssociationHash(v interface{}) int {
var buf bytes.Buffer
m := v.(map[string]interface{})
buf.WriteString(fmt.Sprintf("%s-", m["event_type"].(string)))
buf.WriteString(fmt.Sprintf("%s", m["lambda_arn"].(string)))
buf.WriteString(m["lambda_arn"].(string))
buf.WriteString(fmt.Sprintf("%t", m["include_body"].(bool)))
return hashcode.String(buf.String())
}
Expand Down Expand Up @@ -1259,7 +1259,7 @@ func simpleCopyStruct(src, dst interface{}) {
d := reflect.ValueOf(dst).Elem()

for i := 0; i < s.NumField(); i++ {
if s.Field(i).CanSet() == true {
if s.Field(i).CanSet() {
if s.Field(i).Interface() != nil {
for j := 0; j < d.NumField(); j++ {
if d.Type().Field(j).Name == s.Type().Field(i).Name {
Expand Down
Loading

0 comments on commit d6748b7

Please sign in to comment.