Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

Commit

Permalink
Add yamllint and fix issues
Browse files Browse the repository at this point in the history
Fixes #10

Also adds yamllint to `make check` target.

Signed-off-by: Nick Young <ynick@vmware.com>
  • Loading branch information
Nick Young authored and youngnick committed Dec 9, 2019
1 parent 1ca4d16 commit 37dffbc
Show file tree
Hide file tree
Showing 21 changed files with 63 additions and 41 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Check_Targets := \
check-unconvert \
check-ineffassign \
check-unparam \
check-yamllint \

.PHONY: check
check: install $(Check_Targets) ## Run tests and CI checks
Expand Down Expand Up @@ -96,6 +97,10 @@ check-gofmt:
check-vet: | check-test
go vet $(MODULE)/...

.PHONY: check-yamllint
check-yamllint:
docker run --rm -ti -v $(CURDIR):/workdir giantswarm/yamllint -c /workdir/yamllintcfg.yaml internal/translator/testdata

help: ## Display this help
@echo Contour high performance Ingress controller for Kubernetes
@echo
Expand Down
12 changes: 6 additions & 6 deletions internal/translator/testdata/basic_include/input.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
apiVersion: contour.heptio.com/v1beta1
kind: IngressRoute
metadata:
metadata:
name: delegation-root
namespace: default
spec:
spec:
virtualhost:
fqdn: root.bar.com
routes:
routes:
- match: /
services:
services:
- name: s1
port: 80
- match: /service2 # delegate the subpath, `/service2` to the IngressRoute object in this namespace with the name `service2`
- match: /service2
delegate:
name: service2
name: service2
3 changes: 2 additions & 1 deletion internal/translator/testdata/basic_include/output.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: projectcontour.io/v1
kind: HTTPProxy
metadata:
Expand All @@ -19,4 +20,4 @@ spec:
fqdn: root.bar.com
status:
currentStatus: ""
description: ""
description: ""
1 change: 1 addition & 0 deletions internal/translator/testdata/basic_ingress/output.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: projectcontour.io/v1
kind: HTTPProxy
metadata:
Expand Down
10 changes: 5 additions & 5 deletions internal/translator/testdata/health-checks/input.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
apiVersion: contour.heptio.com/v1beta1
kind: IngressRoute
metadata:
metadata:
name: health-check
namespace: default
spec:
spec:
virtualhost:
fqdn: health.bar.com
routes:
routes:
- match: /
services:
services:
- name: s1-health
port: 80
healthCheck:
Expand All @@ -18,5 +18,5 @@ spec:
timeoutSeconds: 2
unhealthyThresholdCount: 3
healthyThresholdCount: 5
- name: s2-health # no health-check defined for this service
- name: s2-health
port: 80
3 changes: 2 additions & 1 deletion internal/translator/testdata/health-checks/output.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: projectcontour.io/v1
kind: HTTPProxy
metadata:
Expand All @@ -23,4 +24,4 @@ spec:
fqdn: health.bar.com
status:
currentStatus: ""
description: ""
description: ""
10 changes: 5 additions & 5 deletions internal/translator/testdata/lb-diff-strategy/input.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
---
apiVersion: contour.heptio.com/v1beta1
kind: IngressRoute
metadata:
metadata:
name: lb-strategy
namespace: default
spec:
spec:
virtualhost:
fqdn: strategy.bar.com
routes:
routes:
- match: /
services:
services:
- name: s1-strategy
port: 80
strategy: Random
- name: s2-strategy
port: 80
strategy: WeightedLeastRequest # Default LB Algorithm for this Service is overridden
strategy: WeightedLeastRequest
1 change: 1 addition & 0 deletions internal/translator/testdata/lb-diff-strategy/output.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: projectcontour.io/v1
kind: HTTPProxy
metadata:
Expand Down
10 changes: 5 additions & 5 deletions internal/translator/testdata/lb-strategy/input.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
---
apiVersion: contour.heptio.com/v1beta1
kind: IngressRoute
metadata:
metadata:
name: lb-strategy
namespace: default
spec:
spec:
virtualhost:
fqdn: strategy.bar.com
routes:
routes:
- match: /
services:
services:
- name: s1-strategy
port: 80
strategy: WeightedLeastRequest
- name: s2-strategy
port: 80
strategy: WeightedLeastRequest # Default LB Algorithm for this Service is overridden
strategy: WeightedLeastRequest
1 change: 1 addition & 0 deletions internal/translator/testdata/lb-strategy/output.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: projectcontour.io/v1
kind: HTTPProxy
metadata:
Expand Down
8 changes: 4 additions & 4 deletions internal/translator/testdata/multiple-upstreams/input.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
apiVersion: contour.heptio.com/v1beta1
kind: IngressRoute
metadata:
metadata:
name: multiple-upstreams
namespace: default
spec:
spec:
virtualhost:
fqdn: multi.bar.com
routes:
routes:
- match: /
services:
services:
- name: s1
port: 80
- name: s2
Expand Down
3 changes: 2 additions & 1 deletion internal/translator/testdata/multiple-upstreams/output.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: projectcontour.io/v1
kind: HTTPProxy
metadata:
Expand All @@ -17,4 +18,4 @@ spec:
fqdn: multi.bar.com
status:
currentStatus: ""
description: ""
description: ""
10 changes: 5 additions & 5 deletions internal/translator/testdata/namespace_include/input.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
---
apiVersion: contour.heptio.com/v1beta1
kind: IngressRoute
metadata:
metadata:
name: different-namespace
namespace: default
spec:
spec:
virtualhost:
fqdn: root.bar.com
routes:
routes:
- match: /
services:
services:
- name: s1
port: 80
- match: /service2
delegate:
name: service2
namespace: other
namespace: other
3 changes: 2 additions & 1 deletion internal/translator/testdata/namespace_include/output.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: projectcontour.io/v1
kind: HTTPProxy
metadata:
Expand All @@ -20,4 +21,4 @@ spec:
fqdn: root.bar.com
status:
currentStatus: ""
description: ""
description: ""
3 changes: 2 additions & 1 deletion internal/translator/testdata/request-timeout/output.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: projectcontour.io/v1
kind: HTTPProxy
metadata:
Expand All @@ -18,4 +19,4 @@ spec:
fqdn: timeout.bar.com
status:
currentStatus: ""
description: ""
description: ""
1 change: 1 addition & 0 deletions internal/translator/testdata/tls_ingressroute/input.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: contour.heptio.com/v1beta1
kind: IngressRoute
metadata:
Expand Down
2 changes: 1 addition & 1 deletion internal/translator/testdata/tls_ingressroute/output.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: projectcontour.io/v1
kind: HTTPProxy
metadata:
Expand All @@ -18,4 +19,3 @@ spec:
status:
currentStatus: ""
description: ""

8 changes: 4 additions & 4 deletions internal/translator/testdata/weight-shifting/input.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
apiVersion: contour.heptio.com/v1beta1
kind: IngressRoute
metadata:
metadata:
name: weight-shifting
namespace: default
spec:
spec:
virtualhost:
fqdn: weights.bar.com
routes:
routes:
- match: /
services:
services:
- name: s1
port: 80
weight: 10
Expand Down
3 changes: 2 additions & 1 deletion internal/translator/testdata/weight-shifting/output.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: projectcontour.io/v1
kind: HTTPProxy
metadata:
Expand All @@ -19,4 +20,4 @@ spec:
fqdn: weights.bar.com
status:
currentStatus: ""
description: ""
description: ""
1 change: 1 addition & 0 deletions internal/translator/translate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func TestTranslateIngressRoute(t *testing.T) {
if err != nil {
t.Fatal(err)
}
outputYAML = append([]byte("---\n"), outputYAML...)

translateDiff := cmp.Diff(bytes.TrimSpace(outputYAML), bytes.TrimSpace(tc.output))
if translateDiff != "" {
Expand Down
6 changes: 6 additions & 0 deletions yamllintcfg.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extends: default

rules:
indentation:
spaces: 2
indent-sequences: consistent

0 comments on commit 37dffbc

Please sign in to comment.