Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,356 changes: 757 additions & 599 deletions cli/cmd/lint_test.go

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions testdata/lint/chart-missing-helmchart/.replicated
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
charts:
- path: chart
manifests:
- manifests/*.yaml
repl-lint:
linters:
helm:
disabled: true
preflight:
disabled: true
4 changes: 4 additions & 0 deletions testdata/lint/chart-missing-helmchart/chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v2
name: test-app
version: 1.0.0
description: Test chart without matching HelmChart manifest
1 change: 1 addition & 0 deletions testdata/lint/chart-missing-helmchart/manifests/.gitkeep
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Empty manifests directory - no HelmChart manifest
6 changes: 6 additions & 0 deletions testdata/lint/configs/all-linters-enabled.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
repl-lint:
version: 1
linters:
helm: {}
preflight: {}
support-bundle: {}
5 changes: 5 additions & 0 deletions testdata/lint/configs/basic-helm-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
repl-lint:
linters:
helm: {}
preflight:
disabled: true
8 changes: 8 additions & 0 deletions testdata/lint/configs/empty-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
charts: []
manifests: []
preflights: []
repl-lint:
linters:
helm: {}
preflight:
disabled: true
9 changes: 9 additions & 0 deletions testdata/lint/configs/helm-with-latest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repl-lint:
tools:
helm: "latest"
preflight: "latest"
support-bundle: "latest"
linters:
helm: {}
preflight:
disabled: true
9 changes: 9 additions & 0 deletions testdata/lint/configs/helm-with-versions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repl-lint:
tools:
helm: "3.14.4"
preflight: "0.123.9"
support-bundle: "0.123.9"
linters:
helm: {}
preflight:
disabled: true
6 changes: 6 additions & 0 deletions testdata/lint/configs/manifests-only.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
manifests:
- manifests/*.yaml
repl-lint:
linters:
helm: {}
preflight: {}
7 changes: 7 additions & 0 deletions testdata/lint/hidden-dirs-test/.github/manifests/fake-sb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This should be ignored
apiVersion: troubleshoot.sh/v1beta2
kind: SupportBundle
metadata:
name: fake
spec:
collectors: []
4 changes: 4 additions & 0 deletions testdata/lint/hidden-dirs-test/charts/my-chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v2
name: my-chart
version: 1.0.0
description: Test chart for hidden directory autodiscovery
9 changes: 9 additions & 0 deletions testdata/lint/hidden-dirs-test/manifests/helmchart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: kots.io/v1beta2
kind: HelmChart
metadata:
name: my-chart
spec:
chart:
name: my-chart
chartVersion: 1.0.0
weight: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v2
name: my-app
version: 1.0.0
description: Test chart for autodiscovery with mixed manifests
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: kots.io/v1beta2
kind: HelmChart
metadata:
name: my-app
spec:
chart:
name: my-app
chartVersion: 1.0.0
weight: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: troubleshoot.sh/v1beta2
kind: Preflight
metadata:
name: my-app-preflight
spec:
analyzers:
- clusterVersion:
outcomes:
- fail:
when: "< 1.20.0"
message: Kubernetes version must be at least 1.20.0
- pass:
message: Kubernetes version is supported
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: troubleshoot.sh/v1beta2
kind: SupportBundle
metadata:
name: my-app-support-bundle
spec:
collectors:
- logs:
selector:
- app=my-app
namespace: default
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v2
name: my-app
version: 1.0.0
description: Test chart for autodiscovery with mixed manifests
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: kots.io/v1beta2
kind: HelmChart
metadata:
name: my-app
spec:
chart:
name: my-app
chartVersion: 1.0.0
weight: 1
13 changes: 13 additions & 0 deletions testdata/lint/mixed-manifests-yaml-yml/manifests/preflight.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: troubleshoot.sh/v1beta2
kind: Preflight
metadata:
name: my-app-preflight
spec:
analyzers:
- clusterVersion:
outcomes:
- fail:
when: "< 1.20.0"
message: Kubernetes version must be at least 1.20.0
- pass:
message: Kubernetes version is supported
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: troubleshoot.sh/v1beta2
kind: SupportBundle
metadata:
name: my-app-support-bundle
spec:
collectors:
- logs:
selector:
- app=my-app
namespace: default
10 changes: 10 additions & 0 deletions testdata/lint/multi-chart-project/.replicated
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
charts:
- path: chart1
- path: chart2
manifests:
- manifests/*.yaml
repl-lint:
linters:
helm: {}
preflight:
disabled: true
4 changes: 4 additions & 0 deletions testdata/lint/multi-chart-project/chart1/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v2
name: chart1
version: 1.0.0
description: First chart for multi-chart testing
18 changes: 18 additions & 0 deletions testdata/lint/multi-chart-project/chart1/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
ports:
- containerPort: 80
3 changes: 3 additions & 0 deletions testdata/lint/multi-chart-project/chart1/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
image:
repository: nginx
tag: "1.21"
4 changes: 4 additions & 0 deletions testdata/lint/multi-chart-project/chart2/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v2
name: chart2
version: 1.0.0
description: Second chart for multi-chart testing
18 changes: 18 additions & 0 deletions testdata/lint/multi-chart-project/chart2/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis
spec:
selector:
matchLabels:
app: redis
template:
metadata:
labels:
app: redis
spec:
containers:
- name: redis
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
ports:
- containerPort: 6379
3 changes: 3 additions & 0 deletions testdata/lint/multi-chart-project/chart2/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
image:
repository: redis
tag: "7.0"
10 changes: 10 additions & 0 deletions testdata/lint/multi-chart-project/manifests/chart1-helmchart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: kots.io/v1beta2
kind: HelmChart
metadata:
name: chart1
spec:
chart:
name: chart1
chartVersion: 1.0.0
weight: 1
builder: {}
10 changes: 10 additions & 0 deletions testdata/lint/multi-chart-project/manifests/chart2-helmchart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: kots.io/v1beta2
kind: HelmChart
metadata:
name: chart2
spec:
chart:
name: chart2
chartVersion: 1.0.0
weight: 2
builder: {}
10 changes: 10 additions & 0 deletions testdata/lint/orphaned-helmchart/.replicated
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
charts:
- path: chart
manifests:
- manifests/*.yaml
repl-lint:
linters:
helm:
disabled: true
preflight:
disabled: true
4 changes: 4 additions & 0 deletions testdata/lint/orphaned-helmchart/chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v2
name: current-app
version: 1.0.0
description: Current active chart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: kots.io/v1beta2
kind: HelmChart
metadata:
name: current-app
spec:
chart:
name: current-app
chartVersion: 1.0.0
weight: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: kots.io/v1beta2
kind: HelmChart
metadata:
name: old-app
spec:
chart:
name: old-app
chartVersion: 0.9.0
weight: 2
9 changes: 9 additions & 0 deletions testdata/lint/simple-chart/.replicated
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
charts:
- path: chart
manifests:
- manifests/*.yaml
repl-lint:
linters:
helm: {}
preflight:
disabled: true
4 changes: 4 additions & 0 deletions testdata/lint/simple-chart/chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v2
name: test-chart
version: 1.0.0
description: A simple test chart for lint testing
19 changes: 19 additions & 0 deletions testdata/lint/simple-chart/chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: test
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: test-chart
template:
metadata:
labels:
app: test-chart
spec:
containers:
- name: nginx
image: {{ .Values.image.repository }}:{{ .Values.image.tag }}
ports:
- containerPort: 80
6 changes: 6 additions & 0 deletions testdata/lint/simple-chart/chart/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
replicaCount: 1

image:
repository: nginx
tag: "1.21"
pullPolicy: IfNotPresent
10 changes: 10 additions & 0 deletions testdata/lint/simple-chart/manifests/helmchart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: kots.io/v1beta2
kind: HelmChart
metadata:
name: test-chart
spec:
chart:
name: test-chart
chartVersion: 1.0.0
weight: 1
builder: {}
Loading