diff options
author | Valentin Rothberg <rothberg@redhat.com> | 2019-06-24 21:29:31 +0200 |
---|---|---|
committer | Valentin Rothberg <rothberg@redhat.com> | 2019-06-24 21:29:31 +0200 |
commit | 2388222e98462fdbbe44f3e091b2b79d80956a9a (patch) | |
tree | 17078d861c20a3e48b19c750c6864c5f59248386 /vendor/github.com/containernetworking/cni/pkg/invoke/delegate.go | |
parent | a1a4a75abee2c381483a218e1660621ee416ef7c (diff) | |
download | podman-2388222e98462fdbbe44f3e091b2b79d80956a9a.tar.gz podman-2388222e98462fdbbe44f3e091b2b79d80956a9a.tar.bz2 podman-2388222e98462fdbbe44f3e091b2b79d80956a9a.zip |
update dependencies
Ran a `go get -u` and bumped K8s deps to 1.15.0.
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'vendor/github.com/containernetworking/cni/pkg/invoke/delegate.go')
-rw-r--r-- | vendor/github.com/containernetworking/cni/pkg/invoke/delegate.go | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/vendor/github.com/containernetworking/cni/pkg/invoke/delegate.go b/vendor/github.com/containernetworking/cni/pkg/invoke/delegate.go index 30b4672f1..8defe4dd3 100644 --- a/vendor/github.com/containernetworking/cni/pkg/invoke/delegate.go +++ b/vendor/github.com/containernetworking/cni/pkg/invoke/delegate.go @@ -16,22 +16,17 @@ package invoke import ( "context" - "fmt" "os" "path/filepath" "github.com/containernetworking/cni/pkg/types" ) -func delegateCommon(expectedCommand, delegatePlugin string, exec Exec) (string, Exec, error) { +func delegateCommon(delegatePlugin string, exec Exec) (string, Exec, error) { if exec == nil { exec = defaultExec } - if os.Getenv("CNI_COMMAND") != expectedCommand { - return "", nil, fmt.Errorf("CNI_COMMAND is not " + expectedCommand) - } - paths := filepath.SplitList(os.Getenv("CNI_PATH")) pluginPath, err := exec.FindInPath(delegatePlugin, paths) if err != nil { @@ -44,32 +39,42 @@ func delegateCommon(expectedCommand, delegatePlugin string, exec Exec) (string, // DelegateAdd calls the given delegate plugin with the CNI ADD action and // JSON configuration func DelegateAdd(ctx context.Context, delegatePlugin string, netconf []byte, exec Exec) (types.Result, error) { - pluginPath, realExec, err := delegateCommon("ADD", delegatePlugin, exec) + pluginPath, realExec, err := delegateCommon(delegatePlugin, exec) if err != nil { return nil, err } - return ExecPluginWithResult(ctx, pluginPath, netconf, ArgsFromEnv(), realExec) + // DelegateAdd will override the original "CNI_COMMAND" env from process with ADD + return ExecPluginWithResult(ctx, pluginPath, netconf, delegateArgs("ADD"), realExec) } // DelegateCheck calls the given delegate plugin with the CNI CHECK action and // JSON configuration func DelegateCheck(ctx context.Context, delegatePlugin string, netconf []byte, exec Exec) error { - pluginPath, realExec, err := delegateCommon("CHECK", delegatePlugin, exec) + pluginPath, realExec, err := delegateCommon(delegatePlugin, exec) if err != nil { return err } - return ExecPluginWithoutResult(ctx, pluginPath, netconf, ArgsFromEnv(), realExec) + // DelegateCheck will override the original CNI_COMMAND env from process with CHECK + return ExecPluginWithoutResult(ctx, pluginPath, netconf, delegateArgs("CHECK"), realExec) } // DelegateDel calls the given delegate plugin with the CNI DEL action and // JSON configuration func DelegateDel(ctx context.Context, delegatePlugin string, netconf []byte, exec Exec) error { - pluginPath, realExec, err := delegateCommon("DEL", delegatePlugin, exec) + pluginPath, realExec, err := delegateCommon(delegatePlugin, exec) if err != nil { return err } - return ExecPluginWithoutResult(ctx, pluginPath, netconf, ArgsFromEnv(), realExec) + // DelegateDel will override the original CNI_COMMAND env from process with DEL + return ExecPluginWithoutResult(ctx, pluginPath, netconf, delegateArgs("DEL"), realExec) +} + +// return CNIArgs used by delegation +func delegateArgs(action string) *DelegateArgs { + return &DelegateArgs{ + Command: action, + } } |