You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a fallback to inline environment when path doesn't exist (#637)
* Add a fallback to inline environment when path doesn't exist
* Add test + better error message in case of env not being found
Co-authored-by: Julien Duchesne <[email protected]>
Copy file name to clipboardExpand all lines: pkg/tanka/errors.go
+8-3
Original file line number
Diff line number
Diff line change
@@ -17,12 +17,17 @@ func (e ErrNoEnv) Error() string {
17
17
18
18
// ErrMultipleEnvs means that the given jsonnet has multiple Environment objects
19
19
typeErrMultipleEnvsstruct {
20
-
pathstring
21
-
names []string
20
+
pathstring
21
+
givenNamestring
22
+
foundEnvs []string
22
23
}
23
24
24
25
func (eErrMultipleEnvs) Error() string {
25
-
returnfmt.Sprintf("found multiple Environments in '%s'. Use `--name` to select a single one: \n - %s", e.path, strings.Join(e.names, "\n - "))
26
+
ife.givenName!="" {
27
+
returnfmt.Sprintf("found multiple Environments in %q matching %q. Provide a more specific name that matches a single one: \n - %s", e.path, e.givenName, strings.Join(e.foundEnvs, "\n - "))
28
+
}
29
+
30
+
returnfmt.Sprintf("found multiple Environments in %q. Use `--name` to select a single one: \n - %s", e.path, strings.Join(e.foundEnvs, "\n - "))
26
31
}
27
32
28
33
// ErrParallel is an array of errors collected while processing in parallel
assert.EqualError(t, err, "found multiple Environments in './testdata/cases/multiple-inline-envs'. Use `--name` to select a single one: \n - project1-env1\n - project1-env2\n - project2-env1")
161
+
assert.EqualError(t, err, "found multiple Environments in \"./testdata/cases/multiple-inline-envs\". Use `--name` to select a single one: \n - project1-env1\n - project1-env2\n - project2-env1")
assert.EqualError(t, err, "found multiple Environments in './testdata/cases/multiple-inline-envs'. Use `--name` to select a single one: \n - project1-env1\n - project2-env1")
165
+
assert.EqualError(t, err, "found multiple Environments in \"./testdata/cases/multiple-inline-envs\" matching \"env1\". Provide a more specific name that matches a single one: \n - project1-env1\n - project2-env1")
assert.EqualError(t, err, "found multiple Environments in \".\" matching \"env1\". Provide a more specific name that matches a single one: \n - project1-env1\n - project2-env1")
0 commit comments