mirror of
https://github.com/k8snetworkplumbingwg/multus-cni.git
synced 2025-06-20 21:03:35 +00:00
Make binary file and directory name consistent
This change make binary file and directory name consistent. In addition, change the package name cni to server because cni is a bit umbiguous for cni plugin's repository.
This commit is contained in:
parent
d4a3ea4fd0
commit
d4a30c383d
@ -25,9 +25,9 @@ import (
|
|||||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||||
utilwait "k8s.io/apimachinery/pkg/util/wait"
|
utilwait "k8s.io/apimachinery/pkg/util/wait"
|
||||||
|
|
||||||
"gopkg.in/k8snetworkplumbingwg/multus-cni.v3/pkg/cni"
|
|
||||||
"gopkg.in/k8snetworkplumbingwg/multus-cni.v3/pkg/config"
|
"gopkg.in/k8snetworkplumbingwg/multus-cni.v3/pkg/config"
|
||||||
"gopkg.in/k8snetworkplumbingwg/multus-cni.v3/pkg/logging"
|
"gopkg.in/k8snetworkplumbingwg/multus-cni.v3/pkg/logging"
|
||||||
|
srv "gopkg.in/k8snetworkplumbingwg/multus-cni.v3/pkg/server"
|
||||||
"gopkg.in/k8snetworkplumbingwg/multus-cni.v3/pkg/types"
|
"gopkg.in/k8snetworkplumbingwg/multus-cni.v3/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -201,18 +201,18 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func startMultusDaemon(daemonConfig *types.ControllerNetConf) error {
|
func startMultusDaemon(daemonConfig *types.ControllerNetConf) error {
|
||||||
if err := cni.FilesystemPreRequirements(daemonConfig.MultusSocketDir); err != nil {
|
if err := srv.FilesystemPreRequirements(daemonConfig.MultusSocketDir); err != nil {
|
||||||
return fmt.Errorf("failed to prepare the cni-socket for communicating with the shim: %w", err)
|
return fmt.Errorf("failed to prepare the cni-socket for communicating with the shim: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
server, err := cni.NewCNIServer(daemonConfig.MultusSocketDir)
|
server, err := srv.NewCNIServer(daemonConfig.MultusSocketDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create the server: %v", err)
|
return fmt.Errorf("failed to create the server: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
l, err := cni.ServerListener(cni.SocketPath(daemonConfig.MultusSocketDir))
|
l, err := srv.GetListener(srv.SocketPath(daemonConfig.MultusSocketDir))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to start the CNI server using socket %s. Reason: %+v", cni.SocketPath(daemonConfig.MultusSocketDir), err)
|
return fmt.Errorf("failed to start the CNI server using socket %s. Reason: %+v", srv.SocketPath(daemonConfig.MultusSocketDir), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
server.SetKeepAlivesEnabled(false)
|
server.SetKeepAlivesEnabled(false)
|
@ -26,8 +26,8 @@ import (
|
|||||||
"github.com/containernetworking/cni/pkg/skel"
|
"github.com/containernetworking/cni/pkg/skel"
|
||||||
cniversion "github.com/containernetworking/cni/pkg/version"
|
cniversion "github.com/containernetworking/cni/pkg/version"
|
||||||
|
|
||||||
"gopkg.in/k8snetworkplumbingwg/multus-cni.v3/pkg/cni"
|
|
||||||
"gopkg.in/k8snetworkplumbingwg/multus-cni.v3/pkg/multus"
|
"gopkg.in/k8snetworkplumbingwg/multus-cni.v3/pkg/multus"
|
||||||
|
"gopkg.in/k8snetworkplumbingwg/multus-cni.v3/pkg/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -47,13 +47,13 @@ func main() {
|
|||||||
|
|
||||||
skel.PluginMain(
|
skel.PluginMain(
|
||||||
func(args *skel.CmdArgs) error {
|
func(args *skel.CmdArgs) error {
|
||||||
return cni.CmdAdd(args)
|
return server.CmdAdd(args)
|
||||||
},
|
},
|
||||||
func(args *skel.CmdArgs) error {
|
func(args *skel.CmdArgs) error {
|
||||||
return cni.CmdCheck(args)
|
return server.CmdCheck(args)
|
||||||
},
|
},
|
||||||
func(args *skel.CmdArgs) error {
|
func(args *skel.CmdArgs) error {
|
||||||
return cni.CmdDel(args)
|
return server.CmdDel(args)
|
||||||
},
|
},
|
||||||
cniversion.All, "meta-plugin that delegates to other CNI plugins")
|
cniversion.All, "meta-plugin that delegates to other CNI plugins")
|
||||||
}
|
}
|
@ -40,10 +40,10 @@ if [ "$GO111MODULE" == "off" ]; then
|
|||||||
export GO15VENDOREXPERIMENT=1
|
export GO15VENDOREXPERIMENT=1
|
||||||
export GOBIN=${PWD}/bin
|
export GOBIN=${PWD}/bin
|
||||||
export GOPATH=${PWD}/gopath
|
export GOPATH=${PWD}/gopath
|
||||||
go build -o ${PWD}/bin/multus -tags no_openssl -ldflags "${LDFLAGS}" "$@" ${REPO_PATH}/cmd
|
go build -o ${PWD}/bin/multus -tags no_openssl -ldflags "${LDFLAGS}" "$@" ${REPO_PATH}/cmd/multus
|
||||||
go build -o ${PWD}/bin/generate-kubeconfig -tags no_openssl -ldflags "${LDFLAGS}" ${REPO_PATH}/cmd/config-generation
|
go build -o ${PWD}/bin/generate-kubeconfig -tags no_openssl -ldflags "${LDFLAGS}" ${REPO_PATH}/cmd/generate-kubeconfig
|
||||||
go build -o ${PWD}/bin/multus-daemon -tags no_openssl -ldflags "${LDFLAGS}" "$@" ${REPO_PATH}/cmd/controller/
|
go build -o ${PWD}/bin/multus-daemon -tags no_openssl -ldflags "${LDFLAGS}" "$@" ${REPO_PATH}/cmd/multus-daemon
|
||||||
go build -o ${PWD}/bin/multus-shim -tags no_openssl -ldflags "${LDFLAGS}" "$@" ${REPO_PATH}/cmd/shim/
|
go build -o ${PWD}/bin/multus-shim -tags no_openssl -ldflags "${LDFLAGS}" "$@" ${REPO_PATH}/cmd/multus-shim
|
||||||
else
|
else
|
||||||
# build with go modules
|
# build with go modules
|
||||||
export GO111MODULE=on
|
export GO111MODULE=on
|
||||||
@ -53,11 +53,11 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Building plugins"
|
echo "Building plugins"
|
||||||
go build ${BUILD_ARGS[*]} -ldflags "${LDFLAGS}" "$@" ./cmd
|
go build ${BUILD_ARGS[*]} -ldflags "${LDFLAGS}" "$@" ./cmd/multus
|
||||||
echo "Building spec generators"
|
echo "Building spec generators"
|
||||||
go build -o "${DEST_DIR}"/generate-kubeconfig -ldflags "${LDFLAGS}" ./cmd/config-generation
|
go build -o "${DEST_DIR}"/generate-kubeconfig -ldflags "${LDFLAGS}" ./cmd/generate-kubeconfig
|
||||||
echo "Building multus controller"
|
echo "Building multus controller"
|
||||||
go build -o "${DEST_DIR}"/multus-daemon -ldflags "${LDFLAGS}" ./cmd/controller/
|
go build -o "${DEST_DIR}"/multus-daemon -ldflags "${LDFLAGS}" ./cmd/multus-daemon
|
||||||
echo "Building multus shim"
|
echo "Building multus shim"
|
||||||
go build -o "${DEST_DIR}"/multus-shim -ldflags "${LDFLAGS}" ./cmd/shim/
|
go build -o "${DEST_DIR}"/multus-shim -ldflags "${LDFLAGS}" ./cmd/multus-shim
|
||||||
fi
|
fi
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
package cni
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
@ -62,8 +62,8 @@ func HandleCNIRequest(cmd string, k8sArgs *types.K8sArgs, cniCmdArgs *skel.CmdAr
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ServerListener creates a listener to a unix socket located in `socketPath`
|
// GetListener creates a listener to a unix socket located in `socketPath`
|
||||||
func ServerListener(socketPath string) (net.Listener, error) {
|
func GetListener(socketPath string) (net.Listener, error) {
|
||||||
l, err := net.Listen("unix", socketPath)
|
l, err := net.Listen("unix", socketPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, logging.Errorf("failed to listen on pod info socket: %v", err)
|
return nil, logging.Errorf("failed to listen on pod info socket: %v", err)
|
@ -1,4 +1,4 @@
|
|||||||
package cni
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
package cni
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
@ -13,7 +13,7 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
package cni
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -212,7 +212,7 @@ func startCNIServer(runDir string, k8sClient *k8s.ClientInfo) (*Server, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
l, err := ServerListener(SocketPath(runDir))
|
l, err := GetListener(SocketPath(runDir))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to start the CNI server using socket %s. Reason: %+v", SocketPath(runDir), err)
|
return nil, fmt.Errorf("failed to start the CNI server using socket %s. Reason: %+v", SocketPath(runDir), err)
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package cni
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -36,3 +36,27 @@ type Server struct {
|
|||||||
type Response struct {
|
type Response struct {
|
||||||
Result *current.Result
|
Result *current.Result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ShimNetConf for the shim cni config file written in json
|
||||||
|
type ShimNetConf struct {
|
||||||
|
types.NetConf
|
||||||
|
|
||||||
|
MultusSocketDir string `json:"socketDir"`
|
||||||
|
LogFile string `json:"logFile,omitempty"`
|
||||||
|
LogLevel string `json:"logLevel,omitempty"`
|
||||||
|
LogToStderr bool `json:"logToStderr,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ControllerNetConf for the controller cni configuration
|
||||||
|
type ControllerNetConf struct {
|
||||||
|
ConfDir string `json:"confDir"`
|
||||||
|
CNIDir string `json:"cniDir"`
|
||||||
|
BinDir string `json:"binDir"`
|
||||||
|
LogFile string `json:"logFile"`
|
||||||
|
LogLevel string `json:"logLevel"`
|
||||||
|
LogToStderr bool `json:"logToStderr,omitempty"`
|
||||||
|
|
||||||
|
// Option to point to the path of the unix domain socket through which the
|
||||||
|
// multus client / server communicate.
|
||||||
|
MultusSocketDir string `json:"socketDir"`
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user