Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #175 from PaulMaddox/fix-resource-generation
Browse files Browse the repository at this point in the history
Fix resource generation
  • Loading branch information
PaulMaddox authored Mar 9, 2019
2 parents 638b5bd + e6b095e commit 197bd11
Show file tree
Hide file tree
Showing 488 changed files with 84,444 additions and 49,709 deletions.
25 changes: 18 additions & 7 deletions cloudformation/alexa-ask-skill.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cloudformation

import (
"bytes"
"encoding/json"
"errors"
"fmt"
Expand Down Expand Up @@ -99,7 +100,11 @@ func (r *AlexaASKSkill) UnmarshalJSON(b []byte) error {
DependsOn []string
Metadata map[string]interface{}
}{}
if err := json.Unmarshal(b, &res); err != nil {

dec := json.NewDecoder(bytes.NewReader(b))
dec.DisallowUnknownFields() // Force error if unknown field is found

if err := dec.Decode(&res); err != nil {
fmt.Printf("ERROR: %s\n", err)
return err
}
Expand All @@ -119,11 +124,13 @@ func (r *AlexaASKSkill) UnmarshalJSON(b []byte) error {
}

// GetAllAlexaASKSkillResources retrieves all AlexaASKSkill items from an AWS CloudFormation template
func (t *Template) GetAllAlexaASKSkillResources() map[string]AlexaASKSkill {
results := map[string]AlexaASKSkill{}
func (t *Template) GetAllAlexaASKSkillResources() map[string]*AlexaASKSkill {
results := map[string]*AlexaASKSkill{}
for name, untyped := range t.Resources {
switch resource := untyped.(type) {
case AlexaASKSkill:
results[name] = &resource
case *AlexaASKSkill:
// We found a strongly typed resource of the correct type; use it
results[name] = resource
case map[string]interface{}:
Expand All @@ -135,7 +142,8 @@ func (t *Template) GetAllAlexaASKSkillResources() map[string]AlexaASKSkill {
if b, err := json.Marshal(resource); err == nil {
var result AlexaASKSkill
if err := json.Unmarshal(b, &result); err == nil {
results[name] = result
t.Resources[name] = &result
results[name] = &result
}
}
}
Expand All @@ -147,10 +155,12 @@ func (t *Template) GetAllAlexaASKSkillResources() map[string]AlexaASKSkill {

// GetAlexaASKSkillWithName retrieves all AlexaASKSkill items from an AWS CloudFormation template
// whose logical ID matches the provided name. Returns an error if not found.
func (t *Template) GetAlexaASKSkillWithName(name string) (AlexaASKSkill, error) {
func (t *Template) GetAlexaASKSkillWithName(name string) (*AlexaASKSkill, error) {
if untyped, ok := t.Resources[name]; ok {
switch resource := untyped.(type) {
case AlexaASKSkill:
return &resource, nil
case *AlexaASKSkill:
// We found a strongly typed resource of the correct type; use it
return resource, nil
case map[string]interface{}:
Expand All @@ -162,12 +172,13 @@ func (t *Template) GetAlexaASKSkillWithName(name string) (AlexaASKSkill, error)
if b, err := json.Marshal(resource); err == nil {
var result AlexaASKSkill
if err := json.Unmarshal(b, &result); err == nil {
return result, nil
t.Resources[name] = &result
return &result, nil
}
}
}
}
}
}
return AlexaASKSkill{}, errors.New("resource not found")
return nil, errors.New("resource not found")
}
700 changes: 368 additions & 332 deletions cloudformation/all.go

Large diffs are not rendered by default.

30 changes: 23 additions & 7 deletions cloudformation/aws-amazonmq-broker.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cloudformation

import (
"bytes"
"encoding/json"
"errors"
"fmt"
Expand Down Expand Up @@ -70,6 +71,11 @@ type AWSAmazonMQBroker struct {
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-amazonmq-broker.html#cfn-amazonmq-broker-subnetids
SubnetIds []string `json:"SubnetIds,omitempty"`

// Tags AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-amazonmq-broker.html#cfn-amazonmq-broker-tags
Tags []AWSAmazonMQBroker_TagsEntry `json:"Tags,omitempty"`

// Users AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-amazonmq-broker.html#cfn-amazonmq-broker-users
Expand Down Expand Up @@ -149,7 +155,11 @@ func (r *AWSAmazonMQBroker) UnmarshalJSON(b []byte) error {
DependsOn []string
Metadata map[string]interface{}
}{}
if err := json.Unmarshal(b, &res); err != nil {

dec := json.NewDecoder(bytes.NewReader(b))
dec.DisallowUnknownFields() // Force error if unknown field is found

if err := dec.Decode(&res); err != nil {
fmt.Printf("ERROR: %s\n", err)
return err
}
Expand All @@ -169,11 +179,13 @@ func (r *AWSAmazonMQBroker) UnmarshalJSON(b []byte) error {
}

// GetAllAWSAmazonMQBrokerResources retrieves all AWSAmazonMQBroker items from an AWS CloudFormation template
func (t *Template) GetAllAWSAmazonMQBrokerResources() map[string]AWSAmazonMQBroker {
results := map[string]AWSAmazonMQBroker{}
func (t *Template) GetAllAWSAmazonMQBrokerResources() map[string]*AWSAmazonMQBroker {
results := map[string]*AWSAmazonMQBroker{}
for name, untyped := range t.Resources {
switch resource := untyped.(type) {
case AWSAmazonMQBroker:
results[name] = &resource
case *AWSAmazonMQBroker:
// We found a strongly typed resource of the correct type; use it
results[name] = resource
case map[string]interface{}:
Expand All @@ -185,7 +197,8 @@ func (t *Template) GetAllAWSAmazonMQBrokerResources() map[string]AWSAmazonMQBrok
if b, err := json.Marshal(resource); err == nil {
var result AWSAmazonMQBroker
if err := json.Unmarshal(b, &result); err == nil {
results[name] = result
t.Resources[name] = &result
results[name] = &result
}
}
}
Expand All @@ -197,10 +210,12 @@ func (t *Template) GetAllAWSAmazonMQBrokerResources() map[string]AWSAmazonMQBrok

// GetAWSAmazonMQBrokerWithName retrieves all AWSAmazonMQBroker items from an AWS CloudFormation template
// whose logical ID matches the provided name. Returns an error if not found.
func (t *Template) GetAWSAmazonMQBrokerWithName(name string) (AWSAmazonMQBroker, error) {
func (t *Template) GetAWSAmazonMQBrokerWithName(name string) (*AWSAmazonMQBroker, error) {
if untyped, ok := t.Resources[name]; ok {
switch resource := untyped.(type) {
case AWSAmazonMQBroker:
return &resource, nil
case *AWSAmazonMQBroker:
// We found a strongly typed resource of the correct type; use it
return resource, nil
case map[string]interface{}:
Expand All @@ -212,12 +227,13 @@ func (t *Template) GetAWSAmazonMQBrokerWithName(name string) (AWSAmazonMQBroker,
if b, err := json.Marshal(resource); err == nil {
var result AWSAmazonMQBroker
if err := json.Unmarshal(b, &result); err == nil {
return result, nil
t.Resources[name] = &result
return &result, nil
}
}
}
}
}
}
return AWSAmazonMQBroker{}, errors.New("resource not found")
return nil, errors.New("resource not found")
}
60 changes: 60 additions & 0 deletions cloudformation/aws-amazonmq-broker_tagsentry.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package cloudformation

// AWSAmazonMQBroker_TagsEntry AWS CloudFormation Resource (AWS::AmazonMQ::Broker.TagsEntry)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-amazonmq-broker-tagsentry.html
type AWSAmazonMQBroker_TagsEntry struct {

// Key AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-amazonmq-broker-tagsentry.html#cfn-amazonmq-broker-tagsentry-key
Key string `json:"Key,omitempty"`

// Value AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-amazonmq-broker-tagsentry.html#cfn-amazonmq-broker-tagsentry-value
Value string `json:"Value,omitempty"`

// _deletionPolicy represents a CloudFormation DeletionPolicy
_deletionPolicy DeletionPolicy

// _dependsOn stores the logical ID of the resources to be created before this resource
_dependsOn []string

// _metadata stores structured data associated with this resource
_metadata map[string]interface{}
}

// AWSCloudFormationType returns the AWS CloudFormation resource type
func (r *AWSAmazonMQBroker_TagsEntry) AWSCloudFormationType() string {
return "AWS::AmazonMQ::Broker.TagsEntry"
}

// DependsOn returns a slice of logical ID names this resource depends on.
// see: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-dependson.html
func (r *AWSAmazonMQBroker_TagsEntry) DependsOn() []string {
return r._dependsOn
}

// SetDependsOn specify that the creation of this resource follows another.
// see: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-dependson.html
func (r *AWSAmazonMQBroker_TagsEntry) SetDependsOn(dependencies []string) {
r._dependsOn = dependencies
}

// Metadata returns the metadata associated with this resource.
// see: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-metadata.html
func (r *AWSAmazonMQBroker_TagsEntry) Metadata() map[string]interface{} {
return r._metadata
}

// SetMetadata enables you to associate structured data with this resource.
// see: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-metadata.html
func (r *AWSAmazonMQBroker_TagsEntry) SetMetadata(metadata map[string]interface{}) {
r._metadata = metadata
}

// SetDeletionPolicy applies an AWS CloudFormation DeletionPolicy to this resource
// see: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html
func (r *AWSAmazonMQBroker_TagsEntry) SetDeletionPolicy(policy DeletionPolicy) {
r._deletionPolicy = policy
}
30 changes: 23 additions & 7 deletions cloudformation/aws-amazonmq-configuration.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cloudformation

import (
"bytes"
"encoding/json"
"errors"
"fmt"
Expand Down Expand Up @@ -35,6 +36,11 @@ type AWSAmazonMQConfiguration struct {
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-amazonmq-configuration.html#cfn-amazonmq-configuration-name
Name string `json:"Name,omitempty"`

// Tags AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-amazonmq-configuration.html#cfn-amazonmq-configuration-tags
Tags []AWSAmazonMQConfiguration_TagsEntry `json:"Tags,omitempty"`

// _deletionPolicy represents a CloudFormation DeletionPolicy
_deletionPolicy DeletionPolicy

Expand Down Expand Up @@ -109,7 +115,11 @@ func (r *AWSAmazonMQConfiguration) UnmarshalJSON(b []byte) error {
DependsOn []string
Metadata map[string]interface{}
}{}
if err := json.Unmarshal(b, &res); err != nil {

dec := json.NewDecoder(bytes.NewReader(b))
dec.DisallowUnknownFields() // Force error if unknown field is found

if err := dec.Decode(&res); err != nil {
fmt.Printf("ERROR: %s\n", err)
return err
}
Expand All @@ -129,11 +139,13 @@ func (r *AWSAmazonMQConfiguration) UnmarshalJSON(b []byte) error {
}

// GetAllAWSAmazonMQConfigurationResources retrieves all AWSAmazonMQConfiguration items from an AWS CloudFormation template
func (t *Template) GetAllAWSAmazonMQConfigurationResources() map[string]AWSAmazonMQConfiguration {
results := map[string]AWSAmazonMQConfiguration{}
func (t *Template) GetAllAWSAmazonMQConfigurationResources() map[string]*AWSAmazonMQConfiguration {
results := map[string]*AWSAmazonMQConfiguration{}
for name, untyped := range t.Resources {
switch resource := untyped.(type) {
case AWSAmazonMQConfiguration:
results[name] = &resource
case *AWSAmazonMQConfiguration:
// We found a strongly typed resource of the correct type; use it
results[name] = resource
case map[string]interface{}:
Expand All @@ -145,7 +157,8 @@ func (t *Template) GetAllAWSAmazonMQConfigurationResources() map[string]AWSAmazo
if b, err := json.Marshal(resource); err == nil {
var result AWSAmazonMQConfiguration
if err := json.Unmarshal(b, &result); err == nil {
results[name] = result
t.Resources[name] = &result
results[name] = &result
}
}
}
Expand All @@ -157,10 +170,12 @@ func (t *Template) GetAllAWSAmazonMQConfigurationResources() map[string]AWSAmazo

// GetAWSAmazonMQConfigurationWithName retrieves all AWSAmazonMQConfiguration items from an AWS CloudFormation template
// whose logical ID matches the provided name. Returns an error if not found.
func (t *Template) GetAWSAmazonMQConfigurationWithName(name string) (AWSAmazonMQConfiguration, error) {
func (t *Template) GetAWSAmazonMQConfigurationWithName(name string) (*AWSAmazonMQConfiguration, error) {
if untyped, ok := t.Resources[name]; ok {
switch resource := untyped.(type) {
case AWSAmazonMQConfiguration:
return &resource, nil
case *AWSAmazonMQConfiguration:
// We found a strongly typed resource of the correct type; use it
return resource, nil
case map[string]interface{}:
Expand All @@ -172,12 +187,13 @@ func (t *Template) GetAWSAmazonMQConfigurationWithName(name string) (AWSAmazonMQ
if b, err := json.Marshal(resource); err == nil {
var result AWSAmazonMQConfiguration
if err := json.Unmarshal(b, &result); err == nil {
return result, nil
t.Resources[name] = &result
return &result, nil
}
}
}
}
}
}
return AWSAmazonMQConfiguration{}, errors.New("resource not found")
return nil, errors.New("resource not found")
}
60 changes: 60 additions & 0 deletions cloudformation/aws-amazonmq-configuration_tagsentry.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package cloudformation

// AWSAmazonMQConfiguration_TagsEntry AWS CloudFormation Resource (AWS::AmazonMQ::Configuration.TagsEntry)
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-amazonmq-configuration-tagsentry.html
type AWSAmazonMQConfiguration_TagsEntry struct {

// Key AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-amazonmq-configuration-tagsentry.html#cfn-amazonmq-configuration-tagsentry-key
Key string `json:"Key,omitempty"`

// Value AWS CloudFormation Property
// Required: true
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-amazonmq-configuration-tagsentry.html#cfn-amazonmq-configuration-tagsentry-value
Value string `json:"Value,omitempty"`

// _deletionPolicy represents a CloudFormation DeletionPolicy
_deletionPolicy DeletionPolicy

// _dependsOn stores the logical ID of the resources to be created before this resource
_dependsOn []string

// _metadata stores structured data associated with this resource
_metadata map[string]interface{}
}

// AWSCloudFormationType returns the AWS CloudFormation resource type
func (r *AWSAmazonMQConfiguration_TagsEntry) AWSCloudFormationType() string {
return "AWS::AmazonMQ::Configuration.TagsEntry"
}

// DependsOn returns a slice of logical ID names this resource depends on.
// see: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-dependson.html
func (r *AWSAmazonMQConfiguration_TagsEntry) DependsOn() []string {
return r._dependsOn
}

// SetDependsOn specify that the creation of this resource follows another.
// see: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-dependson.html
func (r *AWSAmazonMQConfiguration_TagsEntry) SetDependsOn(dependencies []string) {
r._dependsOn = dependencies
}

// Metadata returns the metadata associated with this resource.
// see: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-metadata.html
func (r *AWSAmazonMQConfiguration_TagsEntry) Metadata() map[string]interface{} {
return r._metadata
}

// SetMetadata enables you to associate structured data with this resource.
// see: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-metadata.html
func (r *AWSAmazonMQConfiguration_TagsEntry) SetMetadata(metadata map[string]interface{}) {
r._metadata = metadata
}

// SetDeletionPolicy applies an AWS CloudFormation DeletionPolicy to this resource
// see: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html
func (r *AWSAmazonMQConfiguration_TagsEntry) SetDeletionPolicy(policy DeletionPolicy) {
r._deletionPolicy = policy
}
Loading

0 comments on commit 197bd11

Please sign in to comment.