mirror of https://github.com/k3s-io/k3s
Merge pull request #51250 from dixudx/bump_cni_v0.6.0
Automatic merge from submit-queue (batch tested with PRs 53106, 52193, 51250, 52449, 53861). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. bump CNI to v0.6.0 **What this PR does / why we need it**: **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #49480 **Special notes for your reviewer**: /assign @luxas @bboreham @feiskyer **Release note**: ```release-note bump CNI to v0.6.0 ```pull/6/head
commit
855551dc80
|
@ -439,33 +439,33 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "github.com/containernetworking/cni/libcni",
|
||||
"Comment": "v0.5.2",
|
||||
"Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e"
|
||||
"Comment": "v0.6.0",
|
||||
"Rev": "a7885cb6f8ab03fba07852ded351e4f5e7a112bf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/containernetworking/cni/pkg/invoke",
|
||||
"Comment": "v0.5.2",
|
||||
"Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e"
|
||||
"Comment": "v0.6.0",
|
||||
"Rev": "a7885cb6f8ab03fba07852ded351e4f5e7a112bf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/containernetworking/cni/pkg/types",
|
||||
"Comment": "v0.5.2",
|
||||
"Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e"
|
||||
"Comment": "v0.6.0",
|
||||
"Rev": "a7885cb6f8ab03fba07852ded351e4f5e7a112bf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/containernetworking/cni/pkg/types/020",
|
||||
"Comment": "v0.5.2",
|
||||
"Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e"
|
||||
"Comment": "v0.6.0",
|
||||
"Rev": "a7885cb6f8ab03fba07852ded351e4f5e7a112bf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/containernetworking/cni/pkg/types/current",
|
||||
"Comment": "v0.5.2",
|
||||
"Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e"
|
||||
"Comment": "v0.6.0",
|
||||
"Rev": "a7885cb6f8ab03fba07852ded351e4f5e7a112bf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/containernetworking/cni/pkg/version",
|
||||
"Comment": "v0.5.2",
|
||||
"Rev": "137b4975ecab6e1f0c24c1e3c228a50a3cfba75e"
|
||||
"Comment": "v0.6.0",
|
||||
"Rev": "a7885cb6f8ab03fba07852ded351e4f5e7a112bf"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/coreos/etcd/alarm",
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
# Copyright 2016 The Kubernetes 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.
|
||||
|
||||
# Build the CNI binaries.
|
||||
#
|
||||
# Usage:
|
||||
# [ARCH=amd64] [CNI_RELEASE=v0.3.0] make (build|push)
|
||||
|
||||
ARCH?=amd64
|
||||
CNI_RELEASE?=0799f5732f2a11b329d9e3d51b9c8f2e3759f2ff
|
||||
CNI_TARBALL=cni-$(ARCH)-$(CNI_RELEASE).tar.gz
|
||||
CUR_DIR=$(shell pwd)
|
||||
OUTPUT_DIR=$(CUR_DIR)/output
|
||||
GOLANG_VERSION=1.7.6
|
||||
|
||||
all: build
|
||||
|
||||
build:
|
||||
mkdir -p $(OUTPUT_DIR)
|
||||
|
||||
docker run -it -v $(OUTPUT_DIR):/output:Z golang:$(GOLANG_VERSION) /bin/bash -c "\
|
||||
git clone https://github.com/containernetworking/cni\
|
||||
&& cd cni \
|
||||
&& git checkout $(CNI_RELEASE) \
|
||||
&& CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) ./build \
|
||||
&& tar -zcvf $(CNI_TARBALL) bin/ \
|
||||
&& mv $(CNI_TARBALL) /output/"
|
||||
|
||||
# Backward Compatibility
|
||||
ifeq ($(ARCH),amd64)
|
||||
cp $(OUTPUT_DIR)/$(CNI_TARBALL) $(OUTPUT_DIR)/cni-$(CNI_RELEASE).tar.gz
|
||||
endif
|
||||
|
||||
push: build
|
||||
gsutil cp $(OUTPUT_DIR)/$(CNI_TARBALL) gs://kubernetes-release/network-plugins
|
||||
|
||||
ifeq ($(ARCH),amd64)
|
||||
gsutil cp $(OUTPUT_DIR)/cni-$(CNI_RELEASE).tar.gz gs://kubernetes-release/network-plugins
|
||||
endif
|
||||
|
||||
clean:
|
||||
rm -rf output/
|
||||
|
||||
.PHONY: all
|
|
@ -24,10 +24,10 @@ ARCH?=amd64
|
|||
CACHEBUST?=1
|
||||
|
||||
BASEIMAGE=gcr.io/google-containers/debian-base-$(ARCH):0.2
|
||||
CNI_RELEASE=0799f5732f2a11b329d9e3d51b9c8f2e3759f2ff
|
||||
CNI_VERSION=v0.6.0
|
||||
|
||||
TEMP_DIR:=$(shell mktemp -d)
|
||||
CNI_TARBALL=cni-$(ARCH)-$(CNI_RELEASE).tar.gz
|
||||
CNI_TARBALL=cni-plugins-$(ARCH)-$(CNI_VERSION).tgz
|
||||
|
||||
.PHONY: all build push clean
|
||||
|
||||
|
@ -48,8 +48,8 @@ ifeq ($(CACHEBUST),1)
|
|||
cd ${TEMP_DIR} && sed -i.back "s|CACHEBUST|$(shell uuidgen)|g" Dockerfile
|
||||
endif
|
||||
|
||||
mkdir -p ${TEMP_DIR}/cni-bin
|
||||
tar -xz -C ${TEMP_DIR}/cni-bin -f "cni-tars/${CNI_TARBALL}"
|
||||
mkdir -p ${TEMP_DIR}/cni-bin/bin
|
||||
tar -xz -C ${TEMP_DIR}/cni-bin/bin -f "cni-tars/${CNI_TARBALL}"
|
||||
|
||||
# Register /usr/bin/qemu-ARCH-static as the handler for non-x86 binaries in the kernel
|
||||
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
||||
|
|
|
@ -56,8 +56,8 @@ docker_repositories()
|
|||
|
||||
http_file(
|
||||
name = "kubernetes_cni",
|
||||
sha256 = "05ab3937bc68562e989dc143362ec4d4275262ba9f359338aed720fc914457a5",
|
||||
url = "https://storage.googleapis.com/kubernetes-release/network-plugins/cni-amd64-0799f5732f2a11b329d9e3d51b9c8f2e3759f2ff.tar.gz",
|
||||
sha256 = "f04339a21b8edf76d415e7f17b620e63b8f37a76b2f706671587ab6464411f2d",
|
||||
url = "https://storage.googleapis.com/kubernetes-release/network-plugins/cni-plugins-amd64-v0.6.0.tgz",
|
||||
)
|
||||
|
||||
docker_pull(
|
||||
|
|
|
@ -10,7 +10,8 @@ URL: https://kubernetes.io
|
|||
Binaries required to provision container networking.
|
||||
|
||||
%prep
|
||||
tar xzfv cni-*.tar.gz
|
||||
mkdir -p ./bin
|
||||
tar -C ./bin -xz -f cni-plugins-amd64-v0.6.0.tgz
|
||||
|
||||
%install
|
||||
|
||||
|
|
|
@ -110,13 +110,13 @@ function install-kube-binary-config {
|
|||
|
||||
if [[ "${NETWORK_PROVIDER:-}" == "kubenet" ]] || \
|
||||
[[ "${NETWORK_PROVIDER:-}" == "cni" ]]; then
|
||||
#TODO(andyzheng0831): We should make the cni version number as a k8s env variable.
|
||||
local -r cni_tar="cni-0799f5732f2a11b329d9e3d51b9c8f2e3759f2ff.tar.gz"
|
||||
local -r cni_sha1="1d9788b0f5420e1a219aad2cb8681823fc515e7c"
|
||||
local -r cni_version="v0.6.0"
|
||||
local -r cni_tar="cni-plugins-amd64-${cni_version}.tgz"
|
||||
local -r cni_sha1="d595d3ded6499a64e8dac02466e2f5f2ce257c9f"
|
||||
download-or-bust "${cni_sha1}" "https://storage.googleapis.com/kubernetes-release/network-plugins/${cni_tar}"
|
||||
local -r cni_dir="${KUBE_HOME}/cni"
|
||||
mkdir -p "${cni_dir}"
|
||||
tar xzf "${KUBE_HOME}/${cni_tar}" -C "${cni_dir}" --overwrite
|
||||
mkdir -p "${cni_dir}/bin"
|
||||
tar xzf "${KUBE_HOME}/${cni_tar}" -C "${cni_dir}/bin" --overwrite
|
||||
mv "${cni_dir}/bin"/* "${kube_bin}"
|
||||
rmdir "${cni_dir}/bin"
|
||||
rm -f "${KUBE_HOME}/${cni_tar}"
|
||||
|
|
|
@ -170,9 +170,9 @@ function install-node-problem-detector {
|
|||
}
|
||||
|
||||
function install-cni-binaries {
|
||||
#TODO(andyzheng0831): We should make the cni version number as a k8s env variable.
|
||||
local -r cni_tar="cni-0799f5732f2a11b329d9e3d51b9c8f2e3759f2ff.tar.gz"
|
||||
local -r cni_sha1="1d9788b0f5420e1a219aad2cb8681823fc515e7c"
|
||||
local -r cni_version="v0.6.0"
|
||||
local -r cni_tar="cni-plugins-amd64-${cni_version}.tgz"
|
||||
local -r cni_sha1="d595d3ded6499a64e8dac02466e2f5f2ce257c9f"
|
||||
if is-preloaded "${cni_tar}" "${cni_sha1}"; then
|
||||
echo "${cni_tar} is preloaded."
|
||||
return
|
||||
|
@ -181,8 +181,8 @@ function install-cni-binaries {
|
|||
echo "Downloading cni binaries"
|
||||
download-or-bust "${cni_sha1}" "https://storage.googleapis.com/kubernetes-release/network-plugins/${cni_tar}"
|
||||
local -r cni_dir="${KUBE_HOME}/cni"
|
||||
mkdir -p "${cni_dir}"
|
||||
tar xzf "${KUBE_HOME}/${cni_tar}" -C "${cni_dir}" --overwrite
|
||||
mkdir -p "${cni_dir}/bin"
|
||||
tar xzf "${KUBE_HOME}/${cni_tar}" -C "${cni_dir}/bin" --overwrite
|
||||
mv "${cni_dir}/bin"/* "${KUBE_BIN}"
|
||||
rmdir "${cni_dir}/bin"
|
||||
rm -f "${KUBE_HOME}/${cni_tar}"
|
||||
|
|
|
@ -17,11 +17,11 @@ cni-tar:
|
|||
archive:
|
||||
- extracted
|
||||
- user: root
|
||||
- name: /home/kubernetes
|
||||
- name: /home/kubernetes/bin
|
||||
- makedirs: True
|
||||
- source: https://storage.googleapis.com/kubernetes-release/network-plugins/cni-0799f5732f2a11b329d9e3d51b9c8f2e3759f2ff.tar.gz
|
||||
- source: https://storage.googleapis.com/kubernetes-release/network-plugins/cni-plugins-amd64-v0.6.0.tgz
|
||||
- tar_options: v
|
||||
- source_hash: md5=afbb526e7d976f98353ac96f73043031
|
||||
- source_hash: md5=9534876FAE7DBE813CDAB404DC1F9219
|
||||
- archive_format: tar
|
||||
- if_missing: /home/kubernetes/bin
|
||||
|
||||
|
|
|
@ -27,10 +27,11 @@ import (
|
|||
// utils.go contains functions used across test suites.
|
||||
|
||||
const (
|
||||
cniRelease = "0799f5732f2a11b329d9e3d51b9c8f2e3759f2ff"
|
||||
cniDirectory = "cni" // The CNI tarball creates the "bin" directory under "cni".
|
||||
cniVersion = "v0.6.0"
|
||||
cniArch = "amd64"
|
||||
cniDirectory = "cni/bin" // The CNI tarball places binaries under directory under "cni/bin".
|
||||
cniConfDirectory = "cni/net.d"
|
||||
cniURL = "https://storage.googleapis.com/kubernetes-release/network-plugins/cni-" + cniRelease + ".tar.gz"
|
||||
cniURL = "https://storage.googleapis.com/kubernetes-release/network-plugins/cni-plugins-" + cniArch + "-" + cniVersion + ".tgz"
|
||||
)
|
||||
|
||||
const cniConfig = `{
|
||||
|
|
|
@ -57,13 +57,16 @@ func (args *Args) AsEnv() []string {
|
|||
pluginArgsStr = stringify(args.PluginArgs)
|
||||
}
|
||||
|
||||
env = append(env,
|
||||
"CNI_COMMAND="+args.Command,
|
||||
"CNI_CONTAINERID="+args.ContainerID,
|
||||
"CNI_NETNS="+args.NetNS,
|
||||
"CNI_ARGS="+pluginArgsStr,
|
||||
"CNI_IFNAME="+args.IfName,
|
||||
"CNI_PATH="+args.Path)
|
||||
// Ensure that the custom values are first, so any value present in
|
||||
// the process environment won't override them.
|
||||
env = append([]string{
|
||||
"CNI_COMMAND=" + args.Command,
|
||||
"CNI_CONTAINERID=" + args.ContainerID,
|
||||
"CNI_NETNS=" + args.NetNS,
|
||||
"CNI_ARGS=" + pluginArgsStr,
|
||||
"CNI_IFNAME=" + args.IfName,
|
||||
"CNI_PATH=" + args.Path,
|
||||
}, env...)
|
||||
return env
|
||||
}
|
||||
|
||||
|
|
|
@ -50,13 +50,9 @@ func pluginErr(err error, output []byte) error {
|
|||
if _, ok := err.(*exec.ExitError); ok {
|
||||
emsg := types.Error{}
|
||||
if perr := json.Unmarshal(output, &emsg); perr != nil {
|
||||
return fmt.Errorf("netplugin failed but error parsing its diagnostic message %q: %v", string(output), perr)
|
||||
emsg.Msg = fmt.Sprintf("netplugin failed but error parsing its diagnostic message %q: %v", string(output), perr)
|
||||
}
|
||||
details := ""
|
||||
if emsg.Details != "" {
|
||||
details = fmt.Sprintf("; %v", emsg.Details)
|
||||
}
|
||||
return fmt.Errorf("%v%v", emsg.Msg, details)
|
||||
return &emsg
|
||||
}
|
||||
|
||||
return err
|
||||
|
|
|
@ -23,9 +23,9 @@ import (
|
|||
"github.com/containernetworking/cni/pkg/types"
|
||||
)
|
||||
|
||||
const implementedSpecVersion string = "0.2.0"
|
||||
const ImplementedSpecVersion string = "0.2.0"
|
||||
|
||||
var SupportedVersions = []string{"", "0.1.0", implementedSpecVersion}
|
||||
var SupportedVersions = []string{"", "0.1.0", ImplementedSpecVersion}
|
||||
|
||||
// Compatibility types for CNI version 0.1.0 and 0.2.0
|
||||
|
||||
|
@ -39,7 +39,7 @@ func NewResult(data []byte) (types.Result, error) {
|
|||
|
||||
func GetResult(r types.Result) (*Result, error) {
|
||||
// We expect version 0.1.0/0.2.0 results
|
||||
result020, err := r.GetAsVersion(implementedSpecVersion)
|
||||
result020, err := r.GetAsVersion(ImplementedSpecVersion)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -52,18 +52,20 @@ func GetResult(r types.Result) (*Result, error) {
|
|||
|
||||
// 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 types.DNS `json:"dns,omitempty"`
|
||||
CNIVersion string `json:"cniVersion,omitempty"`
|
||||
IP4 *IPConfig `json:"ip4,omitempty"`
|
||||
IP6 *IPConfig `json:"ip6,omitempty"`
|
||||
DNS types.DNS `json:"dns,omitempty"`
|
||||
}
|
||||
|
||||
func (r *Result) Version() string {
|
||||
return implementedSpecVersion
|
||||
return ImplementedSpecVersion
|
||||
}
|
||||
|
||||
func (r *Result) GetAsVersion(version string) (types.Result, error) {
|
||||
for _, supportedVersion := range SupportedVersions {
|
||||
if version == supportedVersion {
|
||||
r.CNIVersion = version
|
||||
return r, nil
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,12 @@ func GetKeyField(keyString string, v reflect.Value) reflect.Value {
|
|||
return v.Elem().FieldByName(keyString)
|
||||
}
|
||||
|
||||
// UnmarshalableArgsError is used to indicate error unmarshalling args
|
||||
// from the args-string in the form "K=V;K2=V2;..."
|
||||
type UnmarshalableArgsError struct {
|
||||
error
|
||||
}
|
||||
|
||||
// LoadArgs parses args from a string in the form "K=V;K2=V2;..."
|
||||
func LoadArgs(args string, container interface{}) error {
|
||||
if args == "" {
|
||||
|
@ -85,8 +91,13 @@ func LoadArgs(args string, container interface{}) error {
|
|||
unknownArgs = append(unknownArgs, pair)
|
||||
continue
|
||||
}
|
||||
|
||||
u := keyField.Addr().Interface().(encoding.TextUnmarshaler)
|
||||
keyFieldIface := keyField.Addr().Interface()
|
||||
u, ok := keyFieldIface.(encoding.TextUnmarshaler)
|
||||
if !ok {
|
||||
return UnmarshalableArgsError{fmt.Errorf(
|
||||
"ARGS: cannot unmarshal into field '%s' - type '%s' does not implement encoding.TextUnmarshaler",
|
||||
keyString, reflect.TypeOf(keyFieldIface))}
|
||||
}
|
||||
err := u.UnmarshalText([]byte(valueString))
|
||||
if err != nil {
|
||||
return fmt.Errorf("ARGS: error parsing value of pair %q: %v)", pair, err)
|
||||
|
|
|
@ -24,9 +24,9 @@ import (
|
|||
"github.com/containernetworking/cni/pkg/types/020"
|
||||
)
|
||||
|
||||
const implementedSpecVersion string = "0.3.1"
|
||||
const ImplementedSpecVersion string = "0.3.1"
|
||||
|
||||
var SupportedVersions = []string{"0.3.0", implementedSpecVersion}
|
||||
var SupportedVersions = []string{"0.3.0", ImplementedSpecVersion}
|
||||
|
||||
func NewResult(data []byte) (types.Result, error) {
|
||||
result := &Result{}
|
||||
|
@ -37,7 +37,7 @@ func NewResult(data []byte) (types.Result, error) {
|
|||
}
|
||||
|
||||
func GetResult(r types.Result) (*Result, error) {
|
||||
resultCurrent, err := r.GetAsVersion(implementedSpecVersion)
|
||||
resultCurrent, err := r.GetAsVersion(ImplementedSpecVersion)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -63,16 +63,16 @@ func convertFrom020(result types.Result) (*Result, error) {
|
|||
}
|
||||
|
||||
newResult := &Result{
|
||||
DNS: oldResult.DNS,
|
||||
Routes: []*types.Route{},
|
||||
CNIVersion: ImplementedSpecVersion,
|
||||
DNS: oldResult.DNS,
|
||||
Routes: []*types.Route{},
|
||||
}
|
||||
|
||||
if oldResult.IP4 != nil {
|
||||
newResult.IPs = append(newResult.IPs, &IPConfig{
|
||||
Version: "4",
|
||||
Interface: -1,
|
||||
Address: oldResult.IP4.IP,
|
||||
Gateway: oldResult.IP4.Gateway,
|
||||
Version: "4",
|
||||
Address: oldResult.IP4.IP,
|
||||
Gateway: oldResult.IP4.Gateway,
|
||||
})
|
||||
for _, route := range oldResult.IP4.Routes {
|
||||
gw := route.GW
|
||||
|
@ -88,10 +88,9 @@ func convertFrom020(result types.Result) (*Result, error) {
|
|||
|
||||
if oldResult.IP6 != nil {
|
||||
newResult.IPs = append(newResult.IPs, &IPConfig{
|
||||
Version: "6",
|
||||
Interface: -1,
|
||||
Address: oldResult.IP6.IP,
|
||||
Gateway: oldResult.IP6.Gateway,
|
||||
Version: "6",
|
||||
Address: oldResult.IP6.IP,
|
||||
Gateway: oldResult.IP6.Gateway,
|
||||
})
|
||||
for _, route := range oldResult.IP6.Routes {
|
||||
gw := route.GW
|
||||
|
@ -117,6 +116,7 @@ func convertFrom030(result types.Result) (*Result, error) {
|
|||
if !ok {
|
||||
return nil, fmt.Errorf("failed to convert result")
|
||||
}
|
||||
newResult.CNIVersion = ImplementedSpecVersion
|
||||
return newResult, nil
|
||||
}
|
||||
|
||||
|
@ -134,6 +134,7 @@ func NewResultFromResult(result types.Result) (*Result, error) {
|
|||
|
||||
// Result is what gets returned from the plugin (via stdout) to the caller
|
||||
type Result struct {
|
||||
CNIVersion string `json:"cniVersion,omitempty"`
|
||||
Interfaces []*Interface `json:"interfaces,omitempty"`
|
||||
IPs []*IPConfig `json:"ips,omitempty"`
|
||||
Routes []*types.Route `json:"routes,omitempty"`
|
||||
|
@ -143,7 +144,8 @@ type Result struct {
|
|||
// Convert to the older 0.2.0 CNI spec Result type
|
||||
func (r *Result) convertTo020() (*types020.Result, error) {
|
||||
oldResult := &types020.Result{
|
||||
DNS: r.DNS,
|
||||
CNIVersion: types020.ImplementedSpecVersion,
|
||||
DNS: r.DNS,
|
||||
}
|
||||
|
||||
for _, ip := range r.IPs {
|
||||
|
@ -189,12 +191,13 @@ func (r *Result) convertTo020() (*types020.Result, error) {
|
|||
}
|
||||
|
||||
func (r *Result) Version() string {
|
||||
return implementedSpecVersion
|
||||
return ImplementedSpecVersion
|
||||
}
|
||||
|
||||
func (r *Result) GetAsVersion(version string) (types.Result, error) {
|
||||
switch version {
|
||||
case "0.3.0", implementedSpecVersion:
|
||||
case "0.3.0", ImplementedSpecVersion:
|
||||
r.CNIVersion = version
|
||||
return r, nil
|
||||
case types020.SupportedVersions[0], types020.SupportedVersions[1], types020.SupportedVersions[2]:
|
||||
return r.convertTo020()
|
||||
|
@ -244,12 +247,18 @@ func (i *Interface) String() string {
|
|||
return fmt.Sprintf("%+v", *i)
|
||||
}
|
||||
|
||||
// Int returns a pointer to the int value passed in. Used to
|
||||
// set the IPConfig.Interface field.
|
||||
func Int(v int) *int {
|
||||
return &v
|
||||
}
|
||||
|
||||
// IPConfig contains values necessary to configure an IP address on an interface
|
||||
type IPConfig struct {
|
||||
// IP version, either "4" or "6"
|
||||
Version string
|
||||
// Index into Result structs Interfaces list
|
||||
Interface int
|
||||
Interface *int
|
||||
Address net.IPNet
|
||||
Gateway net.IP
|
||||
}
|
||||
|
@ -261,7 +270,7 @@ func (i *IPConfig) String() string {
|
|||
// JSON (un)marshallable types
|
||||
type ipConfig struct {
|
||||
Version string `json:"version"`
|
||||
Interface int `json:"interface,omitempty"`
|
||||
Interface *int `json:"interface,omitempty"`
|
||||
Address types.IPNet `json:"address"`
|
||||
Gateway net.IP `json:"gateway,omitempty"`
|
||||
}
|
||||
|
|
|
@ -136,7 +136,11 @@ type Error struct {
|
|||
}
|
||||
|
||||
func (e *Error) Error() string {
|
||||
return e.Msg
|
||||
details := ""
|
||||
if e.Details != "" {
|
||||
details = fmt.Sprintf("; %v", e.Details)
|
||||
}
|
||||
return fmt.Sprintf("%v%v", e.Msg, details)
|
||||
}
|
||||
|
||||
func (e *Error) Print() error {
|
||||
|
|
Loading…
Reference in New Issue