Merge pull request #344 from dcbw/interface-checks
all: assert internal objects implement interfaces
This commit is contained in:
commit
47f6604b5a
@ -43,6 +43,9 @@ type CNIConfig struct {
|
|||||||
Path []string
|
Path []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CNIConfig implements the CNI interface
|
||||||
|
var _ CNI = &CNIConfig{}
|
||||||
|
|
||||||
// AddNetwork executes the plugin with the ADD command
|
// AddNetwork executes the plugin with the ADD command
|
||||||
func (c *CNIConfig) AddNetwork(net *NetworkConfig, rt *RuntimeConf) (*types.Result, error) {
|
func (c *CNIConfig) AddNetwork(net *NetworkConfig, rt *RuntimeConf) (*types.Result, error) {
|
||||||
pluginPath, err := invoke.FindInPath(net.Network.Type, c.Path)
|
pluginPath, err := invoke.FindInPath(net.Network.Type, c.Path)
|
||||||
|
@ -47,6 +47,9 @@ type Args struct {
|
|||||||
Path string
|
Path string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Args implements the CNIArgs interface
|
||||||
|
var _ CNIArgs = &Args{}
|
||||||
|
|
||||||
func (args *Args) AsEnv() []string {
|
func (args *Args) AsEnv() []string {
|
||||||
env := os.Environ()
|
env := os.Environ()
|
||||||
pluginArgsStr := args.PluginArgsStr
|
pluginArgsStr := args.PluginArgsStr
|
||||||
|
@ -62,6 +62,9 @@ type netNS struct {
|
|||||||
closed bool
|
closed bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// netNS implements the NetNS interface
|
||||||
|
var _ NetNS = &netNS{}
|
||||||
|
|
||||||
func getCurrentThreadNetNSPath() string {
|
func getCurrentThreadNetNSPath() string {
|
||||||
// /proc/self/ns/net returns the namespace of the main thread, not
|
// /proc/self/ns/net returns the namespace of the main thread, not
|
||||||
// of whatever thread this goroutine is running on. Make sure we
|
// of whatever thread this goroutine is running on. Make sure we
|
||||||
|
@ -36,6 +36,9 @@ type pluginInfo struct {
|
|||||||
SupportedVersions_ []string `json:"supportedVersions,omitempty"`
|
SupportedVersions_ []string `json:"supportedVersions,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pluginInfo implements the PluginInfo interface
|
||||||
|
var _ PluginInfo = &pluginInfo{}
|
||||||
|
|
||||||
func (p *pluginInfo) Encode(w io.Writer) error {
|
func (p *pluginInfo) Encode(w io.Writer) error {
|
||||||
return json.NewEncoder(w).Encode(p)
|
return json.NewEncoder(w).Encode(p)
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/containernetworking/cni/plugins/ipam/host-local/backend"
|
||||||
)
|
)
|
||||||
|
|
||||||
const lastIPFile = "last_reserved_ip"
|
const lastIPFile = "last_reserved_ip"
|
||||||
@ -32,6 +34,9 @@ type Store struct {
|
|||||||
dataDir string
|
dataDir string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store implements the Store interface
|
||||||
|
var _ backend.Store = &Store{}
|
||||||
|
|
||||||
func New(network, dataDir string) (*Store, error) {
|
func New(network, dataDir string) (*Store, error) {
|
||||||
if dataDir == "" {
|
if dataDir == "" {
|
||||||
dataDir = defaultDataDir
|
dataDir = defaultDataDir
|
||||||
|
@ -16,6 +16,8 @@ package testing
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
|
"github.com/containernetworking/cni/plugins/ipam/host-local/backend"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FakeStore struct {
|
type FakeStore struct {
|
||||||
@ -23,6 +25,9 @@ type FakeStore struct {
|
|||||||
lastReservedIP net.IP
|
lastReservedIP net.IP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FakeStore implements the Store interface
|
||||||
|
var _ backend.Store = &FakeStore{}
|
||||||
|
|
||||||
func NewFakeStore(ipmap map[string]string, lastIP net.IP) *FakeStore {
|
func NewFakeStore(ipmap map[string]string, lastIP net.IP) *FakeStore {
|
||||||
return &FakeStore{ipmap, lastIP}
|
return &FakeStore{ipmap, lastIP}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user