func CreateOrUpdate(ctx context.Context, client client.Interface, wep *api.WorkloadEndpoint) (*api.WorkloadEndpoint, error) {
	if wep.ResourceVersion != "" {
		return client.WorkloadEndpoints().Update(ctx, wep, options.SetOptions{})
	}
	return client.WorkloadEndpoints().Create(ctx, wep, options.SetOptions{})
}
CreateOrUpdate creates the WorkloadEndpoint if ResourceVersion is not specified,
or Update if it's specified.
package utils
import (
	"bytes"
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"io/ioutil"
	"net"
	"os"
	"path/filepath"
	"regexp"
	"strconv"
	"strings"
	"github.com/containernetworking/cni/pkg/skel"
	cnitypes "github.com/containernetworking/cni/pkg/types"
	"github.com/containernetworking/cni/pkg/types/current"
	"github.com/containernetworking/plugins/pkg/ipam"
	"github.com/sirupsen/logrus"
	lumberjack "gopkg.in/natefinch/lumberjack.v2"
	"github.com/projectcalico/cni-plugin/internal/pkg/azure"
	"github.com/projectcalico/cni-plugin/pkg/types"
	"github.com/projectcalico/libcalico-go/lib/apiconfig"
	api "github.com/projectcalico/libcalico-go/lib/apis/v3"
	client "github.com/projectcalico/libcalico-go/lib/clientv3"
	"github.com/projectcalico/libcalico-go/lib/names"
	cnet "github.com/projectcalico/libcalico-go/lib/net"
	"github.com/projectcalico/libcalico-go/lib/options"
)
func Min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func DetermineNodename(conf types.NetConf) (nodename string) {
	if conf.Nodename != "" {
		logrus.Debugf("Read node name from CNI conf: %s", conf.Nodename)
		nodename = conf.Nodename
	} else if nff := nodenameFromFile(conf.NodenameFile); nff != "" {
		logrus.Debugf("Read node name from file: %s", nff)
		nodename = nff
	} else if conf.Hostname != "" {
		nodename = conf.Hostname
		logrus.Warn("Configuration option 'hostname' is deprecated, use 'nodename' instead")
	} else {
		nodename, _ = names.Hostname()
		logrus.Debugf("Read node name from OS Hostname")
	}
	logrus.Debugf("Using node name %s", nodename)
	return
}
func nodenameFromFile(filename string) string {
	if filename == "" {
		filename = "/var/lib/calico/nodename"
	}
	data, err := ioutil.ReadFile(filename)
	if err != nil {
		if os.IsNotExist(err) {
			logrus.Infof("File %s does not exist", filename)
			return ""
		}
		logrus.WithError(err).Errorf("Failed to read %s", filename)
		return ""
	}
	return string(data)
}
func MTUFromFile(filename string) (int, error) {
	if filename == "" {
		filename = "/var/lib/calico/mtu"
	}
	data, err := ioutil.ReadFile(filename)
	if err != nil {
		if os.IsNotExist(err) {
			logrus.Infof("File %s does not exist", filename)
			return 0, nil
		}
		logrus.WithError(err).Errorf("Failed to read %s", filename)
		return 0, err
	}
	return strconv.Atoi(strings.TrimSpace(string(data)))
}