mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00

First, make podman diff accept optionally a second argument. This allows the user to specify a second image/container to compare the first with. If it is not set the parent layer will be used as before. Second, podman container diff should only use containers and podman image diff should only use images. Previously, podman container diff would use the image when both an image and container with this name exists. To make this work two new parameters have been added to the api. If they are not used the previous behaviour is used. The same applies to the bindings. Fixes #10649 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
32 lines
725 B
Go
32 lines
725 B
Go
package containers
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
|
|
"github.com/containers/podman/v3/pkg/bindings"
|
|
"github.com/containers/storage/pkg/archive"
|
|
)
|
|
|
|
// Diff provides the changes between two container layers
|
|
func Diff(ctx context.Context, nameOrID string, options *DiffOptions) ([]archive.Change, error) {
|
|
if options == nil {
|
|
options = new(DiffOptions)
|
|
}
|
|
conn, err := bindings.GetClient(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
params, err := options.ToParams()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
response, err := conn.DoRequest(nil, http.MethodGet, "/containers/%s/changes", params, nil, nameOrID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var changes []archive.Change
|
|
return changes, response.Process(&changes)
|
|
}
|