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

Add support for Template Outputs #291

Merged
merged 5 commits into from
Jul 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 29 additions & 17 deletions cloudformation/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,44 @@ type Template struct {
Transform *Transform `json:"Transform,omitempty"`
Description string `json:"Description,omitempty"`
Metadata map[string]interface{} `json:"Metadata,omitempty"`
Parameters map[string]interface{} `json:"Parameters,omitempty"`
Parameters Parameters `json:"Parameters,omitempty"`
Mappings map[string]interface{} `json:"Mappings,omitempty"`
Conditions map[string]interface{} `json:"Conditions,omitempty"`
Resources Resources `json:"Resources,omitempty"`
Outputs map[string]interface{} `json:"Outputs,omitempty"`
Outputs Outputs `json:"Outputs,omitempty"`
}

type Parameter struct {
Type string `json:"Type"`
Description string `json:"Description,omitempty"`
Default string `json:"Default,omitempty"`
AllowedPattern string `json:"AllowedPattern,omitempty"`
AllowedValues []string `json:"AllowedValues,omitempty"`
ConstraintDescription string `json:"ConstraintDescription,omitempty"`
MaxLength int `json:"MaxLength,omitempty"`
MinLength int `json:"MinLength,omitempty"`
MaxValue float64 `json:"MaxValue,omitempty"`
MinValue float64 `json:"MinValue,omitempty"`
NoEcho bool `json:"NoEcho,omitempty"`
Type string `json:"Type"`
Description string `json:"Description,omitempty"`
Default interface{} `json:"Default,omitempty"`
Copy link
Contributor Author

@xrn xrn Jul 24, 2020

Choose a reason for hiding this comment

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

FYI - Default has to be changed to Interface from string because Parameter could take different types like string, number, array - there can be for example:

Parameters:
TimeoutParam:
Type: Number
Default: 10

AllowedPattern string `json:"AllowedPattern,omitempty"`
AllowedValues []string `json:"AllowedValues,omitempty"`
ConstraintDescription string `json:"ConstraintDescription,omitempty"`
MaxLength int `json:"MaxLength,omitempty"`
MinLength int `json:"MinLength,omitempty"`
MaxValue float64 `json:"MaxValue,omitempty"`
MinValue float64 `json:"MinValue,omitempty"`
NoEcho bool `json:"NoEcho,omitempty"`
}

type Output struct {
Value interface{} `json:"Value"`
Description string `json:"Description,omitempty"`
Export Export `json:"Export,omitempty"`
}

type Export struct {
Name string `json:"Name,omitempty"`
}

type Resource interface {
AWSCloudFormationType() string
}

type Parameters map[string]Parameter
type Resources map[string]Resource
type Outputs map[string]Output

func (resources *Resources) UnmarshalJSON(b []byte) error {
// Resources
Expand Down Expand Up @@ -139,8 +151,8 @@ func (t *Transform) UnmarshalJSON(b []byte) error {
var strslice []string
for _, i := range val {
switch str := i.(type) {
case string:
strslice = append(strslice, str)
case string:
strslice = append(strslice, str)
}
}
t.StringArray = &strslice
Expand All @@ -155,11 +167,11 @@ func NewTemplate() *Template {
AWSTemplateFormatVersion: "2010-09-09",
Description: "",
Metadata: map[string]interface{}{},
Parameters: map[string]interface{}{},
Parameters: Parameters{},
Mappings: map[string]interface{}{},
Conditions: map[string]interface{}{},
Resources: Resources{},
Outputs: map[string]interface{}{},
Outputs: Outputs{},
}
}

Expand Down