Skip to content

Commit 43b1f16

Browse files
feat: write runtime templates & other fixes (#7)
* feat: update go to 1.20 Signed-off-by: Mathew Wicks <[email protected]> * feat: write runtime templates Signed-off-by: Mathew Wicks <[email protected]> * ci: pin builds to go 1.20.4 Signed-off-by: Mathew Wicks <[email protected]> --------- Signed-off-by: Mathew Wicks <[email protected]>
1 parent d6964a7 commit 43b1f16

File tree

8 files changed

+101
-45
lines changed

8 files changed

+101
-45
lines changed

.github/workflows/check-commit.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Set up Go
1616
uses: actions/setup-go@v4
1717
with:
18-
go-version: 1.19
18+
go-version: "1.20.4"
1919

2020
- name: Install golangci-lint
2121
run: |
@@ -33,7 +33,7 @@ jobs:
3333
- name: Set up Go
3434
uses: actions/setup-go@v4
3535
with:
36-
go-version: 1.19
36+
go-version: "1.20.4"
3737

3838
- name: Run Tests
3939
run: make test
@@ -47,7 +47,7 @@ jobs:
4747
- name: Set up Go
4848
uses: actions/setup-go@v4
4949
with:
50-
go-version: 1.19
50+
go-version: "1.20.4"
5151

5252
- name: Build single target
5353
run: make build

.github/workflows/check-pr.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Set up Go
2020
uses: actions/setup-go@v4
2121
with:
22-
go-version: 1.19
22+
go-version: "1.20.4"
2323

2424
- name: Install golangci-lint
2525
run: |
@@ -37,7 +37,7 @@ jobs:
3737
- name: Set up Go
3838
uses: actions/setup-go@v4
3939
with:
40-
go-version: 1.19
40+
go-version: "1.20.4"
4141

4242
- name: Run Tests
4343
run: make test
@@ -51,7 +51,7 @@ jobs:
5151
- name: Set up Go
5252
uses: actions/setup-go@v4
5353
with:
54-
go-version: 1.19
54+
go-version: "1.20.4"
5555

5656
- name: Build single target
5757
run: make build

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Set up Go
1919
uses: actions/setup-go@v4
2020
with:
21-
go-version: 1.19
21+
go-version: "1.20.4"
2222

2323
- name: Build all targets
2424
run: make build-all

cmd/deploykf/generate.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,14 @@ func (o *generateOptions) run(out io.Writer) error {
169169
return err
170170
}
171171

172+
// write runtime config templates
173+
// - note, we are writing these files into the source folder, not the output folder
174+
runtimePath := filepath.Join(tempSourcePath, "runtime")
175+
err = generate.WriteRuntimeTemplates(runtimePath, templatesPath, o.outputDir)
176+
if err != nil {
177+
return err
178+
}
179+
172180
// GENERATOR PHASE 1: render `.gomplateignore_template` files
173181
// - note, we are rendering the `.gomplateignore` files into the generator source
174182
// templates folder, not the output folder
@@ -180,7 +188,7 @@ func (o *generateOptions) run(out io.Writer) error {
180188
RDelim: ">}}",
181189
DataSources: o.gomplateDataSources(),
182190
Contexts: o.gomplateContexts(defaultValuesPath),
183-
Templates: o.gomplateTemplates(helpersPath),
191+
Templates: o.gomplateTemplates(helpersPath, runtimePath),
184192
SuppressEmpty: true,
185193
}
186194
err = gomplate.RunTemplates(phase1Config) //nolint:staticcheck
@@ -220,7 +228,7 @@ func (o *generateOptions) run(out io.Writer) error {
220228
RDelim: ">}}",
221229
DataSources: o.gomplateDataSources(),
222230
Contexts: o.gomplateContexts(defaultValuesPath),
223-
Templates: o.gomplateTemplates(helpersPath),
231+
Templates: o.gomplateTemplates(helpersPath, runtimePath),
224232
SuppressEmpty: true,
225233
}
226234
err = gomplate.RunTemplates(phase2Config) //nolint:staticcheck
@@ -280,6 +288,9 @@ func (o *generateOptions) gomplateContexts(defaultValuesPath string) []string {
280288
}
281289

282290
// build the `Templates` for our `gomplate.Config`
283-
func (o *generateOptions) gomplateTemplates(helpersPath string) []string {
284-
return []string{"helpers=" + helpersPath}
291+
func (o *generateOptions) gomplateTemplates(helpersPath string, runtimePath string) []string {
292+
return []string{
293+
"helpers=" + helpersPath,
294+
"runtime=" + runtimePath,
295+
}
285296
}

go.mod

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
module github.com/deployKF/cli
22

3-
go 1.19
3+
go 1.20
44

5-
// temporarrily replace upstream gomplate with our fork
6-
// - https://github.com/thesuperzapper/gomplate/tree/3-11-4-templates-fix-and-suppress-empty
5+
// note, we have forked gomplate to apply some changes:
6+
// - https://github.com/deployKF/gomplate/tree/fork-3.11.5
77
//
8-
// TODO: remove after gomplate applies these PRs:
9-
// - fix using templates in `gomplate.RunTemplates()`
10-
// https://github.com/hairyhenderson/gomplate/pull/1690
11-
// - expose `SuppressEmpty` in `gomplate.Config`
12-
// https://github.com/hairyhenderson/gomplate/pull/1691
8+
// to get the pseudoversion of the fork, run:
9+
// - go get github.com/deploykf/gomplate/v3@{COMMIT_HASH}
1310
//
14-
replace github.com/hairyhenderson/gomplate/v3 => github.com/thesuperzapper/gomplate/v3 v3.0.0-20230329194704-40166f31ee76
11+
// the following changes are applied:
12+
// - allow writing files outside working directory
13+
// - allow setting SuppressEmpty in `gomplate.Config`
14+
// - fix reading templates in `gomplate.RunTemplates()`
15+
//
16+
replace github.com/hairyhenderson/gomplate/v3 => github.com/deploykf/gomplate/v3 v3.0.0-20230523053447-c7847da61baa
1517

1618
require (
1719
github.com/google/go-github/v50 v50.2.0
18-
github.com/hairyhenderson/gomplate/v3 v3.11.4
19-
github.com/pkg/errors v0.9.1
20-
github.com/spf13/cobra v1.6.1
20+
github.com/hairyhenderson/gomplate/v3 v3.11.5
21+
github.com/spf13/cobra v1.7.0
2122
)
2223

2324
require (
@@ -97,7 +98,7 @@ require (
9798
github.com/hashicorp/vault/sdk v0.5.0 // indirect
9899
github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 // indirect
99100
github.com/imdario/mergo v0.3.13 // indirect
100-
github.com/inconshreveable/mousetrap v1.0.1 // indirect
101+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
101102
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
102103
github.com/jmespath/go-jmespath v0.4.0 // indirect
103104
github.com/joho/godotenv v1.4.0 // indirect
@@ -111,6 +112,7 @@ require (
111112
github.com/mitchellh/reflectwalk v1.0.2 // indirect
112113
github.com/oklog/run v1.1.0 // indirect
113114
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
115+
github.com/pkg/errors v0.9.1 // indirect
114116
github.com/rs/zerolog v1.26.1 // indirect
115117
github.com/ryanuber/go-glob v1.0.0 // indirect
116118
github.com/sergi/go-diff v1.2.0 // indirect
@@ -126,10 +128,10 @@ require (
126128
go4.org/unsafe/assume-no-moving-gc v0.0.0-20230204201903-c31fa085b70e // indirect
127129
gocloud.dev v0.25.1-0.20220408200107-09b10f7359f7 // indirect
128130
golang.org/x/crypto v0.7.0 // indirect
129-
golang.org/x/net v0.8.0 // indirect
130-
golang.org/x/oauth2 v0.6.0 // indirect
131-
golang.org/x/sys v0.6.0 // indirect
132-
golang.org/x/text v0.8.0 // indirect
131+
golang.org/x/net v0.9.0 // indirect
132+
golang.org/x/oauth2 v0.7.0 // indirect
133+
golang.org/x/sys v0.7.0 // indirect
134+
golang.org/x/text v0.9.0 // indirect
133135
golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect
134136
golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect
135137
google.golang.org/api v0.81.0 // indirect

go.sum

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
252252
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
253253
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
254254
github.com/denisenkom/go-mssqldb v0.12.0/go.mod h1:iiK0YP1ZeepvmBQk/QpLEhhTNJgfzrpArPY/aFvc9yU=
255+
github.com/deploykf/gomplate/v3 v3.0.0-20230523053447-c7847da61baa h1:GVaRYv4tnoeSk4GN2IFGw75ekPhitb2fUurlavG6Ybk=
256+
github.com/deploykf/gomplate/v3 v3.0.0-20230523053447-c7847da61baa/go.mod h1:ZE9/H+5uDrIYkfSn1oSjd/JxXoh/IIRPe6KZj3HamTw=
255257
github.com/devigned/tab v0.1.1/go.mod h1:XG9mPq0dFghrYvoBF3xdRrJzSTX1b7IQrvaL9mzjeJY=
256258
github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8=
257259
github.com/dimchansky/utfbom v1.1.1/go.mod h1:SxdoEBH5qIqFocHMyGOXVAybYJdr71b1Q/j0mACtrfE=
@@ -568,8 +570,8 @@ github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJ
568570
github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA=
569571
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
570572
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
571-
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
572-
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
573+
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
574+
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
573575
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
574576
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
575577
github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
@@ -793,8 +795,8 @@ github.com/spf13/afero v1.2.0/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTd
793795
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
794796
github.com/spf13/afero v1.8.2 h1:xehSyVa0YnHWsJ49JFljMpg1HX19V6NDZ1fkm1Xznbo=
795797
github.com/spf13/afero v1.8.2/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo=
796-
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
797-
github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
798+
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
799+
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
798800
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
799801
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
800802
github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8=
@@ -809,8 +811,6 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
809811
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
810812
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
811813
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
812-
github.com/thesuperzapper/gomplate/v3 v3.0.0-20230329194704-40166f31ee76 h1:4JJUYtgr9mUVDKCQQF6IL0Ky+NyJ8zbt99R0KSDkwd4=
813-
github.com/thesuperzapper/gomplate/v3 v3.0.0-20230329194704-40166f31ee76/go.mod h1:23Q996Cny7+kef4xLSVBoZab7xmKi4wCGvP0CxvKhGU=
814814
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
815815
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
816816
github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
@@ -991,8 +991,8 @@ golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su
991991
golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
992992
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
993993
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
994-
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
995-
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
994+
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
995+
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
996996
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
997997
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
998998
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -1014,8 +1014,8 @@ golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ
10141014
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc=
10151015
golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc=
10161016
golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc=
1017-
golang.org/x/oauth2 v0.6.0 h1:Lh8GPgSKBfWSwFvtuWOfeI3aAAnbXTSutYxJiOJFgIw=
1018-
golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw=
1017+
golang.org/x/oauth2 v0.7.0 h1:qe6s0zUXlPX80/dITx3440hWZ7GwMwgDDyrSGTPJG/g=
1018+
golang.org/x/oauth2 v0.7.0/go.mod h1:hPLQkd9LyjfXTiRohC/41GhcFqxisoUQ99sCUOHO9x4=
10191019
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
10201020
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
10211021
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@@ -1125,13 +1125,13 @@ golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBc
11251125
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
11261126
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
11271127
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1128-
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
1129-
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1128+
golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
1129+
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
11301130
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
11311131
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
11321132
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
11331133
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
1134-
golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw=
1134+
golang.org/x/term v0.7.0 h1:BEvjmm5fURWqcfbSKTdpkDXYBrUS1c0m8agp14W48vQ=
11351135
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
11361136
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
11371137
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -1142,8 +1142,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
11421142
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
11431143
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
11441144
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
1145-
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
1146-
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
1145+
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
1146+
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
11471147
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
11481148
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
11491149
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=

internal/generate/runtime.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package generate
2+
3+
import (
4+
"os"
5+
"path/filepath"
6+
)
7+
8+
const (
9+
InputDirTemplateFile = "input_dir"
10+
OutputDirTemplateFile = "output_dir"
11+
)
12+
13+
// WriteRuntimeTemplates writes the runtime templates to the specified directory
14+
func WriteRuntimeTemplates(runtimeTemplatePath string, inputDirConfig string, outputDirConfig string) error {
15+
// check if the runtime templates folder exists, and create it if not
16+
runtimeDirExists, err := DirectoryExists(runtimeTemplatePath)
17+
if err != nil {
18+
return err
19+
}
20+
if !runtimeDirExists {
21+
err = os.MkdirAll(runtimeTemplatePath, 0755)
22+
if err != nil {
23+
return err
24+
}
25+
}
26+
27+
// write `--input-dir` config as a template file
28+
inputDirTemplatePath := filepath.Join(runtimeTemplatePath, InputDirTemplateFile)
29+
err = os.WriteFile(inputDirTemplatePath, []byte(inputDirConfig), 0644)
30+
if err != nil {
31+
return err
32+
}
33+
34+
// write `--output-dir` config as a template file
35+
outputDirTemplatePath := filepath.Join(runtimeTemplatePath, OutputDirTemplateFile)
36+
err = os.WriteFile(outputDirTemplatePath, []byte(outputDirConfig), 0644)
37+
if err != nil {
38+
return err
39+
}
40+
41+
return nil
42+
}

internal/require/args.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
package require
22

33
import (
4-
"github.com/pkg/errors"
4+
"fmt"
5+
56
"github.com/spf13/cobra"
67
)
78

89
// NoArgs returns an error if any args are included.
910
func NoArgs(cmd *cobra.Command, args []string) error {
1011
if len(args) > 0 {
11-
return errors.Errorf(
12+
return fmt.Errorf(
1213
"%q accepts no arguments\n\nUsage: %s",
1314
cmd.CommandPath(),
1415
cmd.UseLine(),

0 commit comments

Comments
 (0)