Skip to content

Commit

Permalink
Update net-attach version to v1.7
Browse files Browse the repository at this point in the history
Signed-off-by: Manuel Buil <[email protected]>
  • Loading branch information
manuelbuil committed Apr 15, 2024
1 parent f4d47d3 commit 05315d3
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 205 deletions.
72 changes: 39 additions & 33 deletions cmd/whereabouts.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,46 @@ import (
"github.com/k8snetworkplumbingwg/whereabouts/pkg/version"
)

func main() {
skel.PluginMain(func(args *skel.CmdArgs) error {
ipamConf, confVersion, err := config.LoadIPAMConfig(args.StdinData, args.Args)
if err != nil {
logging.Errorf("IPAM configuration load failed: %s", err)
return err
}
logging.Debugf("ADD - IPAM configuration successfully read: %+v", *ipamConf)
ipam, err := kubernetes.NewKubernetesIPAM(args.ContainerID, *ipamConf)
if err != nil {
func cmdAddFunc(args *skel.CmdArgs) error {
ipamConf, confVersion, err := config.LoadIPAMConfig(args.StdinData, args.Args)
if err != nil {
logging.Errorf("IPAM configuration load failed: %s", err)
return err
}
logging.Debugf("ADD - IPAM configuration successfully read: %+v", *ipamConf)
ipam, err := kubernetes.NewKubernetesIPAM(args.ContainerID, *ipamConf)
if err != nil {
return logging.Errorf("failed to create Kubernetes IPAM manager: %v", err)
}
defer func() { safeCloseKubernetesBackendConnection(ipam) }()
return cmdAdd(args, ipam, confVersion)
},
cmdCheck,
func(args *skel.CmdArgs) error {
ipamConf, _, err := config.LoadIPAMConfig(args.StdinData, args.Args)
if err != nil {
logging.Errorf("IPAM configuration load failed: %s", err)
return err
}
logging.Debugf("DEL - IPAM configuration successfully read: %+v", *ipamConf)

ipam, err := kubernetes.NewKubernetesIPAM(args.ContainerID, *ipamConf)
if err != nil {
return logging.Errorf("IPAM client initialization error: %v", err)
}
defer func() { safeCloseKubernetesBackendConnection(ipam) }()
return cmdDel(args, ipam)
},
cniversion.All,
fmt.Sprintf("whereabouts %s", version.GetFullVersionWithRuntimeInfo()),
)
}
defer func() { safeCloseKubernetesBackendConnection(ipam) }()
return cmdAdd(args, ipam, confVersion)
}

func cmdDelFunc(args *skel.CmdArgs) error {
ipamConf, _, err := config.LoadIPAMConfig(args.StdinData, args.Args)
if err != nil {
logging.Errorf("IPAM configuration load failed: %s", err)
return err
}
logging.Debugf("DEL - IPAM configuration successfully read: %+v", *ipamConf)

ipam, err := kubernetes.NewKubernetesIPAM(args.ContainerID, *ipamConf)
if err != nil {
return logging.Errorf("IPAM client initialization error: %v", err)
}
defer func() { safeCloseKubernetesBackendConnection(ipam) }()
return cmdDel(args, ipam)
}


func main() {
skel.PluginMainFuncs(skel.CNIFuncs{
Add: cmdAddFunc,
Check: cmdCheck,
Del: cmdDelFunc,
},
cniversion.All,
fmt.Sprintf("whereabouts %s", version.GetFullVersionWithRuntimeInfo()))
}

func safeCloseKubernetesBackendConnection(ipam *kubernetes.KubernetesIPAM) {
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ go 1.21

require (
github.com/blang/semver v3.5.1+incompatible
github.com/containernetworking/cni v1.1.2
github.com/containernetworking/cni v1.2.0-rc1
github.com/containernetworking/plugins v1.4.0
github.com/imdario/mergo v0.3.16
github.com/json-iterator/go v1.1.12 // indirect
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.1.1-0.20210510153419-66a699ae3b05
github.com/k8snetworkplumbingwg/network-attachment-definition-client v1.7.0
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.32.0
github.com/pkg/errors v0.9.1
Expand All @@ -27,6 +27,7 @@ require (
github.com/google/gnostic-models v0.6.8 // indirect
github.com/jonboulle/clockwork v0.4.0 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/vishvananda/netns v0.0.4 // indirect
golang.org/x/exp v0.0.0-20231219180239-dc181d75b848 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
)
Expand Down
Loading

0 comments on commit 05315d3

Please sign in to comment.