Sort unconsumed build arguments before usage

Golang map iteration order is not guaranteed, so in some cases the built slice has it's output of order as well. This means that testing for exact warning messages in docker build output would result in random test failures, making it more annoying for end-users to test against this functionality.

Signed-off-by: Jose Diaz-Gonzalez <email@josediazgonzalez.com>
This commit is contained in:
Jose Diaz-Gonzalez 2023-07-09 03:18:00 -04:00
parent c57097bcd4
commit 079a9d4562

View file

@ -3,6 +3,7 @@ package dockerfile // import "github.com/docker/docker/builder/dockerfile"
import (
"fmt"
"io"
"sort"
"github.com/docker/docker/runconfig/opts"
)
@ -80,6 +81,7 @@ func (b *BuildArgs) WarnOnUnusedBuildArgs(out io.Writer) {
}
}
if len(leftoverArgs) > 0 {
sort.Strings(leftoverArgs)
fmt.Fprintf(out, "[Warning] One or more build-args %v were not consumed\n", leftoverArgs)
}
}