Skip to content

Commit 33ff93f

Browse files
Merge pull request #22 from ContainerSolutions/upgrade-kustomize-v2
[wip] Initial migration to kustomize v2.x
2 parents 7908d62 + 4b3e22c commit 33ff93f

18 files changed

Lines changed: 319 additions & 174 deletions

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: go
22

33
go:
4-
- master
4+
- 1.12.x
55

66
script:
77
- make test-all

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.11 AS build
1+
FROM golang:1.12 AS build
22
ENV GOPATH=""
33
ARG LDFLAGS
44
COPY go.sum .
@@ -8,7 +8,7 @@ COPY . .
88
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o helm-convert -ldflags "$LDFLAGS" main.go
99

1010
FROM alpine AS helm
11-
ENV HELM_VERSION=v2.10.0
11+
ENV HELM_VERSION=v2.13.0
1212
ENV HELM_TMP_FILE=helm-${HELM_VERSION}-linux-amd64.tar.gz
1313
RUN wget https://storage.googleapis.com/kubernetes-helm/${HELM_TMP_FILE} && \
1414
wget https://storage.googleapis.com/kubernetes-helm/${HELM_TMP_FILE}.sha256

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,4 @@ The conversion is currently quite basic and has the following features:
8181
- create secretGenerator based on secret resources (type Opaque and TLS)
8282
- create secretGenerator based on secret type TLS
8383
- create configGenerator from multiline files
84+
- handle datasources type literal, env files and source files

cmd/convert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ func (k *convertCmd) run() error {
225225
hooks.HookWeightAnno,
226226
hooks.HookDeleteAnno,
227227
}),
228-
transformers.NewImageTagTransformer(),
228+
transformers.NewImageTransformer(),
229229
transformers.NewConfigMapTransformer(),
230230
transformers.NewSecretTransformer(),
231231
transformers.NewNamePrefixTransformer(),

go.mod

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,37 @@ module github.com/ContainerSolutions/helm-convert
22

33
require (
44
github.com/BurntSushi/toml v0.3.1 // indirect
5+
github.com/Masterminds/goutils v1.1.0 // indirect
56
github.com/Masterminds/semver v1.4.2 // indirect
6-
github.com/Masterminds/sprig v2.16.0+incompatible // indirect
7-
github.com/aokoli/goutils v1.0.1 // indirect
8-
github.com/aws/aws-sdk-go v1.15.44 // indirect
9-
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
7+
github.com/Masterminds/sprig v2.18.1-0.20190301161902-9f8fceff796f+incompatible // indirect
8+
github.com/cyphar/filepath-securejoin v0.2.2 // indirect
109
github.com/davecgh/go-spew v1.1.1 // indirect
1110
github.com/ghodss/yaml v1.0.0
1211
github.com/gobwas/glob v0.2.3 // indirect
1312
github.com/gogo/protobuf v1.1.1 // indirect
1413
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
1514
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf // indirect
1615
github.com/google/uuid v1.0.0 // indirect
17-
github.com/gopherjs/gopherjs v0.0.0-20181004151105-1babbf986f6f // indirect
18-
github.com/hashicorp/go-cleanhttp v0.5.0 // indirect
19-
github.com/hashicorp/go-getter v0.0.0-20180809191950-4bda8fa99001 // indirect
20-
github.com/hashicorp/go-safetemp v1.0.0 // indirect
21-
github.com/hashicorp/go-version v1.0.0 // indirect
2216
github.com/huandu/xstrings v1.2.0 // indirect
23-
github.com/imdario/mergo v0.0.0-20141206190957-6633656539c1 // indirect
17+
github.com/imdario/mergo v0.3.7 // indirect
2418
github.com/inconshreveable/mousetrap v1.0.0 // indirect
2519
github.com/json-iterator/go v1.1.5 // indirect
26-
github.com/jtolds/gls v4.2.1+incompatible // indirect
2720
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348
28-
github.com/mitchellh/go-homedir v1.0.0 // indirect
29-
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
3021
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
3122
github.com/modern-go/reflect2 v1.0.1 // indirect
3223
github.com/pkg/errors v0.8.0 // indirect
3324
github.com/pmezard/go-difflib v1.0.0 // indirect
34-
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d // indirect
35-
github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a // indirect
3625
github.com/spf13/cobra v0.0.3
3726
github.com/spf13/pflag v1.0.2 // indirect
3827
github.com/stretchr/testify v1.2.2 // indirect
39-
github.com/ulikunitz/xz v0.5.4 // indirect
4028
golang.org/x/crypto v0.0.0-20181009213950-7c1a557ab941 // indirect
4129
golang.org/x/net v0.0.0-20181005035420-146acd28ed58 // indirect
4230
google.golang.org/grpc v1.15.0
4331
gopkg.in/inf.v0 v0.9.1 // indirect
44-
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0 // indirect
4532
gopkg.in/yaml.v2 v2.2.1 // indirect
4633
k8s.io/api v0.0.0-20180628040859-072894a440bd
4734
k8s.io/apimachinery v0.0.0-20180621070125-103fd098999d
48-
k8s.io/client-go v7.0.0+incompatible // indirect
49-
k8s.io/helm v2.11.0-rc.4+incompatible
50-
sigs.k8s.io/kustomize v1.0.10
35+
k8s.io/client-go v10.0.0+incompatible // indirect
36+
k8s.io/helm v2.13.0+incompatible
37+
sigs.k8s.io/kustomize v2.0.3+incompatible
5138
)

go.sum

Lines changed: 14 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
11
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
22
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
33
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
4+
github.com/Masterminds/goutils v1.1.0 h1:zukEsf/1JZwCMgHiK3GZftabmxiCw4apj3a28RPBiVg=
5+
github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
46
github.com/Masterminds/semver v1.4.2 h1:WBLTQ37jOCzSLtXNdoo8bNM8876KhNqOKvrlGITgsTc=
57
github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
6-
github.com/Masterminds/sprig v2.16.0+incompatible h1:QZbMUPxRQ50EKAq3LFMnxddMu88/EUUG3qmxwtDmPsY=
7-
github.com/Masterminds/sprig v2.16.0+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
8-
github.com/aokoli/goutils v1.0.1 h1:7fpzNGoJ3VA8qcrm++XEE1QUe0mIwNeLa02Nwq7RDkg=
9-
github.com/aokoli/goutils v1.0.1/go.mod h1:SijmP0QR8LtwsmDs8Yii5Z/S4trXFGFC2oO5g9DP+DQ=
10-
github.com/aws/aws-sdk-go v1.15.44 h1:XIhmST75fI9XXOdRQKw2czRLiT7abSjKLXdhD9jC4Fk=
11-
github.com/aws/aws-sdk-go v1.15.44/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0=
12-
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas=
13-
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4=
8+
github.com/Masterminds/sprig v2.18.1-0.20190301161902-9f8fceff796f+incompatible h1:i3KaRauSAi1fdIRAWtYgF1zTHlL1SScJ0DZBGzzeHyA=
9+
github.com/Masterminds/sprig v2.18.1-0.20190301161902-9f8fceff796f+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
1410
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
11+
github.com/cyphar/filepath-securejoin v0.2.2 h1:jCwT2GTP+PY5nBz3c/YL5PAIbusElVrPujOBSCj8xRg=
12+
github.com/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4=
1513
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
1614
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1715
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
1816
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
19-
github.com/go-ini/ini v1.25.4 h1:Mujh4R/dH6YL8bxuISne3xX2+qcQ9p0IxKAP6ExWoUo=
20-
github.com/go-ini/ini v1.25.4/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
2117
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
2218
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
2319
github.com/gogo/protobuf v1.1.1 h1:72R+M5VuhED/KujmZVcIquuo8mBgX4oVda//DQb3PXo=
@@ -32,35 +28,17 @@ github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf h1:+RRA9JqSOZFfKrOeq
3228
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI=
3329
github.com/google/uuid v1.0.0 h1:b4Gk+7WdP/d3HZH8EJsZpvV7EtDOgaZLtnaNGIu1adA=
3430
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
35-
github.com/gopherjs/gopherjs v0.0.0-20181004151105-1babbf986f6f h1:JJ2EP5vV3LAD2U1CxQtD7PTOO15Y96kXmKDz7TjxGHs=
36-
github.com/gopherjs/gopherjs v0.0.0-20181004151105-1babbf986f6f/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
37-
github.com/hashicorp/go-cleanhttp v0.5.0 h1:wvCrVc9TjDls6+YGAF2hAifE1E5U1+b4tH6KdvN3Gig=
38-
github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
39-
github.com/hashicorp/go-getter v0.0.0-20180809191950-4bda8fa99001 h1:MFPzqpPED05pFyGjNPJEC2sXM6EHTzFyvX+0s0JoZ48=
40-
github.com/hashicorp/go-getter v0.0.0-20180809191950-4bda8fa99001/go.mod h1:6rdJFnhkXnzGOJbvkrdv4t9nLwKcVA+tmbQeUlkIzrU=
41-
github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo=
42-
github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I=
43-
github.com/hashicorp/go-version v1.0.0 h1:21MVWPKDphxa7ineQQTrCU5brh7OuVVAzGOCnnCPtE8=
44-
github.com/hashicorp/go-version v1.0.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
4531
github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0=
4632
github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4=
47-
github.com/imdario/mergo v0.0.0-20141206190957-6633656539c1 h1:FeeCi0I2Fu8kA8IXrdVPtGzym+mW9bzfj9f26EaES9k=
48-
github.com/imdario/mergo v0.0.0-20141206190957-6633656539c1/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
33+
github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI=
34+
github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
4935
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
5036
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
51-
github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8 h1:12VvqtR6Aowv3l/EQUlocDHW2Cp4G9WJVH7uyH8QFJE=
52-
github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
5337
github.com/json-iterator/go v1.1.5 h1:gL2yXlmiIo4+t+y32d4WGwOjKGYcGOuyrg46vadswDE=
5438
github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
55-
github.com/jtolds/gls v4.2.1+incompatible h1:fSuqC+Gmlu6l/ZYAoZzx2pyucC8Xza35fpRVWLVmUEE=
56-
github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
5739
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
5840
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348 h1:MtvEpTB6LX3vkb4ax0b5D2DHbNAUsen0Gx5wZoq3lV4=
5941
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
60-
github.com/mitchellh/go-homedir v1.0.0 h1:vKb8ShqSby24Yrqr/yDYkuFz8d0WUjys40rvnGC8aR0=
61-
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
62-
github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0=
63-
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
6442
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
6543
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
6644
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
@@ -69,18 +47,12 @@ github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
6947
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
7048
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
7149
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
72-
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
73-
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
74-
github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a h1:JSvGDIbmil4Ui/dDdFBExb7/cmkNjyX5F97oglmvCDo=
75-
github.com/smartystreets/goconvey v0.0.0-20180222194500-ef6db91d284a/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s=
7650
github.com/spf13/cobra v0.0.3 h1:ZlrZ4XsMRm04Fr5pSFxBgfND2EBVa1nLpiy1stUsX/8=
7751
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
7852
github.com/spf13/pflag v1.0.2 h1:Fy0orTDgHdbnzHcsOgfCN4LtHf0ec3wwtiwJqwvf3Gc=
7953
github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
8054
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
8155
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
82-
github.com/ulikunitz/xz v0.5.4 h1:zATC2OoZ8H1TZll3FpbX+ikwmadbO699PE06cIkm9oU=
83-
github.com/ulikunitz/xz v0.5.4/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8=
8456
golang.org/x/crypto v0.0.0-20181009213950-7c1a557ab941 h1:qBTHLajHecfu+xzRI9PqVDcqx7SdHj9d4B+EzSn3tAc=
8557
golang.org/x/crypto v0.0.0-20181009213950-7c1a557ab941/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
8658
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
@@ -105,18 +77,16 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+
10577
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
10678
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
10779
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
108-
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0 h1:POO/ycCATvegFmVuPpQzZFJ+pGZeX22Ufu6fibxDVjU=
109-
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg=
11080
gopkg.in/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
11181
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
11282
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
11383
k8s.io/api v0.0.0-20180628040859-072894a440bd h1:HzgYeLDS1jLxw8DGr68KJh9cdQ5iZJizG0HZWstIhfQ=
11484
k8s.io/api v0.0.0-20180628040859-072894a440bd/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA=
11585
k8s.io/apimachinery v0.0.0-20180621070125-103fd098999d h1:MZjlsu9igBoVPZkXpIGoxI6EonqNsXXZU7hhvfQLkd4=
11686
k8s.io/apimachinery v0.0.0-20180621070125-103fd098999d/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0=
117-
k8s.io/client-go v7.0.0+incompatible h1:kiH+Y6hn+pc78QS/mtBfMJAMIIaWevHi++JvOGEEQp4=
118-
k8s.io/client-go v7.0.0+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s=
119-
k8s.io/helm v2.11.0-rc.4+incompatible h1:GAfCHQGqACuv1juOmFDQkrpmzRKL9sKtMa4KRhdlwoQ=
120-
k8s.io/helm v2.11.0-rc.4+incompatible/go.mod h1:LZzlS4LQBHfciFOurYBFkCMTaZ0D1l+p0teMg7TSULI=
121-
sigs.k8s.io/kustomize v1.0.10 h1:KngFW4wrk7VRlvk1vJOF498rkxp088d8IHSrFsT1rz4=
122-
sigs.k8s.io/kustomize v1.0.10/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU=
87+
k8s.io/client-go v10.0.0+incompatible h1:F1IqCqw7oMBzDkqlcBymRq1450wD0eNqLE9jzUrIi34=
88+
k8s.io/client-go v10.0.0+incompatible/go.mod h1:7vJpHMYJwNQCWgzmNV+VYUl1zCObLyodBc8nIyt8L5s=
89+
k8s.io/helm v2.13.0+incompatible h1:d1WBmGGoVb5VZcmQbysDbXGR0Kh/IXPe1SXldrdu19U=
90+
k8s.io/helm v2.13.0+incompatible/go.mod h1:LZzlS4LQBHfciFOurYBFkCMTaZ0D1l+p0teMg7TSULI=
91+
sigs.k8s.io/kustomize v2.0.3+incompatible h1:JUufWFNlI44MdtnjUqVnvh29rR37PQFzPbLXqhyOyX0=
92+
sigs.k8s.io/kustomize v2.0.3+incompatible/go.mod h1:MkjgH3RdOWrievjo6c9T245dYlB5QeXV4WCbnt/PEpU=

pkg/generators/comments.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ var commentsMapping = map[string]string{
2525
"# a file for custom resource definition(CRD).",
2626
"vars": "# Vars are used to insert values from resources that cannot\n" +
2727
"# be referenced otherwise.",
28-
"imageTags": "# ImageTags modify the tags for images without\n" +
28+
"images": "# Images modify the tags for images without\n" +
2929
"# creating patches.",
3030
}

pkg/generators/generators.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ func NewGenerator(force bool) *Generator {
3333
}
3434

3535
// Render to disk the kustomization.yaml, Kube-descriptor.yaml and associated resources
36-
func (g *Generator) Render(destination string, config *ktypes.Kustomization, metadata *chart.Metadata, resources *types.Resources, addConfigComments bool) error {
36+
func (g *Generator) Render(destination string, config *ktypes.Kustomization,
37+
metadata *chart.Metadata, resources *types.Resources, addConfigComments bool) error {
3738
var err error
3839

3940
// chech if destination path already exist, prompt user to confirm override
@@ -65,8 +66,10 @@ func (g *Generator) Render(destination string, config *ktypes.Kustomization, met
6566
}
6667
}
6768

68-
// render all config files
69-
for filename, data := range resources.ConfigFiles {
69+
// render all config and env files
70+
for filename, data := range resources.SourceFiles {
71+
// TODO: prevent overwriting of file, filename can be similar from one
72+
// resource to another
7073
err = writeFile(path.Join(destination, filename), []byte(data), 0644)
7174
if err != nil {
7275
return err

pkg/transformers/configmap.go

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package transformers
22

33
import (
4-
"fmt"
54
"regexp"
6-
"sort"
75

86
"github.com/ContainerSolutions/helm-convert/pkg/types"
97
"github.com/golang/glog"
@@ -51,38 +49,19 @@ func (t *configMapTransformer) Transform(config *ktypes.Kustomization, resources
5149
}
5250

5351
data := obj["data"].(map[string]interface{})
54-
55-
configMapArg := ktypes.ConfigMapArgs{
56-
Name: name,
57-
}
58-
59-
var fileSources []string
60-
var literalSources []string
61-
52+
dataMap := make(map[string]string, len(data))
6253
for key, value := range data {
63-
// if multiline, store as external file otherwise literal
64-
// TODO: detect if key/value file, ie: .env, .ini and set DataSources.EnvSource
65-
if v, ok := value.(string); ok {
66-
if regexpMultiline.MatchString(v) {
67-
glog.V(8).Infof("Converting '%s' as external file from configmap '%s'", key, name)
68-
filename := fmt.Sprintf("%s-%s", name, key)
69-
fileSources = append(fileSources, filename)
70-
resources.ConfigFiles[filename] = v
71-
} else {
72-
glog.V(8).Infof("Converting '%s' as literal value from configmap '%s'", key, name)
73-
literalSources = append(literalSources, fmt.Sprintf("%s=\"%s\"", key, value))
74-
}
75-
}
54+
dataMap[key] = value.(string)
7655
}
7756

78-
sort.Strings(literalSources)
79-
sort.Strings(fileSources)
80-
81-
configMapArg.DataSources = ktypes.DataSources{
82-
LiteralSources: literalSources,
83-
FileSources: fileSources,
57+
configMapArg := ktypes.ConfigMapArgs{
58+
GeneratorArgs: ktypes.GeneratorArgs{
59+
Name: name,
60+
},
8461
}
8562

63+
configMapArg.GeneratorArgs.DataSources = TransformDataSource(name, dataMap, resources.SourceFiles)
64+
8665
config.ConfigMapGenerator = append(config.ConfigMapGenerator, configMapArg)
8766
delete(resources.ResMap, res.Id())
8867
}

pkg/transformers/configmap_test.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,27 +54,29 @@ spring.datasource.password=pass123
5454
},
5555
}),
5656
},
57-
ConfigFiles: map[string]string{},
57+
SourceFiles: map[string]string{},
5858
},
5959
},
6060
expected: &configMapTransformerArgs{
6161
config: &ktypes.Kustomization{
6262
ConfigMapGenerator: []ktypes.ConfigMapArgs{
6363
ktypes.ConfigMapArgs{
64-
Name: "configmap1",
65-
DataSources: ktypes.DataSources{
66-
LiteralSources: []string{
67-
"SOME_ENV=\"development\"",
68-
"somekey=\"not a file\"",
64+
GeneratorArgs: ktypes.GeneratorArgs{
65+
Name: "configmap1",
66+
DataSources: ktypes.DataSources{
67+
LiteralSources: []string{
68+
"SOME_ENV=development",
69+
"somekey=not a file",
70+
},
71+
FileSources: []string{"configmap1-application.properties"},
6972
},
70-
FileSources: []string{"configmap1-application.properties"},
7173
},
7274
},
7375
},
7476
},
7577
resources: &types.Resources{
7678
ResMap: resmap.ResMap{},
77-
ConfigFiles: map[string]string{
79+
SourceFiles: map[string]string{
7880
"configmap1-application.properties": `
7981
app.name=My app
8082
spring.jpa.hibernate.ddl-auto=update
@@ -88,8 +90,11 @@ spring.datasource.password=pass123
8890
},
8991
} {
9092
t.Run(fmt.Sprintf("%s", test.name), func(t *testing.T) {
93+
res := types.NewResources()
94+
res.ResMap = test.input.resources.ResMap
95+
9196
lt := NewConfigMapTransformer()
92-
err := lt.Transform(test.input.config, test.input.resources)
97+
err := lt.Transform(test.input.config, res)
9398

9499
if err != nil {
95100
t.Fatalf("unexpected error: %v", err)
@@ -99,7 +104,7 @@ spring.datasource.password=pass123
99104
t.Errorf("%s, diff: (-got +want)\n%s", test.name, diff)
100105
}
101106

102-
if diff := pretty.Compare(test.input.resources, test.expected.resources); diff != "" {
107+
if diff := pretty.Compare(res, test.expected.resources); diff != "" {
103108
t.Errorf("%s, diff: (-got +want)\n%s", test.name, diff)
104109
}
105110
})

0 commit comments

Comments
 (0)