aboutsummaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/adapter/runtime.go6
-rw-r--r--pkg/adapter/runtime_remote.go27
-rw-r--r--pkg/varlinkapi/images.go13
3 files changed, 46 insertions, 0 deletions
diff --git a/pkg/adapter/runtime.go b/pkg/adapter/runtime.go
index 6a68a3aea..dd51c7233 100644
--- a/pkg/adapter/runtime.go
+++ b/pkg/adapter/runtime.go
@@ -23,6 +23,7 @@ import (
"github.com/containers/libpod/libpod/events"
"github.com/containers/libpod/libpod/image"
"github.com/containers/libpod/pkg/rootless"
+ "github.com/containers/storage/pkg/archive"
"github.com/pkg/errors"
)
@@ -430,3 +431,8 @@ func (r *LocalRuntime) Events(c *cliconfig.EventValues) error {
}
return nil
}
+
+// Diff shows the difference in two objects
+func (r *LocalRuntime) Diff(c *cliconfig.DiffValues, to string) ([]archive.Change, error) {
+ return r.Runtime.GetDiff("", to)
+}
diff --git a/pkg/adapter/runtime_remote.go b/pkg/adapter/runtime_remote.go
index dcc2d5aa6..c3a4f322d 100644
--- a/pkg/adapter/runtime_remote.go
+++ b/pkg/adapter/runtime_remote.go
@@ -831,3 +831,30 @@ func (r *LocalRuntime) Events(c *cliconfig.EventValues) error {
}
return nil
}
+
+// Diff ...
+func (r *LocalRuntime) Diff(c *cliconfig.DiffValues, to string) ([]archive.Change, error) {
+ var changes []archive.Change
+ reply, err := iopodman.Diff().Call(r.Conn, to)
+ if err != nil {
+ return nil, err
+ }
+ for _, change := range reply {
+ changes = append(changes, archive.Change{Path: change.Path, Kind: stringToChangeType(change.ChangeType)})
+ }
+ return changes, nil
+}
+
+func stringToChangeType(change string) archive.ChangeType {
+ switch change {
+ case "A":
+ return archive.ChangeAdd
+ case "D":
+ return archive.ChangeDelete
+ default:
+ logrus.Errorf("'%s' is unknown archive type", change)
+ fallthrough
+ case "C":
+ return archive.ChangeModify
+ }
+}
diff --git a/pkg/varlinkapi/images.go b/pkg/varlinkapi/images.go
index 0ca867410..63d500204 100644
--- a/pkg/varlinkapi/images.go
+++ b/pkg/varlinkapi/images.go
@@ -910,3 +910,16 @@ func (i *LibpodAPI) LoadImage(call iopodman.VarlinkCall, name, inputFile string,
}
return call.ReplyLoadImage(br)
}
+
+// Diff ...
+func (i *LibpodAPI) Diff(call iopodman.VarlinkCall, name string) error {
+ var response []iopodman.DiffInfo
+ changes, err := i.Runtime.GetDiff("", name)
+ if err != nil {
+ return call.ReplyErrorOccurred(err.Error())
+ }
+ for _, change := range changes {
+ response = append(response, iopodman.DiffInfo{Path: change.Path, ChangeType: change.Kind.String()})
+ }
+ return call.ReplyDiff(response)
+}