Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
85b2f904
Commit
85b2f904
authored
Jul 12, 2016
by
Minhan Xia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update godep to pull from containernetworking/cni
parent
2b18f372
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
219 additions
and
52 deletions
+219
-52
Godeps.json
Godeps/Godeps.json
+15
-15
LICENSES
Godeps/LICENSES
+0
-0
cni.go
pkg/kubelet/network/cni/cni.go
+2
-2
cni_test.go
pkg/kubelet/network/cni/cni_test.go
+1
-1
mock_cni.go
pkg/kubelet/network/cni/testing/mock_cni.go
+2
-2
kubenet_linux.go
pkg/kubelet/network/kubenet/kubenet_linux.go
+2
-2
LICENSE
vendor/github.com/containernetworking/cni/LICENSE
+0
-0
api.go
vendor/github.com/containernetworking/cni/libcni/api.go
+13
-5
conf.go
vendor/github.com/containernetworking/cni/libcni/conf.go
+26
-1
args.go
vendor/github.com/containernetworking/cni/pkg/invoke/args.go
+1
-1
delegate.go
...github.com/containernetworking/cni/pkg/invoke/delegate.go
+28
-12
exec.go
vendor/github.com/containernetworking/cni/pkg/invoke/exec.go
+2
-7
find.go
vendor/github.com/containernetworking/cni/pkg/invoke/find.go
+47
-0
args.go
vendor/github.com/containernetworking/cni/pkg/types/args.go
+54
-3
types.go
vendor/github.com/containernetworking/cni/pkg/types/types.go
+26
-1
No files found.
Godeps/Godeps.json
View file @
85b2f904
...
...
@@ -83,21 +83,6 @@
"Rev"
:
"c0ef4539dfab4d21c8ef20ba2924f9fc6f186d35"
},
{
"ImportPath"
:
"github.com/appc/cni/libcni"
,
"Comment"
:
"v0.1.0-27-g2a58bd9"
,
"Rev"
:
"2a58bd9379ca33579f0cf631945b717aa4fa373d"
},
{
"ImportPath"
:
"github.com/appc/cni/pkg/invoke"
,
"Comment"
:
"v0.1.0-27-g2a58bd9"
,
"Rev"
:
"2a58bd9379ca33579f0cf631945b717aa4fa373d"
},
{
"ImportPath"
:
"github.com/appc/cni/pkg/types"
,
"Comment"
:
"v0.1.0-27-g2a58bd9"
,
"Rev"
:
"2a58bd9379ca33579f0cf631945b717aa4fa373d"
},
{
"ImportPath"
:
"github.com/appc/spec/schema"
,
"Comment"
:
"v0.8.1-6-gab50d12"
,
"Rev"
:
"ab50d12e88f57788bf84b83fef2be236eb1fcc0b"
...
...
@@ -346,6 +331,21 @@
"Rev"
:
"8d75e11374a1928608c906fe745b538483e7aeb2"
},
{
"ImportPath"
:
"github.com/containernetworking/cni/libcni"
,
"Comment"
:
"v0.3.0-61-g9d5e6e6"
,
"Rev"
:
"9d5e6e60e79491207834ae8439e80c943db65a69"
},
{
"ImportPath"
:
"github.com/containernetworking/cni/pkg/invoke"
,
"Comment"
:
"v0.3.0-61-g9d5e6e6"
,
"Rev"
:
"9d5e6e60e79491207834ae8439e80c943db65a69"
},
{
"ImportPath"
:
"github.com/containernetworking/cni/pkg/types"
,
"Comment"
:
"v0.3.0-61-g9d5e6e6"
,
"Rev"
:
"9d5e6e60e79491207834ae8439e80c943db65a69"
},
{
"ImportPath"
:
"github.com/coreos/etcd/alarm"
,
"Comment"
:
"v3.0.4"
,
"Rev"
:
"d53923c636e0e4ab7f00cb75681b97a8f11f5a9d"
...
...
Godeps/LICENSES
View file @
85b2f904
This source diff could not be displayed because it is too large. You can
view the blob
instead.
pkg/kubelet/network/cni/cni.go
View file @
85b2f904
...
...
@@ -23,8 +23,8 @@ import (
"sync"
"time"
"github.com/
appc
/cni/libcni"
cnitypes
"github.com/
appc
/cni/pkg/types"
"github.com/
containernetworking
/cni/libcni"
cnitypes
"github.com/
containernetworking
/cni/pkg/types"
"github.com/golang/glog"
"k8s.io/kubernetes/pkg/apis/componentconfig"
kubecontainer
"k8s.io/kubernetes/pkg/kubelet/container"
...
...
pkg/kubelet/network/cni/cni_test.go
View file @
85b2f904
...
...
@@ -31,7 +31,7 @@ import (
clientset
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
cnitypes
"github.com/
appc
/cni/pkg/types"
cnitypes
"github.com/
containernetworking
/cni/pkg/types"
"github.com/stretchr/testify/mock"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/componentconfig"
...
...
pkg/kubelet/network/cni/testing/mock_cni.go
View file @
85b2f904
...
...
@@ -19,8 +19,8 @@ limitations under the License.
package
mock_cni
import
(
"github.com/
appc
/cni/libcni"
"github.com/
appc
/cni/pkg/types"
"github.com/
containernetworking
/cni/libcni"
"github.com/
containernetworking
/cni/pkg/types"
"github.com/stretchr/testify/mock"
)
...
...
pkg/kubelet/network/kubenet/kubenet_linux.go
View file @
85b2f904
...
...
@@ -26,8 +26,8 @@ import (
"syscall"
"time"
"github.com/
appc
/cni/libcni"
cnitypes
"github.com/
appc
/cni/pkg/types"
"github.com/
containernetworking
/cni/libcni"
cnitypes
"github.com/
containernetworking
/cni/pkg/types"
"github.com/golang/glog"
"github.com/vishvananda/netlink"
"github.com/vishvananda/netlink/nl"
...
...
vendor/github.com/
appc
/cni/LICENSE
→
vendor/github.com/
containernetworking
/cni/LICENSE
View file @
85b2f904
File moved
vendor/github.com/
appc
/cni/libcni/api.go
→
vendor/github.com/
containernetworking
/cni/libcni/api.go
View file @
85b2f904
// Copyright 2015 C
oreOS, Inc.
// Copyright 2015 C
NI authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
...
...
@@ -17,8 +17,8 @@ package libcni
import
(
"strings"
"github.com/
appc
/cni/pkg/invoke"
"github.com/
appc
/cni/pkg/types"
"github.com/
containernetworking
/cni/pkg/invoke"
"github.com/
containernetworking
/cni/pkg/types"
)
type
RuntimeConf
struct
{
...
...
@@ -43,12 +43,20 @@ type CNIConfig struct {
}
func
(
c
*
CNIConfig
)
AddNetwork
(
net
*
NetworkConfig
,
rt
*
RuntimeConf
)
(
*
types
.
Result
,
error
)
{
pluginPath
:=
invoke
.
FindInPath
(
net
.
Network
.
Type
,
c
.
Path
)
pluginPath
,
err
:=
invoke
.
FindInPath
(
net
.
Network
.
Type
,
c
.
Path
)
if
err
!=
nil
{
return
nil
,
err
}
return
invoke
.
ExecPluginWithResult
(
pluginPath
,
net
.
Bytes
,
c
.
args
(
"ADD"
,
rt
))
}
func
(
c
*
CNIConfig
)
DelNetwork
(
net
*
NetworkConfig
,
rt
*
RuntimeConf
)
error
{
pluginPath
:=
invoke
.
FindInPath
(
net
.
Network
.
Type
,
c
.
Path
)
pluginPath
,
err
:=
invoke
.
FindInPath
(
net
.
Network
.
Type
,
c
.
Path
)
if
err
!=
nil
{
return
err
}
return
invoke
.
ExecPluginWithoutResult
(
pluginPath
,
net
.
Bytes
,
c
.
args
(
"DEL"
,
rt
))
}
...
...
vendor/github.com/
appc
/cni/libcni/conf.go
→
vendor/github.com/
containernetworking
/cni/libcni/conf.go
View file @
85b2f904
// Copyright 2015 C
oreOS, Inc.
// Copyright 2015 C
NI authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
...
...
@@ -83,3 +83,28 @@ func LoadConf(dir, name string) (*NetworkConfig, error) {
}
return
nil
,
fmt
.
Errorf
(
`no net configuration with name "%s" in %s`
,
name
,
dir
)
}
func
InjectConf
(
original
*
NetworkConfig
,
key
string
,
newValue
interface
{})
(
*
NetworkConfig
,
error
)
{
config
:=
make
(
map
[
string
]
interface
{})
err
:=
json
.
Unmarshal
(
original
.
Bytes
,
&
config
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"unmarshal existing network bytes: %s"
,
err
)
}
if
key
==
""
{
return
nil
,
fmt
.
Errorf
(
"key value can not be empty"
)
}
if
newValue
==
nil
{
return
nil
,
fmt
.
Errorf
(
"newValue must be specified"
)
}
config
[
key
]
=
newValue
newBytes
,
err
:=
json
.
Marshal
(
config
)
if
err
!=
nil
{
return
nil
,
err
}
return
ConfFromBytes
(
newBytes
)
}
vendor/github.com/
appc
/cni/pkg/invoke/args.go
→
vendor/github.com/
containernetworking
/cni/pkg/invoke/args.go
View file @
85b2f904
// Copyright 2015 C
oreOS, Inc.
// Copyright 2015 C
NI authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
...
...
vendor/github.com/
appc/cni/pkg/invoke/find
.go
→
vendor/github.com/
containernetworking/cni/pkg/invoke/delegate
.go
View file @
85b2f904
// Copyright 201
5 CoreOS, Inc.
// Copyright 201
6 CNI authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
...
...
@@ -15,23 +15,39 @@
package
invoke
import
(
"fmt"
"os"
"path/filepath"
"strings"
"github.com/containernetworking/cni/pkg/types"
)
func
FindInPath
(
plugin
string
,
path
[]
string
)
string
{
for
_
,
p
:=
range
path
{
fullname
:=
filepath
.
Join
(
p
,
plugin
)
if
fi
,
err
:=
os
.
Stat
(
fullname
);
err
==
nil
&&
fi
.
Mode
()
.
IsRegular
()
{
return
fullname
}
func
DelegateAdd
(
delegatePlugin
string
,
netconf
[]
byte
)
(
*
types
.
Result
,
error
)
{
if
os
.
Getenv
(
"CNI_COMMAND"
)
!=
"ADD"
{
return
nil
,
fmt
.
Errorf
(
"CNI_COMMAND is not ADD"
)
}
paths
:=
strings
.
Split
(
os
.
Getenv
(
"CNI_PATH"
),
":"
)
pluginPath
,
err
:=
FindInPath
(
delegatePlugin
,
paths
)
if
err
!=
nil
{
return
nil
,
err
}
return
""
return
ExecPluginWithResult
(
pluginPath
,
netconf
,
ArgsFromEnv
())
}
// Find returns the full path of the plugin by searching in CNI_PATH
func
Find
(
plugin
string
)
string
{
func
DelegateDel
(
delegatePlugin
string
,
netconf
[]
byte
)
error
{
if
os
.
Getenv
(
"CNI_COMMAND"
)
!=
"DEL"
{
return
fmt
.
Errorf
(
"CNI_COMMAND is not DEL"
)
}
paths
:=
strings
.
Split
(
os
.
Getenv
(
"CNI_PATH"
),
":"
)
return
FindInPath
(
plugin
,
paths
)
pluginPath
,
err
:=
FindInPath
(
delegatePlugin
,
paths
)
if
err
!=
nil
{
return
err
}
return
ExecPluginWithoutResult
(
pluginPath
,
netconf
,
ArgsFromEnv
())
}
vendor/github.com/
appc
/cni/pkg/invoke/exec.go
→
vendor/github.com/
containernetworking
/cni/pkg/invoke/exec.go
View file @
85b2f904
// Copyright 2015 C
oreOS, Inc.
// Copyright 2015 C
NI authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
...
...
@@ -20,9 +20,8 @@ import (
"fmt"
"os"
"os/exec"
"path/filepath"
"github.com/
appc
/cni/pkg/types"
"github.com/
containernetworking
/cni/pkg/types"
)
func
pluginErr
(
err
error
,
output
[]
byte
)
error
{
...
...
@@ -58,10 +57,6 @@ func ExecPluginWithoutResult(pluginPath string, netconf []byte, args CNIArgs) er
}
func
execPlugin
(
pluginPath
string
,
netconf
[]
byte
,
args
CNIArgs
)
([]
byte
,
error
)
{
if
pluginPath
==
""
{
return
nil
,
fmt
.
Errorf
(
"could not find %q plugin"
,
filepath
.
Base
(
pluginPath
))
}
stdout
:=
&
bytes
.
Buffer
{}
c
:=
exec
.
Cmd
{
...
...
vendor/github.com/containernetworking/cni/pkg/invoke/find.go
0 → 100644
View file @
85b2f904
// Copyright 2015 CNI authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package
invoke
import
(
"fmt"
"os"
"path/filepath"
)
// FindInPath returns the full path of the plugin by searching in the provided path
func
FindInPath
(
plugin
string
,
paths
[]
string
)
(
string
,
error
)
{
if
plugin
==
""
{
return
""
,
fmt
.
Errorf
(
"no plugin name provided"
)
}
if
len
(
paths
)
==
0
{
return
""
,
fmt
.
Errorf
(
"no paths provided"
)
}
var
fullpath
string
for
_
,
path
:=
range
paths
{
full
:=
filepath
.
Join
(
path
,
plugin
)
if
fi
,
err
:=
os
.
Stat
(
full
);
err
==
nil
&&
fi
.
Mode
()
.
IsRegular
()
{
fullpath
=
full
break
}
}
if
fullpath
==
""
{
return
""
,
fmt
.
Errorf
(
"failed to find plugin %q in path %s"
,
plugin
,
paths
)
}
return
fullpath
,
nil
}
vendor/github.com/
appc
/cni/pkg/types/args.go
→
vendor/github.com/
containernetworking
/cni/pkg/types/args.go
View file @
85b2f904
// Copyright 2015 C
oreOS, Inc.
// Copyright 2015 C
NI authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
...
...
@@ -21,6 +21,49 @@ import (
"strings"
)
// UnmarshallableBool typedef for builtin bool
// because builtin type's methods can't be declared
type
UnmarshallableBool
bool
// UnmarshalText implements the encoding.TextUnmarshaler interface.
// Returns boolean true if the string is "1" or "[Tt]rue"
// Returns boolean false if the string is "0" or "[Ff]alse"
func
(
b
*
UnmarshallableBool
)
UnmarshalText
(
data
[]
byte
)
error
{
s
:=
strings
.
ToLower
(
string
(
data
))
switch
s
{
case
"1"
,
"true"
:
*
b
=
true
case
"0"
,
"false"
:
*
b
=
false
default
:
return
fmt
.
Errorf
(
"Boolean unmarshal error: invalid input %s"
,
s
)
}
return
nil
}
// UnmarshallableString typedef for builtin string
type
UnmarshallableString
string
// UnmarshalText implements the encoding.TextUnmarshaler interface.
// Returns the string
func
(
s
*
UnmarshallableString
)
UnmarshalText
(
data
[]
byte
)
error
{
*
s
=
UnmarshallableString
(
data
)
return
nil
}
// CommonArgs contains the IgnoreUnknown argument
// and must be embedded by all Arg structs
type
CommonArgs
struct
{
IgnoreUnknown
UnmarshallableBool
`json:"ignoreunknown,omitempty"`
}
// GetKeyField is a helper function to receive Values
// Values that represent a pointer to a struct
func
GetKeyField
(
keyString
string
,
v
reflect
.
Value
)
reflect
.
Value
{
return
v
.
Elem
()
.
FieldByName
(
keyString
)
}
// LoadArgs parses args from a string in the form "K=V;K2=V2;..."
func
LoadArgs
(
args
string
,
container
interface
{})
error
{
if
args
==
""
{
return
nil
...
...
@@ -29,6 +72,7 @@ func LoadArgs(args string, container interface{}) error {
containerValue
:=
reflect
.
ValueOf
(
container
)
pairs
:=
strings
.
Split
(
args
,
";"
)
unknownArgs
:=
[]
string
{}
for
_
,
pair
:=
range
pairs
{
kv
:=
strings
.
Split
(
pair
,
"="
)
if
len
(
kv
)
!=
2
{
...
...
@@ -36,15 +80,22 @@ func LoadArgs(args string, container interface{}) error {
}
keyString
:=
kv
[
0
]
valueString
:=
kv
[
1
]
keyField
:=
containerValue
.
Elem
()
.
FieldByName
(
keyString
)
keyField
:=
GetKeyField
(
keyString
,
containerValue
)
if
!
keyField
.
IsValid
()
{
return
fmt
.
Errorf
(
"ARGS: invalid key %q"
,
keyString
)
unknownArgs
=
append
(
unknownArgs
,
pair
)
continue
}
u
:=
keyField
.
Addr
()
.
Interface
()
.
(
encoding
.
TextUnmarshaler
)
err
:=
u
.
UnmarshalText
([]
byte
(
valueString
))
if
err
!=
nil
{
return
fmt
.
Errorf
(
"ARGS: error parsing value of pair %q: %v)"
,
pair
,
err
)
}
}
isIgnoreUnknown
:=
GetKeyField
(
"IgnoreUnknown"
,
containerValue
)
.
Bool
()
if
len
(
unknownArgs
)
>
0
&&
!
isIgnoreUnknown
{
return
fmt
.
Errorf
(
"ARGS: unknown args %q"
,
unknownArgs
)
}
return
nil
}
vendor/github.com/
appc
/cni/pkg/types/types.go
→
vendor/github.com/
containernetworking
/cni/pkg/types/types.go
View file @
85b2f904
// Copyright 2015 C
oreOS, Inc.
// Copyright 2015 C
NI authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
...
...
@@ -16,6 +16,7 @@ package types
import
(
"encoding/json"
"fmt"
"net"
"os"
)
...
...
@@ -61,18 +62,34 @@ type NetConf struct {
IPAM
struct
{
Type
string
`json:"type,omitempty"`
}
`json:"ipam,omitempty"`
DNS
DNS
`json:"dns"`
}
// Result is what gets returned from the plugin (via stdout) to the caller
type
Result
struct
{
IP4
*
IPConfig
`json:"ip4,omitempty"`
IP6
*
IPConfig
`json:"ip6,omitempty"`
DNS
DNS
`json:"dns,omitempty"`
}
func
(
r
*
Result
)
Print
()
error
{
return
prettyPrint
(
r
)
}
// String returns a formatted string in the form of "[IP4: $1,][ IP6: $2,] DNS: $3" where
// $1 represents the receiver's IPv4, $2 represents the receiver's IPv6 and $3 the
// receiver's DNS. If $1 or $2 are nil, they won't be present in the returned string.
func
(
r
*
Result
)
String
()
string
{
var
str
string
if
r
.
IP4
!=
nil
{
str
=
fmt
.
Sprintf
(
"IP4:%+v, "
,
*
r
.
IP4
)
}
if
r
.
IP6
!=
nil
{
str
+=
fmt
.
Sprintf
(
"IP6:%+v, "
,
*
r
.
IP6
)
}
return
fmt
.
Sprintf
(
"%sDNS:%+v"
,
str
,
r
.
DNS
)
}
// IPConfig contains values necessary to configure an interface
type
IPConfig
struct
{
IP
net
.
IPNet
...
...
@@ -80,6 +97,14 @@ type IPConfig struct {
Routes
[]
Route
}
// DNS contains values interesting for DNS resolvers
type
DNS
struct
{
Nameservers
[]
string
`json:"nameservers,omitempty"`
Domain
string
`json:"domain,omitempty"`
Search
[]
string
`json:"search,omitempty"`
Options
[]
string
`json:"options,omitempty"`
}
type
Route
struct
{
Dst
net
.
IPNet
GW
net
.
IP
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment