func RunIPAMPlugin(netconf, command, args, cniVersion string) (*current.Result, types.Error, int) {
	conf := types.NetConf{}
	if err := json.Unmarshal([]byte(netconf), &conf); err != nil {
		panic(fmt.Errorf("failed to load netconf: %v", err))
	}

	// Run the CNI plugin passing in the supplied netconf
	cmd := &exec.Cmd{
		Env:  []string{"CNI_COMMAND=" + command, "CNI_CONTAINERID=a", "CNI_NETNS=b", "CNI_IFNAME=c", "CNI_PATH=d", "CNI_ARGS=" + args},
		Path: "dist/" + conf.IPAM.Type,
	}
	stdin, err := cmd.StdinPipe()
	if err != nil {
		panic("some error found")
	}

	io.WriteString(stdin, netconf)
	io.WriteString(stdin, "\n")
	stdin.Close()

	session, err := gexec.Start(cmd, ginkgo.GinkgoWriter, ginkgo.GinkgoWriter)
	if err != nil {
		panic("some error found")
	}
	session.Wait(5)
	exitCode := session.ExitCode()

	result := &current.Result{}
	error := types.Error{}
	stdout := session.Out.Contents()
	if exitCode == 0 {
		if command == "ADD" {
			result, err = GetResultForCurrent(session, cniVersion)
			if err != nil {
				log.Fatalf("Error getting result from the session: %v \n %v\n", session, err)
			}
		}
	} else {
		if err := json.Unmarshal(stdout, &error); err != nil {
			panic(fmt.Errorf("failed to load error: %s %v", stdout, err))
		}
	}

	return result, error, exitCode
}
// RunIPAMPlugin sets ENV vars required then calls the IPAM plugin
// specified in the config and returns the result and exitCode.
RunIPAMPlugin sets ENV vars required then calls the IPAM plugin
specified in the config and returns the result and exitCode.
// RunIPAMPlugin sets ENV vars required then calls the IPAM plugin // specified in the config and returns the result and exitCode .
func RunIPAMPlugin(netconf, command, args, cniVersion string) (*current.Result, types.Error, int) {
	conf := types.NetConf{}
	if err := json.Unmarshal([]byte(netconf), &conf); err != nil {
		panic(fmt.Errorf("failed to load netconf: %v", err))
	}
	cmd := &exec.Cmd{
		Env:  []string{"CNI_COMMAND=" + command, "CNI_CONTAINERID=a", "CNI_NETNS=b", "CNI_IFNAME=c", "CNI_PATH=d", "CNI_ARGS=" + args},
		Path: "dist/" + conf.IPAM.Type,
	}
	stdin, err := cmd.StdinPipe()
	if err != nil {
		panic("some error found")
	}
	io.WriteString(stdin, netconf)
	io.WriteString(stdin, "\n")
	stdin.Close()
	session, err := gexec.Start(cmd, ginkgo.GinkgoWriter, ginkgo.GinkgoWriter)
	if err != nil {
		panic("some error found")
	}
	session.Wait(5)
	exitCode := session.ExitCode()
	result := &current.Result{}
	error := types.Error{}
	stdout := session.Out.Contents()
	if exitCode == 0 {
		if command == "ADD" {
			result, err = GetResultForCurrent(session, cniVersion)
			if err != nil {
				log.Fatalf("Error getting result from the session: %v \n %v\n", session, err)
			}
		}
	} else {
		if err := json.Unmarshal(stdout, &error); err != nil {
			panic(fmt.Errorf("failed to load error: %s %v", stdout, err))
		}
	}
	return result, error, exitCode
}
func RunIPAMPlugin ( netconf , command , args , cniVersion string ) ( * current . Result , types . Error , int ) { conf := types . NetConf { } if err := json . Unmarshal ( [ ] byte ( netconf ) , & conf ) ; err != nil { panic ( fmt . Errorf ( " " , err ) ) } cmd := & exec . Cmd { Env : [ ] string { " " + command , " " , " " , " " , " " , " " + args } , Path : " " + conf . IPAM . Type , } stdin , err := cmd . StdinPipe ( ) if err != nil { panic ( " " ) } io . WriteString ( stdin , netconf ) io . WriteString ( stdin , " \n " ) stdin . Close ( ) session , err := gexec . Start ( cmd , ginkgo . GinkgoWriter , ginkgo . GinkgoWriter ) if err != nil { panic ( " " ) } session . Wait ( 5 ) exitCode := session . ExitCode ( ) result := & current . Result { } error := types . Error { } stdout := session . Out . Contents ( ) if exitCode == 0 { if command == " " { result , err = GetResultForCurrent ( session , cniVersion ) if err != nil { log . Fatalf ( " \n \n " , session , err ) } } } else { if err := json . Unmarshal ( stdout , & error ) ; err != nil { panic ( fmt . Errorf ( " " , stdout , err ) ) } } return result , error , exitCode }
RunIPAMPlugin sets ENV vars required then calls the IPAM plugin
specified in the config and returns the result and exitCode.
RunIPAMPlugin sets ENV vars required then calls the IPAM plugin specified in the config and returns the result and exitCode .
// Run the CNI plugin passing in the supplied netconf