Skip to content

Commit

Permalink
Ensure custom resource type preserved during autogeneration
Browse files Browse the repository at this point in the history
Issue: crewjam#9
  • Loading branch information
mweagle committed Jun 10, 2017
1 parent f6ff788 commit 25ea992
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions scraper/aws_schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ import (
// Top level resources must comply with the ResourceProperties interface
const topLevelTemplate = `// CfnResourceType returns {{.AWSTypeName}} to implement the ResourceProperties interface
func (s {{.GoTypeName}}) CfnResourceType() string {
{{if .IsCustomResource -}}
if "" != s.ResourceTypeName {
return s.ResourceTypeName
}
{{- end}}
return "{{.AWSTypeName}}"
}
`
Expand Down Expand Up @@ -341,15 +346,28 @@ func writePropertyDefinition(t *testing.T,
isTopLevel,
w)
}

// Special case the CustomResource
// Issue: https://github.com/crewjam/go-cloudformation/issues/9
if "AWS::CloudFormation::CustomResource" == cloudFormationPropertyTypeName {
fmt.Fprintf(w, `
// The user-defined Custom::* name to use for the resource. If empty,
// the default "AWS::CloudFormation::CustomResource" value will be used.
// See http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources.html
ResourceTypeName string
`)
}
fmt.Fprintf(w, "}\n\n")

// Write out the ResourceProperties function
templateParams := struct {
AWSTypeName string
GoTypeName string
AWSTypeName string
GoTypeName string
IsCustomResource bool
}{
cloudFormationPropertyTypeName,
golangTypename,
cloudFormationPropertyTypeName == "AWS::CloudFormation::CustomResource",
}

// Property level items should always have Lists created for them
Expand Down

0 comments on commit 25ea992

Please sign in to comment.