+423
-19
lines changedFilter options
+423
-19
lines changed Original file line number Diff line number Diff line change
@@ -97,7 +97,7 @@ func (l *lintCmd) run() error {
97
97
var total int
98
98
var failures int
99
99
for _, path := range l.paths {
100
-
linter, err := lintChart(path, rvals, l.namespace, l.strict)
100
+
linter, err := lintChart(path, rvals, l.namespace)
101
101
if err != nil {
102
102
failures = failures + 1
103
103
fmt.Println("==> Skipping", path)
@@ -132,7 +132,7 @@ func (l *lintCmd) run() error {
132
132
return nil
133
133
}
134
134
135
-
func lintChart(path string, vals []byte, namespace string, strict bool) (support.Linter, error) {
135
+
func lintChart(path string, vals []byte, namespace string) (support.Linter, error) {
136
136
var chartPath string
137
137
linter := support.Linter{}
138
138
@@ -171,7 +171,7 @@ func lintChart(path string, vals []byte, namespace string, strict bool) (support
171
171
return linter, fmt.Errorf("unable to check Chart.yaml file in chart: %s", err.Error())
172
172
}
173
173
174
-
return lint.All(chartPath, vals, namespace, strict), nil
174
+
return lint.All(chartPath, vals, namespace), nil
175
175
}
176
176
177
177
// vals merges values from files specified via -f/--values and
Original file line number Diff line number Diff line change
@@ -58,11 +58,10 @@ func TestLintChart(t *testing.T) {
58
58
59
59
values := []byte{}
60
60
namespace := "testNamespace"
61
-
strict := false
62
61
63
62
for _, tt := range tests {
64
63
t.Run(tt.name, func(t *testing.T) {
65
-
_, err := lintChart(tt.chartPath, values, namespace, strict)
64
+
_, err := lintChart(tt.chartPath, values, namespace)
66
65
switch {
67
66
case err != nil && !tt.err:
68
67
t.Errorf("%s", err)
@@ -107,3 +106,45 @@ func TestLinRunForNonExistentChart(t *testing.T) {
107
106
}
108
107
})
109
108
}
109
+
110
+
func TestLintRunForStrictErrors(t *testing.T) {
111
+
out := bytes.NewBufferString("")
112
+
tests := []struct {
113
+
name string
114
+
chartPath string
115
+
strict bool
116
+
errStr string
117
+
wantErr bool
118
+
}{
119
+
{
120
+
name: "non-strict should not error",
121
+
chartPath: "testdata/testcharts/bad.name",
122
+
strict: false,
123
+
wantErr: false,
124
+
},
125
+
{
126
+
name: "strict should error",
127
+
chartPath: "testdata/testcharts/bad.name",
128
+
strict: true,
129
+
errStr: "1 chart(s) linted, 1 chart(s) failed",
130
+
wantErr: true,
131
+
},
132
+
}
133
+
for _, tt := range tests {
134
+
t.Run(tt.name, func(t *testing.T) {
135
+
testLint := &lintCmd{
136
+
paths: []string{tt.chartPath},
137
+
strict: tt.strict,
138
+
out: out,
139
+
}
140
+
expectedErr := fmt.Errorf(tt.errStr)
141
+
err := testLint.run()
142
+
if tt.wantErr && err == nil {
143
+
t.Errorf("expected error but got no error")
144
+
}
145
+
if err != nil && (err.Error() != expectedErr.Error()) {
146
+
t.Errorf("expected: \"%v\" , but got: \"%v\"", expectedErr, err)
147
+
}
148
+
})
149
+
}
150
+
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
1
+
# Patterns to ignore when building packages.
2
+
# This supports shell glob matching, relative path matching, and
3
+
# negation (prefixed with !). Only one pattern per line.
4
+
.DS_Store
5
+
# Common VCS dirs
6
+
.git/
7
+
.gitignore
8
+
.bzr/
9
+
.bzrignore
10
+
.hg/
11
+
.hgignore
12
+
.svn/
13
+
# Common backup files
14
+
*.swp
15
+
*.bak
16
+
*.tmp
17
+
*~
18
+
# Various IDEs
19
+
.project
20
+
.idea/
21
+
*.tmproj
22
+
.vscode/
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
1
+
apiVersion: v1
2
+
appVersion: "1.0"
3
+
description: A Helm chart for Kubernetes
4
+
name: bad.name
5
+
version: 0.1.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
1
+
1. Get the application URL by running these commands:
2
+
{{- if .Values.ingress.enabled }}
3
+
{{- range $host := .Values.ingress.hosts }}
4
+
{{- range .paths }}
5
+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
6
+
{{- end }}
7
+
{{- end }}
8
+
{{- else if contains "NodePort" .Values.service.type }}
9
+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "bad.name.fullname" . }})
10
+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
11
+
echo http://$NODE_IP:$NODE_PORT
12
+
{{- else if contains "LoadBalancer" .Values.service.type }}
13
+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
14
+
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "bad.name.fullname" . }}'
15
+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "bad.name.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
16
+
echo http://$SERVICE_IP:{{ .Values.service.port }}
17
+
{{- else if contains "ClusterIP" .Values.service.type }}
18
+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "bad.name.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19
+
echo "Visit http://127.0.0.1:8080 to use your application"
20
+
kubectl port-forward $POD_NAME 8080:80
21
+
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
1
+
{{/* vim: set filetype=mustache: */}}
2
+
{{/*
3
+
Expand the name of the chart.
4
+
*/}}
5
+
{{- define "bad.name.name" -}}
6
+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
7
+
{{- end -}}
8
+
9
+
{{/*
10
+
Create a default fully qualified app name.
11
+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
12
+
If release name contains chart name it will be used as a full name.
13
+
*/}}
14
+
{{- define "bad.name.fullname" -}}
15
+
{{- if .Values.fullnameOverride -}}
16
+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
17
+
{{- else -}}
18
+
{{- $name := default .Chart.Name .Values.nameOverride -}}
19
+
{{- if contains $name .Release.Name -}}
20
+
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
21
+
{{- else -}}
22
+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
23
+
{{- end -}}
24
+
{{- end -}}
25
+
{{- end -}}
26
+
27
+
{{/*
28
+
Create chart name and version as used by the chart label.
29
+
*/}}
30
+
{{- define "bad.name.chart" -}}
31
+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32
+
{{- end -}}
33
+
34
+
{{/*
35
+
Common labels
36
+
*/}}
37
+
{{- define "bad.name.labels" -}}
38
+
app.kubernetes.io/name: {{ include "bad.name.name" . }}
39
+
helm.sh/chart: {{ include "bad.name.chart" . }}
40
+
app.kubernetes.io/instance: {{ .Release.Name }}
41
+
{{- if .Chart.AppVersion }}
42
+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
43
+
{{- end }}
44
+
app.kubernetes.io/managed-by: {{ .Release.Service }}
45
+
{{- end -}}
46
+
47
+
{{/*
48
+
Create the name of the service account to use
49
+
*/}}
50
+
{{- define "bad.name.serviceAccountName" -}}
51
+
{{- if .Values.serviceAccount.create -}}
52
+
{{ default (include "bad.name.fullname" .) .Values.serviceAccount.name }}
53
+
{{- else -}}
54
+
{{ default "default" .Values.serviceAccount.name }}
55
+
{{- end -}}
56
+
{{- end -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
1
+
apiVersion: apps/v1
2
+
kind: Deployment
3
+
metadata:
4
+
name: {{ include "bad.name.fullname" . }}
5
+
labels:
6
+
{{ include "bad.name.labels" . | indent 4 }}
7
+
spec:
8
+
replicas: {{ .Values.replicaCount }}
9
+
selector:
10
+
matchLabels:
11
+
app.kubernetes.io/name: {{ include "bad.name.name" . }}
12
+
app.kubernetes.io/instance: {{ .Release.Name }}
13
+
template:
14
+
metadata:
15
+
labels:
16
+
app.kubernetes.io/name: {{ include "bad.name.name" . }}
17
+
app.kubernetes.io/instance: {{ .Release.Name }}
18
+
spec:
19
+
{{- with .Values.imagePullSecrets }}
20
+
imagePullSecrets:
21
+
{{- toYaml . | nindent 8 }}
22
+
{{- end }}
23
+
serviceAccountName: {{ template "bad.name.serviceAccountName" . }}
24
+
securityContext:
25
+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
26
+
containers:
27
+
- name: {{ .Chart.Name }}
28
+
securityContext:
29
+
{{- toYaml .Values.securityContext | nindent 12 }}
30
+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
31
+
imagePullPolicy: {{ .Values.image.pullPolicy }}
32
+
ports:
33
+
- name: http
34
+
containerPort: 80
35
+
protocol: TCP
36
+
livenessProbe:
37
+
httpGet:
38
+
path: /
39
+
port: http
40
+
readinessProbe:
41
+
httpGet:
42
+
path: /
43
+
port: http
44
+
resources:
45
+
{{- toYaml .Values.resources | nindent 12 }}
46
+
{{- with .Values.nodeSelector }}
47
+
nodeSelector:
48
+
{{- toYaml . | nindent 8 }}
49
+
{{- end }}
50
+
{{- with .Values.affinity }}
51
+
affinity:
52
+
{{- toYaml . | nindent 8 }}
53
+
{{- end }}
54
+
{{- with .Values.tolerations }}
55
+
tolerations:
56
+
{{- toYaml . | nindent 8 }}
57
+
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
1
+
{{- if .Values.ingress.enabled -}}
2
+
{{- $fullName := include "bad.name.fullname" . -}}
3
+
{{- $svcPort := .Values.service.port -}}
4
+
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
5
+
apiVersion: networking.k8s.io/v1beta1
6
+
{{- else -}}
7
+
apiVersion: extensions/v1beta1
8
+
{{- end }}
9
+
kind: Ingress
10
+
metadata:
11
+
name: {{ $fullName }}
12
+
labels:
13
+
{{ include "bad.name.labels" . | indent 4 }}
14
+
{{- with .Values.ingress.annotations }}
15
+
annotations:
16
+
{{- toYaml . | nindent 4 }}
17
+
{{- end }}
18
+
spec:
19
+
{{- if .Values.ingress.tls }}
20
+
tls:
21
+
{{- range .Values.ingress.tls }}
22
+
- hosts:
23
+
{{- range .hosts }}
24
+
- {{ . | quote }}
25
+
{{- end }}
26
+
secretName: {{ .secretName }}
27
+
{{- end }}
28
+
{{- end }}
29
+
rules:
30
+
{{- range .Values.ingress.hosts }}
31
+
- host: {{ .host | quote }}
32
+
http:
33
+
paths:
34
+
{{- range .paths }}
35
+
- path: {{ . }}
36
+
backend:
37
+
serviceName: {{ $fullName }}
38
+
servicePort: {{ $svcPort }}
39
+
{{- end }}
40
+
{{- end }}
41
+
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
1
+
apiVersion: v1
2
+
kind: Service
3
+
metadata:
4
+
name: {{ include "bad.name.fullname" . }}
5
+
labels:
6
+
{{ include "bad.name.labels" . | indent 4 }}
7
+
spec:
8
+
type: {{ .Values.service.type }}
9
+
ports:
10
+
- port: {{ .Values.service.port }}
11
+
targetPort: http
12
+
protocol: TCP
13
+
name: http
14
+
selector:
15
+
app.kubernetes.io/name: {{ include "bad.name.name" . }}
16
+
app.kubernetes.io/instance: {{ .Release.Name }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
1
+
{{- if .Values.serviceAccount.create -}}
2
+
apiVersion: v1
3
+
kind: ServiceAccount
4
+
metadata:
5
+
name: {{ template "bad.name.serviceAccountName" . }}
6
+
labels:
7
+
{{ include "bad.name.labels" . | indent 4 }}
8
+
{{- end -}}
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4