diff --git a/pkg/stackit/cfnyaml/cfnyaml.go b/pkg/stackit/cfnyaml/cfnyaml.go index a302204..8dac6c3 100644 --- a/pkg/stackit/cfnyaml/cfnyaml.go +++ b/pkg/stackit/cfnyaml/cfnyaml.go @@ -68,7 +68,7 @@ func (c *CfnYaml) PackageableNodes() ([]PackageableNode, error) { if def := packageableDefinition(resType); def != nil { propNode := valueForKey(valueNode, def.Path...) - if propNode != nil { + if propNode != nil && looksPackageable(propNode, def) { nodes = append(nodes, PackageableNode{ Name: name, Value: propNode.Value, @@ -86,6 +86,11 @@ func (c *CfnYaml) PackageableNodes() ([]PackageableNode, error) { return nodes, nil } +func looksPackageable(n *yaml.Node, def *packageablePropertyDefinition) bool { + // TODO: https://github.com/glassechidna/stackit/issues/34 + return n.Kind == yaml.ScalarNode +} + func packageableDefinition(typ string) *packageablePropertyDefinition { for _, def := range packageablePropertyDefinitions { if def.ResourceType == typ { diff --git a/pkg/stackit/cfnyaml/cfnyaml_test.go b/pkg/stackit/cfnyaml/cfnyaml_test.go index 235070b..6646a33 100644 --- a/pkg/stackit/cfnyaml/cfnyaml_test.go +++ b/pkg/stackit/cfnyaml/cfnyaml_test.go @@ -55,6 +55,11 @@ var tests = []tableTestEntry{ "./stack.yml": {"bucket", "key.yml", "abc"}, }, }, + { + Name: "f", + Explanation: "no-op", + Replacements: map[string]rewrittenLocation{}, + }, } func TestCfnYaml_PackageableNodes(t *testing.T) { diff --git a/pkg/stackit/cfnyaml/testdata/f_expected.yml b/pkg/stackit/cfnyaml/testdata/f_expected.yml new file mode 100644 index 0000000..b23a49c --- /dev/null +++ b/pkg/stackit/cfnyaml/testdata/f_expected.yml @@ -0,0 +1,14 @@ +Transform: AWS::Serverless-2016-10-31 +Resources: + Function: + Type: AWS::Serverless::Function + Properties: + Handler: index.handler + Runtime: nodejs8.10 + MemorySize: 256 + CodeUri: + Bucket: stackit-ap-southeast-2-607481581596 + Key: func.zip + Version: GNz4tYuVVvtLYlE5touSEDnp6keZUIDJ + Timeout: 60 + AutoPublishAlias: live diff --git a/pkg/stackit/cfnyaml/testdata/f_input.yml b/pkg/stackit/cfnyaml/testdata/f_input.yml new file mode 100644 index 0000000..b23a49c --- /dev/null +++ b/pkg/stackit/cfnyaml/testdata/f_input.yml @@ -0,0 +1,14 @@ +Transform: AWS::Serverless-2016-10-31 +Resources: + Function: + Type: AWS::Serverless::Function + Properties: + Handler: index.handler + Runtime: nodejs8.10 + MemorySize: 256 + CodeUri: + Bucket: stackit-ap-southeast-2-607481581596 + Key: func.zip + Version: GNz4tYuVVvtLYlE5touSEDnp6keZUIDJ + Timeout: 60 + AutoPublishAlias: live