Skip to content

Commit

Permalink
debug missing os
Browse files Browse the repository at this point in the history
  • Loading branch information
pn-santos committed Oct 31, 2024
1 parent 72ca564 commit d5b5210
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/google/go-containerregistry/pkg/registry"
v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/layout"
"github.com/google/go-containerregistry/pkg/v1/mutate"
"github.com/google/go-containerregistry/pkg/v1/random"
"github.com/google/go-containerregistry/pkg/v1/remote"
"github.com/google/go-containerregistry/pkg/v1/tarball"
Expand Down Expand Up @@ -330,12 +331,18 @@ func (s *TaskSuite) TestImageArgs() {

firstImage, err := random.Image(1024, 2)
s.NoError(err)

firstImage = s.withPlatform(firstImage, "linux", "amd64")

firstPath := filepath.Join(imagesDir, "first.tar")
err = tarball.WriteToFile(firstPath, nil, firstImage)
s.NoError(err)

secondImage, err := random.Image(1024, 2)
s.NoError(err)

secondImage = s.withPlatform(secondImage, "linux", "amd64")

secondPath := filepath.Join(imagesDir, "second.tar")
err = tarball.WriteToFile(secondPath, nil, secondImage)
s.NoError(err)
Expand Down Expand Up @@ -651,6 +658,20 @@ func (s *TaskSuite) imageMetadata(output string) (task.ImageMetadata, error) {
return meta, nil
}

func (s *TaskSuite) withPlatform(image v1.Image, os string, arch string) v1.Image {
cf, err := image.ConfigFile()
s.NoError(err)

cf = cf.DeepCopy()
cf.OS = "linux"
cf.Architecture = "amd64"

image, err = mutate.ConfigFile(image, cf)
s.NoError(err)

return image
}

func TestSuite(t *testing.T) {
suite.Run(t, &TaskSuite{
Assertions: require.New(t),
Expand Down

0 comments on commit d5b5210

Please sign in to comment.