diff --git a/go.mod b/go.mod index 9bb7c9c..0b36d3f 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ go 1.19 require ( github.com/blang/semver/v4 v4.0.0 github.com/getoutreach/gobox v1.89.0 - github.com/getoutreach/stencil v1.37.3 + github.com/getoutreach/stencil v1.38.0 github.com/google/go-cmp v0.6.0 github.com/magefile/mage v1.15.0 github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index 4d8a22c..0ee2001 100644 --- a/go.sum +++ b/go.sum @@ -46,8 +46,8 @@ github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4Nij github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= github.com/getoutreach/gobox v1.89.0 h1:wPuBGcFnFmyD0OdvZH/QkW86lNkp2sepfgOjjwUDsKU= github.com/getoutreach/gobox v1.89.0/go.mod h1:w7K/e3SU+CWhu9KmnuRdXBHGWau4yE5dW5Tqb+MWZiU= -github.com/getoutreach/stencil v1.37.3 h1:U+OS7eoFb9K4t6MQBQpFgtBipOjo7r6agI81VXEoETw= -github.com/getoutreach/stencil v1.37.3/go.mod h1:QUu/RIa6NxukXe33OEcrIEUWGTE+psnrN7M8872vhGI= +github.com/getoutreach/stencil v1.38.0 h1:GwtBGTn/RHPFfLV9qIceA6LTcd7s0RSpP7IW7kzRl6A= +github.com/getoutreach/stencil v1.38.0/go.mod h1:nYHADbhmoVVFL2FLmzRC7nbqTbI9yLbRliZblVKO8E8= github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= diff --git a/manifest.yaml b/manifest.yaml index 8fab0cd..62ebb6b 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -248,4 +248,8 @@ arguments: description: Min replicas for production envs schema: type: number + enableReloader: + description: Enable Reloader to cycle pods when secrets or configmaps are modified + schema: + type: boolean ## <> diff --git a/templates/.snapshots/TestRenderDeploymentJsonnetWithHPA-deployments-appname-app.jsonnet.tpl-deployments-testing-testing.jsonnet.snapshot b/templates/.snapshots/TestRenderDeploymentJsonnetWithHPA-deployments-appname-app.jsonnet.tpl-deployments-testing-testing.jsonnet.snapshot index 1367bda..e1f6d3d 100644 --- a/templates/.snapshots/TestRenderDeploymentJsonnetWithHPA-deployments-appname-app.jsonnet.tpl-deployments-testing-testing.jsonnet.snapshot +++ b/templates/.snapshots/TestRenderDeploymentJsonnetWithHPA-deployments-appname-app.jsonnet.tpl-deployments-testing-testing.jsonnet.snapshot @@ -133,6 +133,9 @@ local all = { }, metadata+: { labels+: sharedLabels, + annotations+: { + 'reloader.stakater.com/auto': 'true', + }, }, spec+: { template+: { diff --git a/templates/deployments/appname/app.jsonnet.tpl b/templates/deployments/appname/app.jsonnet.tpl index 6740e9f..2eb2f8f 100644 --- a/templates/deployments/appname/app.jsonnet.tpl +++ b/templates/deployments/appname/app.jsonnet.tpl @@ -204,6 +204,11 @@ local all = { }, metadata+: { labels+: sharedLabels, + {{- if (stencil.Arg "enableReloader") }} + annotations+: { + 'reloader.stakater.com/auto': 'true', + }, + {{- end }} }, spec+: { {{- if not (stencil.Arg "hpa.enabled") }} diff --git a/templates/main_test.go b/templates/main_test.go index fe6c993..cfa9a3a 100644 --- a/templates/main_test.go +++ b/templates/main_test.go @@ -20,12 +20,12 @@ func TestRenderAPIGoSuccess(t *testing.T) { // the ServiceManifest used by the `Run()` method in stenciltest, which is // why this test does not verify correct handling of odd service names. st := stenciltest.New(t, "api/api.go.tpl", libraryTmpls...) - st.Run(true) + st.Run(stenciltest.RegenerateSnapshots()) } func TestRenderDeploymentConfig(t *testing.T) { st := stenciltest.New(t, "deployments/appname/app.config.jsonnet.tpl", libraryTmpls...) - st.Run(true) + st.Run(stenciltest.RegenerateSnapshots()) } func TestRenderDeploymentJsonnet(t *testing.T) { @@ -33,7 +33,7 @@ func TestRenderDeploymentJsonnet(t *testing.T) { st.Args(map[string]interface{}{ "mixins": []interface{}{"c", "b", "a"}, // These should be sorted alphabetically in the snapshot }) - st.Run(true) + st.Run(stenciltest.RegenerateSnapshots()) } func TestRenderDeploymentJsonnet_Canary(t *testing.T) { @@ -50,7 +50,7 @@ func TestRenderDeploymentJsonnet_Canary(t *testing.T) { }, "slack": "hello", }) - st.Run(true) + st.Run(stenciltest.RegenerateSnapshots()) } func TestRenderDeploymentJsonnet_Canary_emptyServiceActivities(t *testing.T) { @@ -64,7 +64,7 @@ func TestRenderDeploymentJsonnet_Canary_emptyServiceActivities(t *testing.T) { "serviceActivities": []interface{}{}, "slack": "hello", }) - st.Run(true) + st.Run(stenciltest.RegenerateSnapshots()) } func TestRenderDeploymentJsonnetWithHPA(t *testing.T) { @@ -95,8 +95,9 @@ func TestRenderDeploymentJsonnetWithHPA(t *testing.T) { }, }, }, + "enableReloader": true, }) - st.Run(true) + st.Run(stenciltest.RegenerateSnapshots()) } func TestUseKIAMFalse(t *testing.T) { @@ -111,7 +112,7 @@ func TestUseKIAMFalse(t *testing.T) { func TestRenderDeploymentOverride(t *testing.T) { st := stenciltest.New(t, "deployments/appname/app.override.jsonnet.tpl", libraryTmpls...) - st.Run(true) + st.Run(stenciltest.RegenerateSnapshots()) } func TestRenderDeploymentDockerfile(t *testing.T) { @@ -123,7 +124,7 @@ func TestRenderDeploymentDockerfile(t *testing.T) { "alpine": "3.1", }, }) - st.Run(true) + st.Run(stenciltest.RegenerateSnapshots()) } func TestRenderDependabot(t *testing.T) { @@ -133,7 +134,7 @@ func TestRenderDependabot(t *testing.T) { "serviceActivities": []interface{}{"grpc"}, "grpcClients": []interface{}{"node"}, }) - st.Run(true) + st.Run(stenciltest.RegenerateSnapshots()) } func TestBasicGoMod(t *testing.T) { @@ -145,7 +146,7 @@ func TestBasicGoMod(t *testing.T) { } st.Ext("github.com/getoutreach/stencil-golang", p) - st.Run(true) + st.Run(stenciltest.RegenerateSnapshots()) } func TestMergeGoMod(t *testing.T) { @@ -164,7 +165,7 @@ func TestMergeGoMod(t *testing.T) { } defer os.Remove("go.mod") - st.Run(true) + st.Run(stenciltest.RegenerateSnapshots()) } func TestGoModStanzaVersion(t *testing.T) { @@ -181,7 +182,7 @@ func TestGoModStanzaVersion(t *testing.T) { } st.Ext("github.com/getoutreach/stencil-golang", p) - st.Run(true) + st.Run(stenciltest.RegenerateSnapshots()) } func TestDevenvYaml(t *testing.T) { @@ -197,12 +198,12 @@ func TestDevenvYaml(t *testing.T) { }, }, }) - st.Run(true) + st.Run(stenciltest.RegenerateSnapshots()) } func TestEmptyDevenvYaml(t *testing.T) { st := stenciltest.New(t, "devenv.yaml.tpl", libraryTmpls...) - st.Run(true) + st.Run(stenciltest.RegenerateSnapshots()) } func TestDevspaceYaml(t *testing.T) { @@ -210,7 +211,7 @@ func TestDevspaceYaml(t *testing.T) { st.Args(map[string]interface{}{ "service": true, }) - st.Run(true) + st.Run(stenciltest.RegenerateSnapshots()) } func TestVSCodeLaunchConfig(t *testing.T) { @@ -218,7 +219,7 @@ func TestVSCodeLaunchConfig(t *testing.T) { st.Args(map[string]interface{}{ "service": true, }) - st.Run(true) + st.Run(stenciltest.RegenerateSnapshots()) } func TestGRPCServerRPC(t *testing.T) { @@ -237,13 +238,13 @@ func TestIncludeRubyToolVersionsIfRubyGRPCCLient(t *testing.T) { st.Args(map[string]interface{}{ "grpcClients": []interface{}{"ruby"}, }) - st.Run(true) + st.Run(stenciltest.RegenerateSnapshots()) } func TestDontIncludeRubyToolVersionsIfNotRubyGRPCCLient(t *testing.T) { st := stenciltest.New(t, "testdata/tool-versions-ruby/.tool-versions.tpl", libraryTmpls...) st.Args(map[string]interface{}{}) - st.Run(true) + st.Run(stenciltest.RegenerateSnapshots()) } func TestGoreleaserYml(t *testing.T) {