summaryrefslogtreecommitdiff
path: root/pkg/varlinkapi/util.go
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2019-05-08 16:45:12 -0700
committerJhon Honce <jhonce@redhat.com>2019-05-14 12:19:28 -0700
commitbd3154fcf6a48b37cfde5d9b1226900cd863c0d9 (patch)
treea898754ae35bdb97d52c359131ef5fff63d4b18b /pkg/varlinkapi/util.go
parenta261b60cc8851c04efd191be6f6e2e4598439822 (diff)
downloadpodman-bd3154fcf6a48b37cfde5d9b1226900cd863c0d9.tar.gz
podman-bd3154fcf6a48b37cfde5d9b1226900cd863c0d9.tar.bz2
podman-bd3154fcf6a48b37cfde5d9b1226900cd863c0d9.zip
Add VarlinkCall.RequiresUpgrade() type and method
Type varlinkapi.VarlinkCall currently only used as receiver for RequiresUpgrade() future helpers could be added to this type. RequiresUpgrade() verifies caller has given correct options to the call for the given operation. Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'pkg/varlinkapi/util.go')
-rw-r--r--pkg/varlinkapi/util.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/pkg/varlinkapi/util.go b/pkg/varlinkapi/util.go
index 8716c963a..a9f1e20a1 100644
--- a/pkg/varlinkapi/util.go
+++ b/pkg/varlinkapi/util.go
@@ -13,6 +13,11 @@ import (
"github.com/containers/libpod/cmd/podman/varlink"
"github.com/containers/libpod/libpod"
"github.com/containers/storage/pkg/archive"
+ "github.com/pkg/errors"
+)
+
+var (
+ ErrUpgradedConnectionRequired = errors.New("peer must use upgraded connection for operation")
)
// getContext returns a non-nil, empty context
@@ -195,3 +200,13 @@ func makePsOpts(inOpts iopodman.PsOpts) shared.PsOptions {
Sync: derefBool(inOpts.Sync),
}
}
+
+// RequiresUpgrade tests if varlink connection has been marked for upgrade.
+func (v *VarlinkCall) RequiresUpgrade() error {
+ if v.WantsUpgrade() {
+ // A nil is sent to the peer as required by the varlink protocol.
+ return v.Reply(nil)
+ } else {
+ return ErrUpgradedConnectionRequired
+ }
+}