Skip to content

Commit

Permalink
Merge pull request #44 from szuecs/gh-action
Browse files Browse the repository at this point in the history
Add github action based build
  • Loading branch information
szuecs authored Jan 19, 2022
2 parents 3933944 + ee44c42 commit 07970e3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: ci
on: [push, pull_request]
jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '^1.17'
- run: make
- run: make test
15 changes: 10 additions & 5 deletions provider/aws/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import (
"github.com/szuecs/kube-static-egress-controller/provider"
)

const (
clusterIDTagPrefix = "kubernetes.io/cluster/"
)

type mockedReceiveMsgs struct {
ec2iface.EC2API
RespVpcs ec2.DescribeVpcsOutput
Expand Down Expand Up @@ -70,7 +74,7 @@ func TestGenerateStackSpec(t *testing.T) {
netA.String(): netA,
},
}
p := NewAWSProvider("cluster-x", "controller-x", true, "", natCidrBlocks, availabilityZones, false, additionalStackTags)
p := NewAWSProvider("cluster-x", "controller-x", true, "", clusterIDTagPrefix, natCidrBlocks, availabilityZones, false, additionalStackTags)
fakeVpcsResp := ec2.DescribeVpcsOutput{
Vpcs: []*ec2.Vpc{
{
Expand Down Expand Up @@ -142,7 +146,7 @@ func TestGenerateTemplate(t *testing.T) {
netA.String(): netA,
},
}
p := NewAWSProvider("cluster-x", "controller-x", true, "", natCidrBlocks, availabilityZones, false, nil)
p := NewAWSProvider("cluster-x", "controller-x", true, "", clusterIDTagPrefix, natCidrBlocks, availabilityZones, false, nil)
expect := `{"AWSTemplateFormatVersion":"2010-09-09","Description":"Static Egress Stack","Parameters":{"AZ1RouteTableIDParameter":{"Type":"String","Description":"Route Table ID No 1"},"InternetGatewayIDParameter":{"Type":"String","Description":"Internet Gateway ID"},"VPCIDParameter":{"Type":"AWS::EC2::VPC::Id","Description":"VPC ID"}},"Resources":{"EIP1":{"Type":"AWS::EC2::EIP","Properties":{"Domain":"vpc"}},"NATGateway1":{"Type":"AWS::EC2::NatGateway","Properties":{"AllocationId":{"Fn::GetAtt":["EIP1","AllocationId"]},"SubnetId":{"Ref":"NATSubnet1"}}},"NATSubnet1":{"Type":"AWS::EC2::Subnet","Properties":{"AvailabilityZone":"eu-central-1a","CidrBlock":"172.31.64.0/28","Tags":[{"Key":"Name","Value":"nat-eu-central-1a"}],"VpcId":{"Ref":"VPCIDParameter"}}},"NATSubnetRoute1":{"Type":"AWS::EC2::Route","Properties":{"DestinationCidrBlock":"0.0.0.0/0","GatewayId":{"Ref":"InternetGatewayIDParameter"},"RouteTableId":{"Ref":"NATSubnetRouteTable1"}}},"NATSubnetRouteTable1":{"Type":"AWS::EC2::RouteTable","Properties":{"VpcId":{"Ref":"VPCIDParameter"},"Tags":[{"Key":"Name","Value":"nat-eu-central-1a"}]}},"NATSubnetRouteTableAssociation1":{"Type":"AWS::EC2::SubnetRouteTableAssociation","Properties":{"RouteTableId":{"Ref":"NATSubnetRouteTable1"},"SubnetId":{"Ref":"NATSubnet1"}}},"RouteToNAT1z213x95x138x236y32":{"Type":"AWS::EC2::Route","Properties":{"DestinationCidrBlock":"213.95.138.236/32","NatGatewayId":{"Ref":"NATGateway1"},"RouteTableId":{"Ref":"AZ1RouteTableIDParameter"}}}},"Outputs":{"EIP1":{"Description":"external IP of the NATGateway1","Value":{"Ref":"EIP1"}}}}`
template := p.generateTemplate(
destinationCidrBlocks,
Expand Down Expand Up @@ -486,9 +490,10 @@ func TestEnsure(tt *testing.T) {
} {
tt.Run(tc.msg, func(t *testing.T) {
provider := &AWSProvider{
clusterID: "cluster-x",
controllerID: "controller-x",
vpcID: "x",
clusterIDTagPrefix: clusterIDTagPrefix,
clusterID: "cluster-x",
controllerID: "controller-x",
vpcID: "x",
natCidrBlocks: []string{
"172.31.64.0/28",
"172.31.64.16/28",
Expand Down

0 comments on commit 07970e3

Please sign in to comment.