func dedupEnv(env []string) []string {
	out := make([]string, 0, len(env))
	envMap := map[string]string{}
	for _, kv := range env {
		eq := strings.Index(kv, "=")
		if eq < 0 {
			out = append(out, kv)
			continue
		}
		envMap[kv[:eq]] = kv[eq+1:]
	}
	for k, v := range envMap {
		out = append(out, fmt.Sprintf("%s=%s", k, v))
	}
	return out
}
dedupEnv returns a copy of env with any duplicates removed, in favor of later values.
Items not of the normal environment "key=value" form are preserved unchanged.
package invoke
import (
	"fmt"
	"os"
	"strings"
)
type CNIArgs interface {
	AsEnv() []string
}
type inherited struct{}
var inheritArgsFromEnv inherited
func (*inherited) AsEnv() []string {
	return nil
}
func ArgsFromEnv() CNIArgs {
	return &inheritArgsFromEnv
}
type Args struct {
	Command       string
	ContainerID   string
	NetNS         string
	PluginArgs    [][2]string
	PluginArgsStr string
	IfName        string
	Path          string
}
var _ CNIArgs = &Args{}
func (args *Args) AsEnv() []string {
	env := os.Environ()
	pluginArgsStr := args.PluginArgsStr
	if pluginArgsStr == "" {
		pluginArgsStr = stringify(args.PluginArgs)
	}
	env = append(env,
		"CNI_COMMAND="+args.Command,
		"CNI_CONTAINERID="+args.ContainerID,
		"CNI_NETNS="+args.NetNS,
		"CNI_ARGS="+pluginArgsStr,
		"CNI_IFNAME="+args.IfName,
		"CNI_PATH="+args.Path,
	)
	return dedupEnv(env)
}
func stringify(pluginArgs [][2]string) string {
	entries := make([]string, len(pluginArgs))
	for i, kv := range pluginArgs {
		entries[i] = strings.Join(kv[:], "=")
	}
	return strings.Join(entries, ";")
}
var _ CNIArgs = &DelegateArgs{}
type DelegateArgs struct {
	Command string
}
func (d *DelegateArgs) AsEnv() []string {
	env := os.Environ()
	env = append(env,
		"CNI_COMMAND="+d.Command,
	)
	return dedupEnv(env)
}