Display source of bake definitions when read from environment
While it would make sense to add "from file" to complement "from env," (in the common case of `--file` or using the default), it wouldn't provide any real value. A simpler solution would have been looking for the existence of the variable at the point where printing happens. It felt wrong duplicating the logic. Executing the same logic (if it was extracted) wouldn't be as bad, but still not ideal. A 'correct' solution would be to explicitly track the source of each definition, which would be clearer and more future-proof. It didn't seem like this feature warranted that amount of engineering (with no known features that might make use of it). This implementation seemed like a fair compromise; none of the functions are exported, and all have only one caller. I also considered converting prefixing environment values with `env://` so they could be thought of (and processed like) `cmd://` values. I didn't think it would be viewed as a good solution. Co-authored-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> Signed-off-by: Roberto Villarreal <rrjjvv@yahoo.com>
This commit is contained in:
co-authored by
CrazyMax
parent
cb54ddb9fe
commit
d44ffb4bd4
+5
-5
@@ -2213,7 +2213,7 @@ target "second" {
|
||||
|
||||
dt, err := cmd.CombinedOutput()
|
||||
require.NoError(t, err, string(dt))
|
||||
require.Contains(t, string(dt), `#1 [internal] load local bake definitions`)
|
||||
require.Contains(t, string(dt), `#1 [internal] load local bake definitions from BUILDX_BAKE_FILE env`)
|
||||
require.Contains(t, string(dt), `#1 reading first.hcl`)
|
||||
})
|
||||
|
||||
@@ -2230,7 +2230,7 @@ target "second" {
|
||||
|
||||
dt, err := cmd.CombinedOutput()
|
||||
require.NoError(t, err, string(dt))
|
||||
require.Contains(t, string(dt), `#1 [internal] load local bake definitions`)
|
||||
require.Contains(t, string(dt), `#1 [internal] load local bake definitions from BUILDX_BAKE_FILE env`)
|
||||
require.Contains(t, string(dt), `#1 reading first.hcl`)
|
||||
require.NotContains(t, string(dt), "docker-bake.hcl")
|
||||
})
|
||||
@@ -2249,7 +2249,7 @@ target "second" {
|
||||
withEnv("BUILDX_BAKE_FILE=first.hcl"+string(os.PathListSeparator)+"second.hcl"))
|
||||
dt, err := cmd.CombinedOutput()
|
||||
require.NoError(t, err, string(dt))
|
||||
require.Contains(t, string(dt), `#1 [internal] load local bake definitions`)
|
||||
require.Contains(t, string(dt), `#1 [internal] load local bake definitions from BUILDX_BAKE_FILE env`)
|
||||
require.Contains(t, string(dt), `#1 reading first.hcl`)
|
||||
require.Contains(t, string(dt), `#1 reading second.hcl`)
|
||||
})
|
||||
@@ -2269,7 +2269,7 @@ target "second" {
|
||||
|
||||
dt, err := cmd.CombinedOutput()
|
||||
require.NoError(t, err, string(dt))
|
||||
require.Contains(t, string(dt), `#1 [internal] load local bake definitions`)
|
||||
require.Contains(t, string(dt), `#1 [internal] load local bake definitions from BUILDX_BAKE_FILE env`)
|
||||
require.Contains(t, string(dt), `#1 reading first.hcl`)
|
||||
require.Contains(t, string(dt), `#1 reading second.hcl`)
|
||||
})
|
||||
@@ -2294,7 +2294,7 @@ target "second" {
|
||||
|
||||
dt, err := cmd.CombinedOutput()
|
||||
require.NoError(t, err, string(dt))
|
||||
require.Contains(t, string(dt), `#1 [internal] load local bake definitions`)
|
||||
require.Contains(t, string(dt), `#1 [internal] load local bake definitions from BUILDX_BAKE_FILE env`)
|
||||
require.Contains(t, string(dt), `#1 reading first.hcl`)
|
||||
require.Contains(t, string(dt), `#1 reading from stdin`)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user