mirror of
https://github.com/GoogleContainerTools/kaniko
synced 2026-10-17 20:45:18 +02:00
Changed image name to be full image name minus tag. Also added test for new ImageNameDigestFile flag
This commit is contained in:
@@ -141,7 +141,7 @@ func DoPush(image v1.Image, opts *config.KanikoOptions) error {
|
||||
return errors.Wrap(err, "getting tag for destination")
|
||||
}
|
||||
if opts.ImageNameDigestFile != "" {
|
||||
imageName := []byte(destination + "@")
|
||||
imageName := []byte(destRef.Repository.Name() + "@")
|
||||
builder.Write(append(imageName, digestByteArray...))
|
||||
builder.WriteString("\n")
|
||||
}
|
||||
|
||||
@@ -192,3 +192,34 @@ func TestOCILayoutPath(t *testing.T) {
|
||||
got, err := layoutImage.Manifest()
|
||||
testutil.CheckErrorAndDeepEqual(t, false, err, want, got)
|
||||
}
|
||||
|
||||
func TestImageNameDigestFile(t *testing.T) {
|
||||
image, err := random.Image(1024, 4)
|
||||
if err != nil {
|
||||
t.Fatalf("could not create image: %s", err)
|
||||
}
|
||||
|
||||
digest, err := image.Digest()
|
||||
if err != nil {
|
||||
t.Fatalf("could not get image digest: %s", err)
|
||||
}
|
||||
|
||||
opts := config.KanikoOptions{
|
||||
NoPush: true,
|
||||
Destinations: []string{"gcr.io/foo/bar:latest", "bob/image"},
|
||||
ImageNameDigestFile: "tmpFile",
|
||||
}
|
||||
|
||||
defer os.Remove("tmpFile")
|
||||
|
||||
if err := DoPush(image, &opts); err != nil {
|
||||
t.Fatalf("could not push image: %s", err)
|
||||
}
|
||||
|
||||
want := []byte("gcr.io/foo/bar@" + digest.String() + "\nindex.docker.io/bob/image@" + digest.String() +"\n")
|
||||
|
||||
got, err := ioutil.ReadFile("tmpFile")
|
||||
|
||||
testutil.CheckErrorAndDeepEqual(t, false, err, want, got)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user