types: make Result an interface and move existing Result to separate package
This commit is contained in:
@ -31,14 +31,15 @@ import (
|
||||
|
||||
"github.com/containernetworking/cni/pkg/skel"
|
||||
"github.com/containernetworking/cni/pkg/types"
|
||||
"github.com/containernetworking/cni/pkg/types/current"
|
||||
"github.com/containernetworking/cni/pkg/version"
|
||||
noop_debug "github.com/containernetworking/cni/plugins/test/noop/debug"
|
||||
)
|
||||
|
||||
type NetConf struct {
|
||||
types.NetConf
|
||||
DebugFile string `json:"debugFile"`
|
||||
PrevResult *types.Result `json:"prevResult,omitempty"`
|
||||
DebugFile string `json:"debugFile"`
|
||||
PrevResult *current.Result `json:"prevResult,omitempty"`
|
||||
}
|
||||
|
||||
func loadConf(bytes []byte) (*NetConf, error) {
|
||||
@ -121,7 +122,12 @@ func debugBehavior(args *skel.CmdArgs, command string) error {
|
||||
return errors.New(debug.ReportError)
|
||||
} else if debug.ReportResult == "PASSTHROUGH" || debug.ReportResult == "INJECT-DNS" {
|
||||
if debug.ReportResult == "INJECT-DNS" {
|
||||
netConf.PrevResult.DNS.Nameservers = []string{"1.2.3.4"}
|
||||
newResult, err := current.NewResultFromResult(netConf.PrevResult)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
newResult.DNS.Nameservers = []string{"1.2.3.4"}
|
||||
netConf.PrevResult = newResult
|
||||
}
|
||||
newResult, err := json.Marshal(netConf.PrevResult)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user