Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
don't push images at the end of multi-arch build (and simplify e2e te…
…sts) support DOCKER_DEFAULT_PLATFORM when 'compose up --build' add tests to check behaviour when DOCKER_DEFAULT_PLATFORM is defined Signed-off-by: Guillaume Lours <705411+glours@users.noreply.github.com>
- Loading branch information
Showing
11 changed files
with
159 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
pkg/e2e/fixtures/build-test/platforms/compose-multiple-platform-builds.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package utils | ||
|
||
import "reflect" | ||
|
||
// Contains helps to detect if a non-comparable struct is part of an array | ||
// only use this method if you can't rely on existing golang Contains function of slices (https://pkg.go.dev/golang.org/x/exp/slices#Contains) | ||
func Contains[T any](origin []T, element T) bool { | ||
for _, v := range origin { | ||
if reflect.DeepEqual(v, element) { | ||
return true | ||
} | ||
} | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package utils | ||
|
||
import ( | ||
specs "github.com/opencontainers/image-spec/specs-go/v1" | ||
"testing" | ||
) | ||
|
||
func TestContains(t *testing.T) { | ||
source := []specs.Platform{ | ||
{ | ||
Architecture: "linux/amd64", | ||
OS: "darwin", | ||
OSVersion: "", | ||
OSFeatures: nil, | ||
Variant: "", | ||
}, | ||
{ | ||
Architecture: "linux/arm64", | ||
OS: "linux", | ||
OSVersion: "12", | ||
OSFeatures: nil, | ||
Variant: "v8", | ||
}, | ||
{ | ||
Architecture: "", | ||
OS: "", | ||
OSVersion: "", | ||
OSFeatures: nil, | ||
Variant: "", | ||
}, | ||
} | ||
|
||
type args struct { | ||
origin []specs.Platform | ||
element specs.Platform | ||
} | ||
tests := []struct { | ||
name string | ||
args args | ||
want bool | ||
}{ | ||
{ | ||
name: "element found", | ||
args: args{ | ||
origin: source, | ||
element: specs.Platform{ | ||
Architecture: "linux/arm64", | ||
OS: "linux", | ||
OSVersion: "12", | ||
OSFeatures: nil, | ||
Variant: "v8", | ||
}, | ||
}, | ||
want: true, | ||
}, | ||
{ | ||
name: "element not found", | ||
args: args{ | ||
origin: source, | ||
element: specs.Platform{ | ||
Architecture: "linux/arm64", | ||
OS: "darwin", | ||
OSVersion: "12", | ||
OSFeatures: nil, | ||
Variant: "v8", | ||
}, | ||
}, | ||
want: false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := Contains(tt.args.origin, tt.args.element); got != tt.want { | ||
t.Errorf("Contains() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |