forked from github/multus-cni
Add delegate API in multus-daemon (#890)
This changes introduce delegate API function in multus-daemon. This API will be consumed from other programs for hot-plug interface into running pod. This change also cleanups server code to split into client code and server code to easy to import from other golang code.
This commit is contained in:
@@ -4,8 +4,6 @@ import (
|
||||
"net/http"
|
||||
|
||||
"github.com/containernetworking/cni/pkg/invoke"
|
||||
"github.com/containernetworking/cni/pkg/skel"
|
||||
cni100 "github.com/containernetworking/cni/pkg/types/100"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
|
||||
@@ -13,16 +11,6 @@ import (
|
||||
"gopkg.in/k8snetworkplumbingwg/multus-cni.v3/pkg/types"
|
||||
)
|
||||
|
||||
type cniRequestFunc func(cmd string, k8sArgs *types.K8sArgs, cniCmdArgs *skel.CmdArgs, exec invoke.Exec, kubeClient *k8sclient.ClientInfo) ([]byte, error)
|
||||
|
||||
// Request sent to the Server by the multus-shim
|
||||
type Request struct {
|
||||
// CNI environment variables, like CNI_COMMAND and CNI_NETNS
|
||||
Env map[string]string `json:"env,omitempty"`
|
||||
// CNI configuration passed via stdin to the CNI plugin
|
||||
Config []byte `json:"config,omitempty"`
|
||||
}
|
||||
|
||||
// Metrics represents server's metrics.
|
||||
type Metrics struct {
|
||||
requestCounter *prometheus.CounterVec
|
||||
@@ -32,7 +20,6 @@ type Metrics struct {
|
||||
// the CNI shim requests issued when a pod is added / removed.
|
||||
type Server struct {
|
||||
http.Server
|
||||
requestFunc cniRequestFunc
|
||||
rundir string
|
||||
kubeclient *k8sclient.ClientInfo
|
||||
exec invoke.Exec
|
||||
@@ -40,12 +27,6 @@ type Server struct {
|
||||
metrics *Metrics
|
||||
}
|
||||
|
||||
// Response represents the response (computed in the CNI server) for
|
||||
// ADD / DEL / CHECK for a Pod.
|
||||
type Response struct {
|
||||
Result *cni100.Result
|
||||
}
|
||||
|
||||
// ShimNetConf for the shim cni config file written in json
|
||||
type ShimNetConf struct {
|
||||
types.NetConf
|
||||
|
Reference in New Issue
Block a user