Skip to content

Commit 6233e66

Browse files
committed
support chart path in name
1 parent 2d1a16c commit 6233e66

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+131
-86
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Tested with operator-sdk version: "v1.8.0".
4545
```makefile
4646
HELMIFY = $(shell pwd)/bin/helmify
4747
helmify:
48-
$(call go-get-tool,$(HELMIFY),github.com/arttor/helmify/cmd/[email protected].0)
48+
$(call go-get-tool,$(HELMIFY),github.com/arttor/helmify/cmd/[email protected].2)
4949
5050
helm: manifests kustomize helmify
5151
$(KUSTOMIZE) build config/default | $(HELMIFY)
@@ -63,7 +63,7 @@ Unpack the helmify binary and add it to your PATH and you are good to go!
6363
Helmify takes a chart name for an argument.
6464
Usage:
6565

66-
```helmify [flags] CHART_NAME``` - `CHART_NAME` is optional. Default is 'chart'.
66+
```helmify [flags] CHART_NAME``` - `CHART_NAME` is optional. Default is 'chart'. Can be a directory, e.g. 'deploy/charts/mychart'.
6767

6868
| flag | description | sample |
6969
| --- | --- | --- |

cmd/helmify/flags.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"flag"
55
"fmt"
66
"os"
7+
"path/filepath"
78

89
"github.com/arttor/helmify/pkg/config"
910
)
@@ -20,7 +21,7 @@ Example 3: 'awk 'FNR==1 && NR!=1 {print "---"}{print}' /my_directory/*.yaml | h
2021
- will create 'mychart' directory with Helm chart from all yaml files in my_directory directory.
2122
2223
Usage:
23-
helmify [flags] CHART_NAME - CHART_NAME is optional. Default is 'chart'.
24+
helmify [flags] CHART_NAME - CHART_NAME is optional. Default is 'chart'. Can be a directory, e.g. 'deploy/charts/mychart'.
2425
2526
Flags:
2627
`
@@ -44,6 +45,11 @@ func ReadFlags() config.Config {
4445
printVersion()
4546
os.Exit(0)
4647
}
47-
result.ChartName = flag.Arg(0)
48+
name := flag.Arg(0)
49+
if name != "" {
50+
result.ChartName = filepath.Base(name)
51+
result.ChartDir = filepath.Dir(name)
52+
}
53+
4854
return result
4955
}

examples/app/templates/deployment.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ spec:
3535
secretKeyRef:
3636
key: VAR2
3737
name: {{ include "app.fullname" . }}-secret-vars
38-
image: {{ .Values.image.app.repository }}:{{ .Values.image.app.tag | default .Chart.AppVersion
39-
}}
38+
image: {{ .Values.app.app.image.repository }}:{{ .Values.app.app.image.tag | default
39+
.Chart.AppVersion }}
4040
livenessProbe:
4141
httpGet:
4242
path: /healthz
@@ -67,7 +67,7 @@ spec:
6767
- args:
6868
- --secure-listen-address=0.0.0.0:8443
6969
- --v=10
70-
image: {{ .Values.image.proxySidecar.repository }}:{{ .Values.image.proxySidecar.tag
70+
image: {{ .Values.app.proxySidecar.image.repository }}:{{ .Values.app.proxySidecar.image.tag
7171
| default .Chart.AppVersion }}
7272
name: proxy-sidecar
7373
ports:

examples/app/values.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
app:
22
app:
3+
image:
4+
repository: controller
5+
tag: latest
36
resources:
47
limits:
58
cpu: 100m
69
memory: 30Mi
710
requests:
811
cpu: 100m
912
memory: 20Mi
13+
proxySidecar:
14+
image:
15+
repository: gcr.io/kubebuilder/kube-rbac-proxy
16+
tag: v0.8.0
1017
replicas: 3
1118
appService:
1219
ports:
@@ -30,13 +37,6 @@ configProps:
3037
myProp1: "1"
3138
myProp2: val 1
3239
myProp3: "true"
33-
image:
34-
app:
35-
repository: controller
36-
tag: latest
37-
proxySidecar:
38-
repository: gcr.io/kubebuilder/kube-rbac-proxy
39-
tag: v0.8.0
4040
secretCa:
4141
caCrt: ""
4242
secretVars:

examples/operator/templates/deployment.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ spec:
3030
- --upstream=http://127.0.0.1:8080/
3131
- --logtostderr=true
3232
- --v=10
33-
image: {{ .Values.image.kubeRbacProxy.repository }}:{{ .Values.image.kubeRbacProxy.tag
33+
image: {{ .Values.controllerManager.kubeRbacProxy.image.repository }}:{{ .Values.controllerManager.kubeRbacProxy.image.tag
3434
| default .Chart.AppVersion }}
3535
name: kube-rbac-proxy
3636
ports:
@@ -49,8 +49,8 @@ spec:
4949
secretKeyRef:
5050
key: VAR1
5151
name: {{ include "operator.fullname" . }}-secret-vars
52-
image: {{ .Values.image.manager.repository }}:{{ .Values.image.manager.tag | default
53-
.Chart.AppVersion }}
52+
image: {{ .Values.controllerManager.manager.image.repository }}:{{ .Values.controllerManager.manager.image.tag
53+
| default .Chart.AppVersion }}
5454
livenessProbe:
5555
httpGet:
5656
path: /healthz

examples/operator/templates/secret-ca.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ metadata:
55
labels:
66
{{- include "operator.labels" . | nindent 4 }}
77
data:
8-
ca.crt: '{{ required "secret secretCa.caCrt is required" .Values.secretCa.caCrt
9-
| b64enc }}'
8+
ca.crt: {{ required "secretCa.caCrt is required" .Values.secretCa.caCrt | b64enc
9+
| quote }}

examples/operator/templates/secret-vars.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ metadata:
55
labels:
66
{{- include "operator.labels" . | nindent 4 }}
77
data:
8-
VAR1: '{{ required "secret secretVars.var1 is required" .Values.secretVars.var1
9-
| b64enc }}'
10-
VAR2: '{{ required "secret secretVars.var2 is required" .Values.secretVars.var2
11-
| b64enc }}'
8+
VAR1: {{ required "secretVars.var1 is required" .Values.secretVars.var1 | b64enc
9+
| quote }}
10+
VAR2: {{ required "secretVars.var2 is required" .Values.secretVars.var2 | b64enc
11+
| quote }}

examples/operator/values.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
controllerManager:
2+
kubeRbacProxy:
3+
image:
4+
repository: gcr.io/kubebuilder/kube-rbac-proxy
5+
tag: v0.8.0
26
manager:
7+
image:
8+
repository: controller
9+
tag: latest
310
resources:
411
limits:
512
cpu: 100m
@@ -8,13 +15,6 @@ controllerManager:
815
cpu: 100m
916
memory: 20Mi
1017
replicas: 1
11-
image:
12-
kubeRbacProxy:
13-
repository: gcr.io/kubebuilder/kube-rbac-proxy
14-
tag: v0.8.0
15-
manager:
16-
repository: controller
17-
tag: latest
1818
managerConfig:
1919
controllerManagerConfigYaml:
2020
health:

pkg/app/app.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ package app
22

33
import (
44
"context"
5-
"github.com/arttor/helmify/pkg/processor"
65
"io"
76
"os"
87
"os/signal"
98
"syscall"
109

10+
"github.com/arttor/helmify/pkg/processor"
11+
1112
"github.com/arttor/helmify/pkg/config"
1213
"github.com/arttor/helmify/pkg/decoder"
1314
"github.com/arttor/helmify/pkg/helm"

pkg/app/context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (c *appContext) CreateHelm(stop <-chan struct{}) error {
6767
default:
6868
}
6969
}
70-
return c.output.Create(c.appMeta.ChartName(), templates)
70+
return c.output.Create(c.config.ChartDir, c.config.ChartName, templates)
7171
}
7272

7373
func (c *appContext) process(obj *unstructured.Unstructured) (helmify.Template, error) {

0 commit comments

Comments
 (0)