renderCozystackExpectError mirrors renderCozystackWith but returns the render error to the caller instead of t.Fatal'ing on it. Used by tests that pin error-message contracts (fail-fast on malformed floatingIP, etc.). On unexpected success the returned error is nil and the caller is responsible for
(t *testing.T, lookup func(string, string, string) (map[string]any, error), overrides map[string]any, talosVersion ...string)
| 6872 | // Variadic talosVersion: defaults to v1.12 (multi-doc path); pass |
| 6873 | // "v1.11" or earlier to exercise the legacy network define. |
| 6874 | func renderCozystackExpectError(t *testing.T, lookup func(string, string, string) (map[string]any, error), overrides map[string]any, talosVersion ...string) error { |
| 6875 | t.Helper() |
| 6876 | origLookup := helmEngine.LookupFunc |
| 6877 | t.Cleanup(func() { helmEngine.LookupFunc = origLookup }) |
| 6878 | helmEngine.LookupFunc = lookup |
| 6879 | |
| 6880 | chrt, err := loader.LoadDir("../../charts/cozystack") |
| 6881 | if err != nil { |
| 6882 | t.Fatalf("load chart: %v", err) |
| 6883 | } |
| 6884 | values := cloneValues(chrt.Values) |
| 6885 | if v, _ := values["endpoint"].(string); v == "" { |
| 6886 | values["endpoint"] = testEndpoint |
| 6887 | } |
| 6888 | // Seed advertisedSubnets the same way renderChartTemplateWithLookup |
| 6889 | // does — otherwise an error test that targets a deeper validation |
| 6890 | // (e.g. malformed floatingIP) trips the empty-discovery required() |
| 6891 | // guard on advertisedSubnets first and surfaces the wrong error. |
| 6892 | // Callers that want to exercise the required() guard itself |
| 6893 | // override the field explicitly via the `overrides` argument. |
| 6894 | if arr, ok := values["advertisedSubnets"].([]any); !ok || len(arr) == 0 { |
| 6895 | values["advertisedSubnets"] = []any{testAdvertisedSubnet} |
| 6896 | } |
| 6897 | maps.Copy(values, overrides) |
| 6898 | |
| 6899 | version := "v1.12" |
| 6900 | if len(talosVersion) > 0 && talosVersion[0] != "" { |
| 6901 | version = talosVersion[0] |
| 6902 | } |
| 6903 | |
| 6904 | eng := helmEngine.Engine{} |
| 6905 | _, err = eng.Render(chrt, chartutil.Values{ |
| 6906 | "Values": values, |
| 6907 | "TalosVersion": version, |
| 6908 | }) |
| 6909 | |
| 6910 | return err //nolint:wrapcheck // surfacing the render error verbatim is the whole point of this helper |
| 6911 | } |
| 6912 | |
| 6913 | // renderGenericExpectError is the generic-preset counterpart of |
| 6914 | // renderCozystackExpectError. Used by mirror tests that pin the |
no test coverage detected