Merge pull request #18414 from vrothberg/fix-17763

history: correctly set tags
This commit is contained in:
OpenShift Merge Robot
2023-05-02 11:57:23 -04:00
committed by GitHub
9 changed files with 24 additions and 19 deletions

2
go.mod
View File

@ -13,7 +13,7 @@ require (
github.com/containernetworking/cni v1.1.2
github.com/containernetworking/plugins v1.2.0
github.com/containers/buildah v1.30.0
github.com/containers/common v0.53.0
github.com/containers/common v0.53.1-0.20230502134647-9cd0cc23c80f
github.com/containers/conmon v2.0.20+incompatible
github.com/containers/image/v5 v5.25.0
github.com/containers/libhvee v0.0.5

4
go.sum
View File

@ -239,8 +239,8 @@ github.com/containernetworking/plugins v1.2.0 h1:SWgg3dQG1yzUo4d9iD8cwSVh1VqI+bP
github.com/containernetworking/plugins v1.2.0/go.mod h1:/VjX4uHecW5vVimFa1wkG4s+r/s9qIfPdqlLF4TW8c4=
github.com/containers/buildah v1.30.0 h1:mdp2COGKFFEZNEGP8VZ5ITuUFVNPFoH+iK2sSesNfTA=
github.com/containers/buildah v1.30.0/go.mod h1:lyMLZIevpAa6zSzjRl7z4lFJMCMQLFjfo56YIefaB/U=
github.com/containers/common v0.53.0 h1:Ax814cLeX5VXSnkKUdxz762g+27fJj1st4UvKoXmkKs=
github.com/containers/common v0.53.0/go.mod h1:pABPxJwlTE8oYk9/2BW0e0mumkuhJHIPsABHTGRXN3w=
github.com/containers/common v0.53.1-0.20230502134647-9cd0cc23c80f h1:NGr0tr+qnavYQ3m+ajnrCLCp7y/YlGj14OXsYD5RhqY=
github.com/containers/common v0.53.1-0.20230502134647-9cd0cc23c80f/go.mod h1:uG5iTo9KbPxcyj3nsq0OPbBRTrSsrXKIMNRw4D6rt/w=
github.com/containers/conmon v2.0.20+incompatible h1:YbCVSFSCqFjjVwHTPINGdMX1F6JXHGTUje2ZYobNrkg=
github.com/containers/conmon v2.0.20+incompatible/go.mod h1:hgwZ2mtuDrppv78a/cOBNiCm6O0UMWGx1mu7P00nu5I=
github.com/containers/image/v5 v5.25.0 h1:TJ0unmalbU+scd0i3Txap2wjGsAnv06MSCwgn6bsizk=

View File

@ -92,15 +92,16 @@ func (ir *ImageEngine) Prune(ctx context.Context, opts entities.ImagePruneOption
}
func toDomainHistoryLayer(layer *libimage.ImageHistory) entities.ImageHistoryLayer {
l := entities.ImageHistoryLayer{}
l.ID = layer.ID
l := entities.ImageHistoryLayer{
Comment: layer.Comment,
CreatedBy: layer.CreatedBy,
ID: layer.ID,
Size: layer.Size,
Tags: layer.Tags,
}
if layer.Created != nil {
l.Created = *layer.Created
}
l.CreatedBy = layer.CreatedBy
copy(l.Tags, layer.Tags)
l.Size = layer.Size
l.Comment = layer.Comment
return l
}

View File

@ -73,7 +73,7 @@ for i in $iid ${iid:0:12} $PODMAN_TEST_IMAGE_NAME; do
t GET libpod/images/$i/history 200 \
.[0].Id=$iid \
.[0].Created~[0-9]\\{10\\} \
.[0].Tags=null \
.[0].Tags[0]="$IMAGE" \
.[0].Size=0 \
.[0].Comment=
done
@ -82,7 +82,7 @@ for i in $iid ${iid:0:12} $PODMAN_TEST_IMAGE_NAME; do
t GET images/$i/history 200 \
.[0].Id="sha256:"$iid \
.[0].Created~[0-9]\\{10\\} \
.[0].Tags=null \
.[0].Tags[0]="$IMAGE" \
.[0].Size=0 \
.[0].Comment=
done

View File

@ -27,6 +27,9 @@ load helpers
while IFS= read -r row; do
is "$row" ".* .*$"
done <<<$output
run_podman history --format "{{.Tags}}" $IMAGE
is "$output" "\[$IMAGE\].*" "podman history sets tags"
}
@test "podman history - json" {

View File

@ -51,7 +51,6 @@ func (i *Image) History(ctx context.Context) ([]ImageHistory, error) {
}
if layer != nil {
history.Tags = layer.Names
if !ociImage.History[x].EmptyLayer {
history.Size = layer.UncompressedSize
}
@ -64,8 +63,13 @@ func (i *Image) History(ctx context.Context) ([]ImageHistory, error) {
history.ID = id
usedIDs[id] = true
}
for i := range node.images {
history.Tags = append(history.Tags, node.images[i].Names()...)
}
}
if layer.Parent != "" && !ociImage.History[x].EmptyLayer {
if layer.Parent == "" {
layer = nil
} else if !ociImage.History[x].EmptyLayer {
layer, err = i.runtime.store.Layer(layer.Parent)
if err != nil {
return nil, err

View File

@ -8,14 +8,11 @@ import "golang.org/x/sys/unix"
// numCPU queries the system for the count of threads available
// for use to this process.
//
// Issues two syscalls.
// Returns 0 on errors. Use |runtime.NumCPU| in that case.
func numCPU() int {
// Gets the affinity mask for a process: The very one invoking this function.
pid := unix.Getpid()
var mask unix.CPUSet
err := unix.SchedGetaffinity(pid, &mask)
err := unix.SchedGetaffinity(0, &mask)
if err != nil {
return 0
}

View File

@ -1,4 +1,4 @@
package version
// Version is the version of the build.
const Version = "0.53.0"
const Version = "0.54.0-dev"

2
vendor/modules.txt vendored
View File

@ -125,7 +125,7 @@ github.com/containers/buildah/pkg/rusage
github.com/containers/buildah/pkg/sshagent
github.com/containers/buildah/pkg/util
github.com/containers/buildah/util
# github.com/containers/common v0.53.0
# github.com/containers/common v0.53.1-0.20230502134647-9cd0cc23c80f
## explicit; go 1.18
github.com/containers/common/libimage
github.com/containers/common/libimage/define