Skip to content

Commit

Permalink
Fix method conflicts (awslabs#245)
Browse files Browse the repository at this point in the history
* fix(schema): Refactor DependsOn, Metadata & Policies

BREAKING CHANGE:
This change refactors the DependsOn, Metadata, CreationPolicy,
UpdatePolicy and DeletionPolicy methods on each resource to a new
name. This is required, as some CloudFormation resources use these
keywords as properties (AWS::AppMesh::Route.GrpcRouteMatch has a
Metadata field for example), which causes a conflict.

`resource.DependsOn()` method is refactored to `resource.AWSCloudFormationDependsOn` field.
`resource.SetDependsOn()` method is refactored to `resource.AWSCloudFormationDependsOn` field.
`resource.Metadata()` method is refactored to `resource.AWSCloudFormationMetadata` field.
`resource.SetMetadata()` method is refactored to `resource.AWSCloudFormationMetadata` field.
`resource.CreationPolicy()` method is refactored to `resource.AWSCloudFormationCreationPolicy` field.
`resource.SetCreationPolicy()` method is refactored to `resource.AWSCloudFormationCreationPolicy` field.
`resource.UpdatePolicy()` method is refactored to `resource.AWSCloudFormationUpdatePolicy` field.
`resource.SetUpdatePolicy()` method is refactored to `resource.AWSCloudFormationUpdatePolicy` field.
`resource.DeletionPolicy()` method is refactored to `resource.AWSCloudFormationDeletionPolicy` field.
`resource.SetDeletionPolicy()` method is refactored to `resource.AWSCloudFormationDeletionPolicy` field.

Fixes awslabs#241

* feat(schema): Latest CloudFormation Updates

This commit also bumps the module version to v4 to anticipate the
release of the DependsOn etc refactor that has breaking changes (see
issue awslabs#294)
  • Loading branch information
PaulMaddox authored Nov 30, 2019
1 parent 4859f00 commit d0b0a8b
Show file tree
Hide file tree
Showing 1,808 changed files with 42,406 additions and 74,708 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ topic := &resources.AWSSNSTopic{}
New usage:

```go
import "github.com/awslabs/goformation/v3/cloudformation/sns"
import "github.com/awslabs/goformation/v4/cloudformation/sns"

...snip...

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
As with other Go libraries, GoFormation can be installed with `go get`.

```
$ go get github.com/awslabs/goformation/v3
$ go get github.com/awslabs/goformation/v4
```

## Usage
Expand All @@ -45,8 +45,8 @@ import (
"strconv"
"time"

"github.com/awslabs/goformation/v3/cloudformation"
"github.com/awslabs/goformation/v3/cloudformation/sns"
"github.com/awslabs/goformation/v4/cloudformation"
"github.com/awslabs/goformation/v4/cloudformation/sns"


)
Expand Down Expand Up @@ -160,7 +160,7 @@ package main
import (
"log"
"github.com/awslabs/goformation/v3"
"github.com/awslabs/goformation/v4"
)
func main() {
Expand Down
728 changes: 628 additions & 100 deletions cloudformation/all.go

Large diffs are not rendered by default.

67 changes: 18 additions & 49 deletions cloudformation/amazonmq/aws-amazonmq-broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"encoding/json"
"fmt"

"github.com/awslabs/goformation/v3/cloudformation/policies"
"github.com/awslabs/goformation/v4/cloudformation/policies"
)

// Broker AWS CloudFormation Resource (AWS::AmazonMQ::Broker)
Expand Down Expand Up @@ -72,6 +72,11 @@ type Broker struct {
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-amazonmq-broker.html#cfn-amazonmq-broker-securitygroups
SecurityGroups []string `json:"SecurityGroups,omitempty"`

// StorageType AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-amazonmq-broker.html#cfn-amazonmq-broker-storagetype
StorageType string `json:"StorageType,omitempty"`

// SubnetIds AWS CloudFormation Property
// Required: false
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-amazonmq-broker.html#cfn-amazonmq-broker-subnetids
Expand All @@ -87,57 +92,21 @@ type Broker struct {
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-amazonmq-broker.html#cfn-amazonmq-broker-users
Users []Broker_User `json:"Users,omitempty"`

// _deletionPolicy represents a CloudFormation DeletionPolicy
_deletionPolicy policies.DeletionPolicy
// AWSCloudFormationDeletionPolicy represents a CloudFormation DeletionPolicy
AWSCloudFormationDeletionPolicy policies.DeletionPolicy `json:"-"`

// _dependsOn stores the logical ID of the resources to be created before this resource
_dependsOn []string
// AWSCloudFormationDependsOn stores the logical ID of the resources to be created before this resource
AWSCloudFormationDependsOn []string `json:"-"`

// _metadata stores structured data associated with this resource
_metadata map[string]interface{}
// AWSCloudFormationMetadata stores structured data associated with this resource
AWSCloudFormationMetadata map[string]interface{} `json:"-"`
}

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

// 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 *Broker) 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 *Broker) 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 *Broker) 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 *Broker) SetMetadata(metadata map[string]interface{}) {
r._metadata = metadata
}

// DeletionPolicy returns the AWS CloudFormation DeletionPolicy to this resource
// see: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html
func (r *Broker) DeletionPolicy() policies.DeletionPolicy {
return r._deletionPolicy
}

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

// MarshalJSON is a custom JSON marshalling hook that embeds this object into
// an AWS CloudFormation JSON resource's 'Properties' field and adds a 'Type'.
func (r Broker) MarshalJSON() ([]byte, error) {
Expand All @@ -151,9 +120,9 @@ func (r Broker) MarshalJSON() ([]byte, error) {
}{
Type: r.AWSCloudFormationType(),
Properties: (Properties)(r),
DependsOn: r._dependsOn,
Metadata: r._metadata,
DeletionPolicy: r._deletionPolicy,
DependsOn: r.AWSCloudFormationDependsOn,
Metadata: r.AWSCloudFormationMetadata,
DeletionPolicy: r.AWSCloudFormationDeletionPolicy,
})
}

Expand Down Expand Up @@ -182,13 +151,13 @@ func (r *Broker) UnmarshalJSON(b []byte) error {
*r = Broker(*res.Properties)
}
if res.DependsOn != nil {
r._dependsOn = res.DependsOn
r.AWSCloudFormationDependsOn = res.DependsOn
}
if res.Metadata != nil {
r._metadata = res.Metadata
r.AWSCloudFormationMetadata = res.Metadata
}
if res.DeletionPolicy != "" {
r._deletionPolicy = policies.DeletionPolicy(res.DeletionPolicy)
r.AWSCloudFormationDeletionPolicy = policies.DeletionPolicy(res.DeletionPolicy)
}
return nil
}
50 changes: 7 additions & 43 deletions cloudformation/amazonmq/aws-amazonmq-broker_configurationid.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package amazonmq

import (
"github.com/awslabs/goformation/v3/cloudformation/policies"
"github.com/awslabs/goformation/v4/cloudformation/policies"
)

// Broker_ConfigurationId AWS CloudFormation Resource (AWS::AmazonMQ::Broker.ConfigurationId)
Expand All @@ -18,53 +18,17 @@ type Broker_ConfigurationId struct {
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-amazonmq-broker-configurationid.html#cfn-amazonmq-broker-configurationid-revision
Revision int `json:"Revision"`

// _deletionPolicy represents a CloudFormation DeletionPolicy
_deletionPolicy policies.DeletionPolicy
// AWSCloudFormationDeletionPolicy represents a CloudFormation DeletionPolicy
AWSCloudFormationDeletionPolicy policies.DeletionPolicy `json:"-"`

// _dependsOn stores the logical ID of the resources to be created before this resource
_dependsOn []string
// AWSCloudFormationDependsOn stores the logical ID of the resources to be created before this resource
AWSCloudFormationDependsOn []string `json:"-"`

// _metadata stores structured data associated with this resource
_metadata map[string]interface{}
// AWSCloudFormationMetadata stores structured data associated with this resource
AWSCloudFormationMetadata map[string]interface{} `json:"-"`
}

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

// 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 *Broker_ConfigurationId) 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 *Broker_ConfigurationId) 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 *Broker_ConfigurationId) 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 *Broker_ConfigurationId) SetMetadata(metadata map[string]interface{}) {
r._metadata = metadata
}

// DeletionPolicy returns the AWS CloudFormation DeletionPolicy to this resource
// see: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html
func (r *Broker_ConfigurationId) DeletionPolicy() policies.DeletionPolicy {
return r._deletionPolicy
}

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

import (
"github.com/awslabs/goformation/v3/cloudformation/policies"
"github.com/awslabs/goformation/v4/cloudformation/policies"
)

// Broker_EncryptionOptions AWS CloudFormation Resource (AWS::AmazonMQ::Broker.EncryptionOptions)
Expand All @@ -18,53 +18,17 @@ type Broker_EncryptionOptions struct {
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-amazonmq-broker-encryptionoptions.html#cfn-amazonmq-broker-encryptionoptions-useawsownedkey
UseAwsOwnedKey bool `json:"UseAwsOwnedKey"`

// _deletionPolicy represents a CloudFormation DeletionPolicy
_deletionPolicy policies.DeletionPolicy
// AWSCloudFormationDeletionPolicy represents a CloudFormation DeletionPolicy
AWSCloudFormationDeletionPolicy policies.DeletionPolicy `json:"-"`

// _dependsOn stores the logical ID of the resources to be created before this resource
_dependsOn []string
// AWSCloudFormationDependsOn stores the logical ID of the resources to be created before this resource
AWSCloudFormationDependsOn []string `json:"-"`

// _metadata stores structured data associated with this resource
_metadata map[string]interface{}
// AWSCloudFormationMetadata stores structured data associated with this resource
AWSCloudFormationMetadata map[string]interface{} `json:"-"`
}

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

// 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 *Broker_EncryptionOptions) 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 *Broker_EncryptionOptions) 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 *Broker_EncryptionOptions) 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 *Broker_EncryptionOptions) SetMetadata(metadata map[string]interface{}) {
r._metadata = metadata
}

// DeletionPolicy returns the AWS CloudFormation DeletionPolicy to this resource
// see: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html
func (r *Broker_EncryptionOptions) DeletionPolicy() policies.DeletionPolicy {
return r._deletionPolicy
}

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

import (
"github.com/awslabs/goformation/v3/cloudformation/policies"
"github.com/awslabs/goformation/v4/cloudformation/policies"
)

// Broker_LogList AWS CloudFormation Resource (AWS::AmazonMQ::Broker.LogList)
Expand All @@ -18,53 +18,17 @@ type Broker_LogList struct {
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-amazonmq-broker-loglist.html#cfn-amazonmq-broker-loglist-general
General bool `json:"General,omitempty"`

// _deletionPolicy represents a CloudFormation DeletionPolicy
_deletionPolicy policies.DeletionPolicy
// AWSCloudFormationDeletionPolicy represents a CloudFormation DeletionPolicy
AWSCloudFormationDeletionPolicy policies.DeletionPolicy `json:"-"`

// _dependsOn stores the logical ID of the resources to be created before this resource
_dependsOn []string
// AWSCloudFormationDependsOn stores the logical ID of the resources to be created before this resource
AWSCloudFormationDependsOn []string `json:"-"`

// _metadata stores structured data associated with this resource
_metadata map[string]interface{}
// AWSCloudFormationMetadata stores structured data associated with this resource
AWSCloudFormationMetadata map[string]interface{} `json:"-"`
}

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

// 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 *Broker_LogList) 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 *Broker_LogList) 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 *Broker_LogList) 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 *Broker_LogList) SetMetadata(metadata map[string]interface{}) {
r._metadata = metadata
}

// DeletionPolicy returns the AWS CloudFormation DeletionPolicy to this resource
// see: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-attribute-deletionpolicy.html
func (r *Broker_LogList) DeletionPolicy() policies.DeletionPolicy {
return r._deletionPolicy
}

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

0 comments on commit d0b0a8b

Please sign in to comment.