Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some more goldenfile tests #614

Merged
merged 9 commits into from
Oct 31, 2023
Merged
37 changes: 21 additions & 16 deletions aws/fake/cf.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,28 @@ type CFOutputs struct {

type CFClient struct {
cloudformationiface.CloudFormationAPI
lastStackTemplate string
lastStackParams []*cloudformation.Parameter
lastStackTags []*cloudformation.Tag
Outputs CFOutputs
templateCreationHistory []string
paramCreationHistory [][]*cloudformation.Parameter
tagCreationHistory [][]*cloudformation.Tag
Outputs CFOutputs
}

func (m *CFClient) GetLastStackTemplate() string {
return m.lastStackTemplate
func (m *CFClient) GetTemplateCreationHistory() []string {
return m.templateCreationHistory
}

func (m *CFClient) GetLastStackParams() []*cloudformation.Parameter {
return m.lastStackParams
func (m *CFClient) GetParamCreationHistory() [][]*cloudformation.Parameter {
return m.paramCreationHistory
}

func (m *CFClient) GetLastStackTags() []*cloudformation.Tag {
return m.lastStackTags
func (m *CFClient) GetTagCreationHistory() [][]*cloudformation.Tag {
return m.tagCreationHistory
}

func (m *CFClient) CleanCreationHistory() {
m.paramCreationHistory = [][]*cloudformation.Parameter{}
m.tagCreationHistory = [][]*cloudformation.Tag{}
m.templateCreationHistory = []string{}
}

func (m *CFClient) DescribeStacksPages(in *cloudformation.DescribeStacksInput, fn func(*cloudformation.DescribeStacksOutput, bool) bool) (err error) {
Expand Down Expand Up @@ -62,9 +68,9 @@ func (m *CFClient) DescribeStacks(in *cloudformation.DescribeStacksInput) (*clou
}

func (m *CFClient) CreateStack(params *cloudformation.CreateStackInput) (*cloudformation.CreateStackOutput, error) {
m.lastStackTags = params.Tags
m.lastStackParams = params.Parameters
m.lastStackTemplate = *params.TemplateBody
m.tagCreationHistory = append(m.tagCreationHistory, params.Tags)
m.paramCreationHistory = append(m.paramCreationHistory, params.Parameters)
m.templateCreationHistory = append(m.templateCreationHistory, *params.TemplateBody)

out, ok := m.Outputs.CreateStack.response.(*cloudformation.CreateStackOutput)
if !ok {
Expand All @@ -80,9 +86,8 @@ func MockCSOutput(stackId string) *cloudformation.CreateStackOutput {
}

func (m *CFClient) UpdateStack(params *cloudformation.UpdateStackInput) (*cloudformation.UpdateStackOutput, error) {
m.lastStackTags = params.Tags
m.lastStackParams = params.Parameters
m.lastStackTemplate = *params.TemplateBody
// TODO: Update stack needs another logic to register state update, so createStack and updateStack don't
// mess with each other states.
lucastt marked this conversation as resolved.
Show resolved Hide resolved

out, ok := m.Outputs.UpdateStack.response.(*cloudformation.UpdateStackOutput)
if !ok {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ spec:
port:
name: main-port
path: /
pathType: ImplementationSpecific
pathType: ImplementationSpecific
16 changes: 16 additions & 0 deletions testdata/ingress_rg_notshared_alb/input/k8s/01-ing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: myingress
lucastt marked this conversation as resolved.
Show resolved Hide resolved
spec:
rules:
- host: foo.bar.org
http:
paths:
- backend:
service:
name: foo-bar-service
port:
name: main-port
path: /
pathType: ImplementationSpecific
18 changes: 18 additions & 0 deletions testdata/ingress_rg_notshared_alb/input/k8s/02-rg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: zalando.org/v1
kind: RouteGroup
metadata:
name: my-route-group
annotations:
zalando.org/aws-load-balancer-shared: "false"
spec:
hosts:
- foo.bar.org
backends:
- name: my-backend
type: service
serviceName: my-service
servicePort: 80
routes:
- pathSubtree: /
backends:
- backendName: my-backend
54 changes: 54 additions & 0 deletions testdata/ingress_rg_notshared_alb/output/params/01-ing.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[
{
"parameterKey": "LoadBalancerSchemeParameter",
"parameterValue": "internet-facing"
},
{
"parameterKey": "LoadBalancerSecurityGroupParameter",
"parameterValue": "42"
},
{
"parameterKey": "LoadBalancerSubnetsParameter",
"parameterValue": "foo1"
},
{
"parameterKey": "TargetGroupVPCIDParameter",
"parameterValue": "1"
},
{
"parameterKey": "TargetGroupTargetPortParameter",
"parameterValue": "0"
},
{
"parameterKey": "ListenerSslPolicyParameter",
"parameterValue": "ELBSecurityPolicy-2016-08"
},
{
"parameterKey": "IpAddressType",
"parameterValue": "ipv4"
},
{
"parameterKey": "Type",
"parameterValue": "application"
},
{
"parameterKey": "HTTP2",
"parameterValue": "true"
},
{
"parameterKey": "TargetGroupHealthCheckPathParameter",
"parameterValue": ""
},
{
"parameterKey": "TargetGroupHealthCheckPortParameter",
"parameterValue": "0"
},
{
"parameterKey": "TargetGroupHealthCheckIntervalParameter",
"parameterValue": "0"
},
{
"parameterKey": "TargetGroupHealthCheckTimeoutParameter",
"parameterValue": "0"
}
]
54 changes: 54 additions & 0 deletions testdata/ingress_rg_notshared_alb/output/params/02-rg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[
{
"parameterKey": "LoadBalancerSchemeParameter",
"parameterValue": "internet-facing"
},
{
"parameterKey": "LoadBalancerSecurityGroupParameter",
"parameterValue": "42"
},
{
"parameterKey": "LoadBalancerSubnetsParameter",
"parameterValue": "foo1"
},
{
"parameterKey": "TargetGroupVPCIDParameter",
"parameterValue": "1"
},
{
"parameterKey": "TargetGroupTargetPortParameter",
"parameterValue": "0"
},
{
"parameterKey": "ListenerSslPolicyParameter",
"parameterValue": "ELBSecurityPolicy-2016-08"
},
{
"parameterKey": "IpAddressType",
"parameterValue": "ipv4"
},
{
"parameterKey": "Type",
"parameterValue": "application"
},
{
"parameterKey": "HTTP2",
"parameterValue": "true"
},
{
"parameterKey": "TargetGroupHealthCheckPathParameter",
"parameterValue": ""
},
{
"parameterKey": "TargetGroupHealthCheckPortParameter",
"parameterValue": "0"
},
{
"parameterKey": "TargetGroupHealthCheckIntervalParameter",
"parameterValue": "0"
},
{
"parameterKey": "TargetGroupHealthCheckTimeoutParameter",
"parameterValue": "0"
}
]
12 changes: 12 additions & 0 deletions testdata/ingress_rg_notshared_alb/output/tags/01-ing.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"key": "kubernetes:application",
"value": ""
},{
"key": "kubernetes.io/cluster/aws:123:eu-central-1:kube-1",
"value": "owned"
},{
"key": "ingress:certificate-arn/DUMMY",
"value": "0001-01-01T00:00:00Z"
}
]
15 changes: 15 additions & 0 deletions testdata/ingress_rg_notshared_alb/output/tags/02-rg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[
{
"key": "kubernetes:application",
"value": ""
},{
"key": "kubernetes.io/cluster/aws:123:eu-central-1:kube-1",
"value": "owned"
},{
"key": "ingress:certificate-arn/DUMMY",
"value": "0001-01-01T00:00:00Z"
},{
"key": "ingress:owner",
"value": "/my-route-group"
}
]
Loading
Loading