mirror of
https://github.com/k8snetworkplumbingwg/multus-cni.git
synced 2025-08-18 08:11:47 +00:00
Removes the it `fails to execute confListDel given no 'plugins' key"` test. This test no longer fails after libcni version 1.2.3. It probably shouldn't failduring a DEL action as it is, we want the least error prone path. The GC test now uses both cni.dev attachment formats. Uses both attachment formats as per https://github.com/containernetworking/cni/issues/1101 for GC's cni.dev/valid-attachments & cni.dev/attachments
59 lines
1.3 KiB
Go
59 lines
1.3 KiB
Go
// Package: passthru-cni
|
|
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
|
|
"github.com/containernetworking/cni/pkg/skel"
|
|
cniTypes "github.com/containernetworking/cni/pkg/types"
|
|
current "github.com/containernetworking/cni/pkg/types/100"
|
|
cniVersion "github.com/containernetworking/cni/pkg/version"
|
|
)
|
|
|
|
// NetConf is a CNI configuration structure
|
|
type NetConf struct {
|
|
cniTypes.NetConf
|
|
}
|
|
|
|
func main() {
|
|
skel.PluginMain(
|
|
cmdAdd,
|
|
nil,
|
|
cmdDel,
|
|
cniVersion.PluginSupports("0.3.0", "0.3.1", "0.4.0", "1.0.0", "1.1.0"),
|
|
"Passthrough CNI Plugin v1.0",
|
|
)
|
|
}
|
|
|
|
func cmdAdd(args *skel.CmdArgs) error {
|
|
n, err := loadNetConf(args.StdinData)
|
|
if err != nil {
|
|
return fmt.Errorf("passthru cni: error parsing CNI configuration: %s", err)
|
|
}
|
|
|
|
// Create an empty but valid CNI result
|
|
result := ¤t.Result{
|
|
CNIVersion: n.CNIVersion,
|
|
Interfaces: []*current.Interface{},
|
|
IPs: []*current.IPConfig{},
|
|
Routes: []*cniTypes.Route{},
|
|
DNS: cniTypes.DNS{},
|
|
}
|
|
|
|
return cniTypes.PrintResult(result, n.CNIVersion)
|
|
}
|
|
|
|
func cmdDel(_ *skel.CmdArgs) error {
|
|
// Nothing to do for DEL command, just return nil
|
|
return nil
|
|
}
|
|
|
|
func loadNetConf(bytes []byte) (*NetConf, error) {
|
|
n := &NetConf{}
|
|
if err := json.Unmarshal(bytes, n); err != nil {
|
|
return nil, fmt.Errorf("passthru cni: failed to load netconf: %s", err)
|
|
}
|
|
return n, nil
|
|
}
|