MCPcopy
hub / github.com/roboll/helmfile / TestReadFromYaml_OverrideNamespace

Function TestReadFromYaml_OverrideNamespace

pkg/state/create_test.go:184–269  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

182}
183
184func TestReadFromYaml_OverrideNamespace(t *testing.T) {
185 yamlFile := "/example/path/to/helmfile.yaml"
186 yamlContent := []byte(`environments:
187 production:
188 values:
189 - foo.yaml
190 - bar.yaml.gotmpl
191
192# A.k.a helmfile apply --namespace myns
193namespace: myns
194
195releases:
196- name: myrelease
197 namespace: mynamespace
198 chart: mychart
199 values:
200 - values.yaml.gotmpl
201`)
202
203 fooYamlFile := "/example/path/to/foo.yaml"
204 fooYamlContent := []byte(`foo: foo
205# As this file doesn't have an file extension ".gotmpl", this template expression should not be evaluated
206baz: "{{ readFile \"baz.txt\" }}"`)
207
208 barYamlFile := "/example/path/to/bar.yaml.gotmpl"
209 barYamlContent := []byte(`foo: FOO
210bar: {{ readFile "bar.txt" }}
211`)
212
213 barTextFile := "/example/path/to/bar.txt"
214 barTextContent := []byte("BAR")
215
216 expected := map[string]interface{}{
217 "foo": "FOO",
218 "bar": "BAR",
219 // As the file doesn't have an file extension ".gotmpl", this template expression should not be evaluated
220 "baz": "{{ readFile \"baz.txt\" }}",
221 }
222
223 valuesFile := "/example/path/to/values.yaml.gotmpl"
224 valuesContent := []byte(`env: {{ .Environment.Name }}
225releaseName: {{ .Release.Name }}
226releaseNamespace: {{ .Release.Namespace }}
227overrideNamespace: {{ .Namespace }}
228`)
229
230 expectedValues := `env: production
231releaseName: myrelease
232releaseNamespace: myns
233overrideNamespace: myns
234`
235
236 testFs := testhelper.NewTestFs(map[string]string{
237 fooYamlFile: string(fooYamlContent),
238 barYamlFile: string(barYamlContent),
239 barTextFile: string(barTextContent),
240 valuesFile: string(valuesContent),
241 })

Callers

nothing calls this directly

Calls 6

NewTestFsFunction · 0.92
NewRemoteFunction · 0.92
NewCreatorFunction · 0.85
ParseAndLoadMethod · 0.80
ApplyOverridesMethod · 0.80

Tested by

no test coverage detected