Skip to content

Commit d616c0d

Browse files
committed
changes
Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
1 parent 7c1ee02 commit d616c0d

5 files changed

Lines changed: 12 additions & 10 deletions

File tree

provider/cni/server/add_workload.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"github.com/docker/libnetwork/provider/cni/cniapi"
1616
)
1717

18-
func addWorkload(w http.ResponseWriter, r *http.Request, c cni.CNIService, vars map[string]string) (_ interface{}, retErr error) {
18+
func addWorkload(w http.ResponseWriter, r *http.Request, c cni.Service, vars map[string]string) (_ interface{}, retErr error) {
1919
cniInfo := cniapi.CniInfo{}
2020
var result current.Result
2121

provider/cni/server/cni_server.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ func (c *CniService) Init(serverCloseChan chan struct{}) error {
6868
return nil
6969
}
7070

71+
// SetupWorkload sets up the network for the workload
7172
func (c *CniService) SetupWorkload(cniInfo cniapi.CniInfo) (
7273
ep client.EndpointInfo,
7374
retErr error,
@@ -116,6 +117,7 @@ func (c *CniService) SetupWorkload(cniInfo cniapi.CniInfo) (
116117
return ep, nil
117118
}
118119

120+
// TearDownWorkload tears the networking of the workload
119121
func (c *CniService) TearDownWorkload(cniInfo cniapi.CniInfo) error {
120122
cniMetadata, err := c.getMetadataFromStore(cniInfo)
121123
if err != nil {
@@ -154,7 +156,7 @@ func (c *CniService) putMetadataToStore(cniInfo cniapi.CniInfo,
154156
ContainerID: cniInfo.ContainerID,
155157
SandboxID: sbID,
156158
EndpointID: epID,
157-
SandboxMeta: CopySandboxMetadata(sbConfig, cniInfo.NetNS),
159+
SandboxMeta: copySandboxMetadata(sbConfig, cniInfo.NetNS),
158160
}
159161
store := c.getstore()
160162
if store == nil {
@@ -274,7 +276,7 @@ func createNetwork(netConf cniapi.NetworkConf) error {
274276
log.Infof("Creating network %+v \n", netConf)
275277
driverOpts := make(map[string]string)
276278
driverOpts["hostaccess"] = ""
277-
nc := client.NetworkCreate{Name: netConf.Name, ID: netConf.Name, NetworkType: GetNetworkType(netConf.Name),
279+
nc := client.NetworkCreate{Name: netConf.Name, ID: netConf.Name, NetworkType: getNetworkType(netConf.Name),
278280
DriverOpts: driverOpts}
279281
if ipam := netConf.IPAM; ipam != nil {
280282
cfg := client.IPAMConf{}

provider/cni/server/cni_utils.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ import (
1414

1515
type httpAPIFunc func(w http.ResponseWriter,
1616
r *http.Request,
17-
c cni.CNIService,
17+
c cni.Service,
1818
vars map[string]string,
1919
) (interface{}, error)
2020

2121
// MakeHTTPHandler is a simple Wrapper for http handlers
22-
func MakeHTTPHandler(c cni.CNIService, handlerFunc httpAPIFunc) http.HandlerFunc {
22+
func MakeHTTPHandler(c cni.Service, handlerFunc httpAPIFunc) http.HandlerFunc {
2323
// Create a closure and return an anonymous function
2424
return func(w http.ResponseWriter, r *http.Request) {
2525
// Call the handler
@@ -58,7 +58,7 @@ func writeJSON(w http.ResponseWriter, code int, v interface{}) error {
5858
}
5959

6060
// CopySandboxMetadata creates a sandbox metadata
61-
func CopySandboxMetadata(sbConfig client.SandboxCreate, externalKey string) api.SandboxMetadata {
61+
func copySandboxMetadata(sbConfig client.SandboxCreate, externalKey string) api.SandboxMetadata {
6262
var meta api.SandboxMetadata
6363
meta.ContainerID = sbConfig.ContainerID
6464
meta.HostName = sbConfig.HostName
@@ -75,7 +75,7 @@ func CopySandboxMetadata(sbConfig client.SandboxCreate, externalKey string) api.
7575
return meta
7676
}
7777

78-
func GetNetworkType(networkType string) string {
78+
func getNetworkType(networkType string) string {
7979
switch networkType {
8080
case "dnet-overlay-net":
8181
return "overlay"

provider/cni/server/del_workload.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/docker/libnetwork/provider/cni/cniapi"
1313
)
1414

15-
func deleteWorkload(w http.ResponseWriter, r *http.Request, c cni.CNIService, vars map[string]string) (interface{}, error) {
15+
func deleteWorkload(w http.ResponseWriter, r *http.Request, c cni.Service, vars map[string]string) (interface{}, error) {
1616
//TODO: need to explore force cleanup and test for parallel delete workloads
1717
cniInfo := cniapi.CniInfo{}
1818

provider/cni/service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"github.com/docker/libnetwork/provider/cni/cniapi"
66
)
77

8-
// CNIService interface for Cni service implementations
9-
type CNIService interface {
8+
// Service interface for Cni service implementations
9+
type Service interface {
1010
// Init initializes the cni server
1111
Init(serverCloseChan chan struct{}) error
1212
// SetupWorkload setups the CNI workload networking

0 commit comments

Comments
 (0)