pkg/ipam : use delegateArgs instead of env set/unset in ipam.ExecDel
Signed-off-by: Bruce Ma <brucema19901024@gmail.com>
This commit is contained in:
@ -16,10 +16,8 @@ package ipam
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/containernetworking/cni/pkg/invoke"
|
||||
"github.com/containernetworking/cni/pkg/types"
|
||||
"os"
|
||||
)
|
||||
|
||||
func ExecAdd(plugin string, netconf []byte) (types.Result, error) {
|
||||
@ -31,13 +29,5 @@ func ExecCheck(plugin string, netconf []byte) error {
|
||||
}
|
||||
|
||||
func ExecDel(plugin string, netconf []byte) error {
|
||||
cmd := os.Getenv("CNI_COMMAND")
|
||||
if cmd == "" {
|
||||
return fmt.Errorf("environment variable CNI_COMMAND must be specified.")
|
||||
}
|
||||
// Set CNI_COMMAND to DEL explicity. We might be deleting due to an ADD gone wrong.
|
||||
// restore CNI_COMMAND to original value upon return.
|
||||
os.Setenv("CNI_COMMAND", "DEL")
|
||||
defer os.Setenv("CNI_COMMAND", cmd)
|
||||
return invoke.DelegateDel(context.TODO(), plugin, netconf, nil)
|
||||
}
|
||||
|
Reference in New Issue
Block a user