Skip to content
Permalink
Browse files

fix regression that caused outputs to stop generating (#140)

* fix regression that caused outputs to stop generating

* updated test
  • Loading branch information...
ojkelly committed Feb 13, 2019
1 parent d6e62ba commit a6f60d5178ed7b16539e2da68afb3dec295a67e6
Showing with 245 additions and 22 deletions.
  1. +1 −8 internal/cloudformation/template.go
  2. +235 −8 internal/cloudformation/template_parsers_test.go
  3. +9 −6 internal/tasks/upsert.go
@@ -177,14 +177,6 @@ func processParsers(
resources,
types.TemplateObject{templateResourceName: templateResource},
)
} else if strings.HasPrefix(templateResource.Type, "AWS::") {
resources = mergeTemplatesWithError(
templateResourceName,
"aws-resource",
templateResource.Type,
resources,
types.TemplateObject{templateResourceName: templateResource},
)
} else { // This is a resource
// Check if there is a parser for this resource
parser, ok := parserFuncs[templateResource.Type]
@@ -198,6 +190,7 @@ func processParsers(
resources,
types.TemplateObject{templateResourceName: templateResource},
)

continue
}

@@ -14,12 +14,10 @@ import (

var testYaml = `AWSTemplateFormatVersion: "2010-09-09"
Description: A Demo Template for testing Kombustion
Parameters:
Environment:
Type: String
Default: UnknownEnvironment
Resources:
MyDemoLogGroup:
Type: "AWS::Logs::LogGroup"
@@ -60,17 +58,232 @@ func TestGenerateYamlTemplate(t *testing.T) {
ObjectStore: objectStore,
Filename: "test.yaml",
},
output: YamlCloudformation{AWSTemplateFormatVersion: "2010-09-09", Description: "A Demo Template for testing Kombustion", Metadata: types.TemplateObject{}, Parameters: types.TemplateObject{"Environment": map[interface{}]interface{}{"Type": "String", "Default": "UnknownEnvironment"}}, Mappings: types.TemplateObject{}, Conditions: types.TemplateObject{}, Transform: types.TemplateObject{}, Resources: types.TemplateObject{"MyDemoLogGroup4": types.CfResource{Type: "AWS::Logs::LogGroup", Properties: map[interface{}]interface{}{"LogGroupName": map[string]interface{}{"Fn::Join": []interface{}{"-", []interface{}{"MyDemoLogGroup4", map[string]interface{}{"Ref": "Environment"}}}}, "RetentionInDays": 1}, Condition: interface{}(nil), Metadata: interface{}(nil), DependsOn: interface{}(nil), CreationPolicy: interface{}(nil), UpdatePolicy: interface{}(nil), DeletionPolicy: interface{}(nil)}, "MyDemoLogGroup": types.CfResource{Type: "AWS::Logs::LogGroup", Properties: map[interface{}]interface{}{"LogGroupName": map[string]interface{}{"Fn::Join": []interface{}{"-", []interface{}{"MyDemoLogGroup1", map[string]interface{}{"Ref": "Environment"}}}}, "RetentionInDays": 1}, Condition: interface{}(nil), Metadata: interface{}(nil), DependsOn: interface{}(nil), CreationPolicy: interface{}(nil), UpdatePolicy: interface{}(nil), DeletionPolicy: interface{}(nil)}, "MyDemoLogGroup2": types.CfResource{Type: "AWS::Logs::LogGroup", Properties: map[interface{}]interface{}{"RetentionInDays": 1, "LogGroupName": map[string]interface{}{"Fn::Join": []interface{}{"-", []interface{}{"MyDemoLogGroup2", map[string]interface{}{"Ref": "Environment"}}}}}, Condition: interface{}(nil), Metadata: interface{}(nil), DependsOn: interface{}(nil), CreationPolicy: interface{}(nil), UpdatePolicy: interface{}(nil), DeletionPolicy: interface{}(nil)}, "MyDemoLogGroup3": types.CfResource{Type: "AWS::Logs::LogGroup", Properties: map[interface{}]interface{}{"LogGroupName": map[string]interface{}{"Fn::Join": []interface{}{"-", []interface{}{"MyDemoLogGroup3", map[string]interface{}{"Ref": "Environment"}}}}, "RetentionInDays": 1}, Condition: interface{}(nil), Metadata: interface{}(nil), DependsOn: interface{}(nil), CreationPolicy: interface{}(nil), UpdatePolicy: interface{}(nil), DeletionPolicy: interface{}(nil)}}, Outputs: types.TemplateObject{}},
err: nil,
output: YamlCloudformation{
AWSTemplateFormatVersion: "2010-09-09",
Description: "A Demo Template for testing Kombustion",
Metadata: types.TemplateObject{},
Parameters: types.TemplateObject{
"Environment": map[interface{}]interface{}{
"Type": "String",
"Default": "UnknownEnvironment",
},
},
Mappings: types.TemplateObject{},
Conditions: types.TemplateObject{},
Transform: types.TemplateObject{},
Resources: types.TemplateObject{
"MyDemoLogGroup4": resources.LogsLogGroup{
Type: "AWS::Logs::LogGroup",
Properties: resources.LogsLogGroupProperties{
LogGroupName: map[interface{}]interface{}{
"Fn::Join": []interface{}{
"-",
[]interface{}{
"MyDemoLogGroup4",
map[interface{}]interface{}{
"Ref": "Environment",
},
},
},
},
RetentionInDays: 1,
},
Condition: interface{}(nil),
Metadata: interface{}(nil),
DependsOn: interface{}(nil)},
"MyDemoLogGroup": resources.LogsLogGroup{
Type: "AWS::Logs::LogGroup",
Properties: resources.LogsLogGroupProperties{
LogGroupName: map[interface{}]interface{}{
"Fn::Join": []interface{}{
"-", []interface{}{
"MyDemoLogGroup1",
map[interface{}]interface{}{
"Ref": "Environment",
},
},
},
},
RetentionInDays: 1,
},
Condition: interface{}(nil),
Metadata: interface{}(nil),
DependsOn: interface{}(nil)}, "MyDemoLogGroup2": resources.LogsLogGroup{
Type: "AWS::Logs::LogGroup", Properties: resources.LogsLogGroupProperties{
LogGroupName: map[interface{}]interface{}{
"Fn::Join": []interface{}{
"-", []interface{}{
"MyDemoLogGroup2",
map[interface{}]interface{}{
"Ref": "Environment",
},
},
},
},
RetentionInDays: 1,
},
Condition: interface{}(nil),
Metadata: interface{}(nil),
DependsOn: interface{}(nil)}, "MyDemoLogGroup3": resources.LogsLogGroup{
Type: "AWS::Logs::LogGroup",
Properties: resources.LogsLogGroupProperties{
LogGroupName: map[interface{}]interface{}{
"Fn::Join": []interface{}{
"-",
[]interface{}{
"MyDemoLogGroup3",
map[interface{}]interface{}{
"Ref": "Environment",
},
},
},
},
RetentionInDays: 1,
},
Condition: interface{}(nil),
Metadata: interface{}(nil),
DependsOn: interface{}(nil),
},
},
Outputs: types.TemplateObject{},
},
err: nil,
},
{
input: GenerateParams{
ObjectStore: objectStore,
Filename: "test.yaml",
GenerateDefaultOutputs: true,
},
output: YamlCloudformation{AWSTemplateFormatVersion: "2010-09-09", Description: "A Demo Template for testing Kombustion", Metadata: types.TemplateObject{}, Parameters: types.TemplateObject{"Environment": map[interface{}]interface{}{"Default": "UnknownEnvironment", "Type": "String"}}, Mappings: types.TemplateObject{}, Conditions: types.TemplateObject{}, Transform: types.TemplateObject{}, Resources: types.TemplateObject{"MyDemoLogGroup4": types.CfResource{Type: "AWS::Logs::LogGroup", Properties: map[interface{}]interface{}{"LogGroupName": map[string]interface{}{"Fn::Join": []interface{}{"-", []interface{}{"MyDemoLogGroup4", map[string]interface{}{"Ref": "Environment"}}}}, "RetentionInDays": 1}, Condition: interface{}(nil), Metadata: interface{}(nil), DependsOn: interface{}(nil), CreationPolicy: interface{}(nil), UpdatePolicy: interface{}(nil), DeletionPolicy: interface{}(nil)}, "MyDemoLogGroup": types.CfResource{Type: "AWS::Logs::LogGroup", Properties: map[interface{}]interface{}{"LogGroupName": map[string]interface{}{"Fn::Join": []interface{}{"-", []interface{}{"MyDemoLogGroup1", map[string]interface{}{"Ref": "Environment"}}}}, "RetentionInDays": 1}, Condition: interface{}(nil), Metadata: interface{}(nil), DependsOn: interface{}(nil), CreationPolicy: interface{}(nil), UpdatePolicy: interface{}(nil), DeletionPolicy: interface{}(nil)}, "MyDemoLogGroup2": types.CfResource{Type: "AWS::Logs::LogGroup", Properties: map[interface{}]interface{}{"LogGroupName": map[string]interface{}{"Fn::Join": []interface{}{"-", []interface{}{"MyDemoLogGroup2", map[string]interface{}{"Ref": "Environment"}}}}, "RetentionInDays": 1}, Condition: interface{}(nil), Metadata: interface{}(nil), DependsOn: interface{}(nil), CreationPolicy: interface{}(nil), UpdatePolicy: interface{}(nil), DeletionPolicy: interface{}(nil)}, "MyDemoLogGroup3": types.CfResource{Type: "AWS::Logs::LogGroup", Properties: map[interface{}]interface{}{"LogGroupName": map[string]interface{}{"Fn::Join": []interface{}{"-", []interface{}{"MyDemoLogGroup3", map[string]interface{}{"Ref": "Environment"}}}}, "RetentionInDays": 1}, Condition: interface{}(nil), Metadata: interface{}(nil), DependsOn: interface{}(nil), CreationPolicy: interface{}(nil), UpdatePolicy: interface{}(nil), DeletionPolicy: interface{}(nil)}}, Outputs: types.TemplateObject{}},
err: nil,
output: YamlCloudformation{
AWSTemplateFormatVersion: "2010-09-09",
Description: "A Demo Template for testing Kombustion",
Metadata: types.TemplateObject{},
Parameters: types.TemplateObject{
"Environment": map[interface{}]interface{}{
"Type": "String", "Default": "UnknownEnvironment",
},
},
Mappings: types.TemplateObject{},
Conditions: types.TemplateObject{},
Transform: types.TemplateObject{},
Resources: types.TemplateObject{
"MyDemoLogGroup2": resources.LogsLogGroup{
Type: "AWS::Logs::LogGroup",
Properties: resources.LogsLogGroupProperties{
LogGroupName: map[interface{}]interface{}{
"Fn::Join": []interface{}{"-", []interface{}{
"MyDemoLogGroup2", map[interface{}]interface{}{
"Ref": "Environment",
},
},
},
},
RetentionInDays: 1,
},
Condition: interface{}(nil),
Metadata: interface{}(nil),
DependsOn: interface{}(nil),
},
"MyDemoLogGroup3": resources.LogsLogGroup{
Type: "AWS::Logs::LogGroup",
Properties: resources.LogsLogGroupProperties{
LogGroupName: map[interface{}]interface{}{
"Fn::Join": []interface{}{"-", []interface{}{
"MyDemoLogGroup3",
map[interface{}]interface{}{
"Ref": "Environment",
},
},
},
},
RetentionInDays: 1,
},
Condition: interface{}(nil),
Metadata: interface{}(nil),
DependsOn: interface{}(nil),
},
"MyDemoLogGroup4": resources.LogsLogGroup{
Type: "AWS::Logs::LogGroup",
Properties: resources.LogsLogGroupProperties{
LogGroupName: map[interface{}]interface{}{
"Fn::Join": []interface{}{
"-",
[]interface{}{
"MyDemoLogGroup4",
map[interface{}]interface{}{"Ref": "Environment"},
},
},
},
RetentionInDays: 1,
},
Condition: interface{}(nil),
Metadata: interface{}(nil),
DependsOn: interface{}(nil)},
"MyDemoLogGroup": resources.LogsLogGroup{
Type: "AWS::Logs::LogGroup",
Properties: resources.LogsLogGroupProperties{
LogGroupName: map[interface{}]interface{}{
"Fn::Join": []interface{}{"-",
[]interface{}{"MyDemoLogGroup1",
map[interface{}]interface{}{"Ref": "Environment"},
},
},
},
RetentionInDays: 1,
},
Condition: interface{}(nil),
Metadata: interface{}(nil),
DependsOn: interface{}(nil),
},
},
Outputs: types.TemplateObject{
"MyDemoLogGroup2": types.TemplateObject{
"Description": "MyDemoLogGroup2 Object",
"Value": map[string]interface{}{
"Ref": "MyDemoLogGroup2",
},
"Export": map[string]interface{}{
"Name": map[string]interface{}{
"Fn::Sub": "${AWS::StackName}-LogsLogGroup-MyDemoLogGroup2",
},
},
},
"MyDemoLogGroup3": types.TemplateObject{
"Description": "MyDemoLogGroup3 Object",
"Value": map[string]interface{}{
"Ref": "MyDemoLogGroup3",
},
"Export": map[string]interface{}{
"Name": map[string]interface{}{
"Fn::Sub": "${AWS::StackName}-LogsLogGroup-MyDemoLogGroup3",
},
},
},
"MyDemoLogGroup4": types.TemplateObject{
"Export": map[string]interface{}{
"Name": map[string]interface{}{
"Fn::Sub": "${AWS::StackName}-LogsLogGroup-MyDemoLogGroup4",
},
}, "Description": "MyDemoLogGroup4 Object",
"Value": map[string]interface{}{
"Ref": "MyDemoLogGroup4",
},
},
"MyDemoLogGroup": types.TemplateObject{
"Description": "MyDemoLogGroup Object",
"Value": map[string]interface{}{
"Ref": "MyDemoLogGroup",
},
"Export": map[string]interface{}{
"Name": map[string]interface{}{
"Fn::Sub": "${AWS::StackName}-LogsLogGroup-MyDemoLogGroup",
},
},
},
},
},
err: nil,
},
}

@@ -146,8 +359,22 @@ func TestProcessParsers(t *testing.T) {
mappings: types.TemplateObject{},
outputs: types.TemplateObject{},
parameters: types.TemplateObject{},
resources: types.TemplateObject{"Test": types.CfResource{Type: "AWS::Logs::LogsGroup", Properties: map[string]interface{}{"LogGroupName": "TestLogGroup"}, Condition: map[string]interface{}{"ConditionName": "ConditionValue"}, Metadata: map[string]interface{}{"MetadataName": "MetadataValue"}, DependsOn: []interface{}{"OtherResource"}, CreationPolicy: interface{}(nil), UpdatePolicy: interface{}(nil), DeletionPolicy: interface{}(nil)}},
transform: types.TemplateObject{},
resources: types.TemplateObject{
"Test": resources.LogsLogGroup{
Type: "AWS::Logs::LogsGroup",
Properties: resources.LogsLogGroupProperties{
LogGroupName: "TestLogGroup",
RetentionInDays: interface{}(nil)},
Condition: map[interface{}]interface{}{
"ConditionName": "ConditionValue",
},
Metadata: map[interface{}]interface{}{
"MetadataName": "MetadataValue",
},
DependsOn: []interface{}{"OtherResource"},
},
},
transform: types.TemplateObject{},
},
},
{
@@ -3,16 +3,17 @@ package tasks
import (
"fmt"

"github.com/aws/aws-sdk-go/aws"
awsCF "github.com/aws/aws-sdk-go/service/cloudformation"
"github.com/urfave/cli"

printer "github.com/KablamoOSS/go-cli-printer"
"github.com/KablamoOSS/kombustion/internal/cloudformation"
"github.com/KablamoOSS/kombustion/internal/cloudformation/tasks"
"github.com/KablamoOSS/kombustion/internal/core"
"github.com/KablamoOSS/kombustion/internal/manifest"
"github.com/KablamoOSS/kombustion/internal/plugins"
"github.com/KablamoOSS/kombustion/internal/plugins/lock"
"github.com/aws/aws-sdk-go/aws"
awsCF "github.com/aws/aws-sdk-go/service/cloudformation"
"github.com/urfave/cli"
)

// UpsertFlags for kombustion upsert
@@ -192,14 +193,16 @@ func upsert(
printer.Progress("Generating template")
// Template generation parameters
generateParams := cloudformation.GenerateParams{
ObjectStore: objectStore,
Filename: templatePath,
Env: envName,
ObjectStore: objectStore,
Filename: templatePath,
Env: envName,
GenerateDefaultOutputs: generateDefaultOutputs || manifestFile.GenerateDefaultOutputs,
ParamMap: paramMap,
Plugins: loadedPlugins,
}

printer.Stepf("Generate Default Outputs: %t", generateParams.GenerateDefaultOutputs)

// CloudFormation Stack parameters
var parameters []*awsCF.Parameter

0 comments on commit a6f60d5

Please sign in to comment.
You can’t perform that action at this time.