Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add enableReloader annotation #457

Merged
merged 2 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
## <</Stencil::Block>>
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ local all = {
},
metadata+: {
labels+: sharedLabels,
annotations+: {
'reloader.stakater.com/auto': 'true',
},
},
spec+: {
template+: {
Expand Down
5 changes: 5 additions & 0 deletions templates/deployments/appname/app.jsonnet.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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") }}
Expand Down
37 changes: 19 additions & 18 deletions templates/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ 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) {
st := stenciltest.New(t, "deployments/appname/app.jsonnet.tpl", libraryTmpls...)
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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -95,8 +95,9 @@ func TestRenderDeploymentJsonnetWithHPA(t *testing.T) {
},
},
},
"enableReloader": true,
})
st.Run(true)
st.Run(stenciltest.RegenerateSnapshots())
}

func TestUseKIAMFalse(t *testing.T) {
Expand All @@ -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) {
Expand All @@ -123,7 +124,7 @@ func TestRenderDeploymentDockerfile(t *testing.T) {
"alpine": "3.1",
},
})
st.Run(true)
st.Run(stenciltest.RegenerateSnapshots())
}

func TestRenderDependabot(t *testing.T) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -197,28 +198,28 @@ 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) {
st := stenciltest.New(t, "devspace.yaml.tpl", libraryTmpls...)
st.Args(map[string]interface{}{
"service": true,
})
st.Run(true)
st.Run(stenciltest.RegenerateSnapshots())
}

func TestVSCodeLaunchConfig(t *testing.T) {
st := stenciltest.New(t, ".vscode/launch.json.tpl", libraryTmpls...)
st.Args(map[string]interface{}{
"service": true,
})
st.Run(true)
st.Run(stenciltest.RegenerateSnapshots())
}

func TestGRPCServerRPC(t *testing.T) {
Expand All @@ -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) {
Expand Down