mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-14 18:53:35 +00:00
vendor files
This commit is contained in:
41
vendor/k8s.io/kubernetes/pkg/util/ipconfig/BUILD
generated
vendored
Normal file
41
vendor/k8s.io/kubernetes/pkg/util/ipconfig/BUILD
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
"go_test",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"doc.go",
|
||||
"ipconfig.go",
|
||||
],
|
||||
importpath = "k8s.io/kubernetes/pkg/util/ipconfig",
|
||||
deps = [
|
||||
"//vendor/github.com/golang/glog:go_default_library",
|
||||
"//vendor/k8s.io/utils/exec:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["ipconfig_test.go"],
|
||||
importpath = "k8s.io/kubernetes/pkg/util/ipconfig",
|
||||
library = ":go_default_library",
|
||||
deps = ["//vendor/k8s.io/utils/exec:go_default_library"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
)
|
18
vendor/k8s.io/kubernetes/pkg/util/ipconfig/doc.go
generated
vendored
Normal file
18
vendor/k8s.io/kubernetes/pkg/util/ipconfig/doc.go
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
// Package ipconfig provides an interface and implementations for running Windows ipconfig commands.
|
||||
package ipconfig // import "k8s.io/kubernetes/pkg/util/ipconfig"
|
99
vendor/k8s.io/kubernetes/pkg/util/ipconfig/ipconfig.go
generated
vendored
Normal file
99
vendor/k8s.io/kubernetes/pkg/util/ipconfig/ipconfig.go
generated
vendored
Normal file
@ -0,0 +1,99 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
package ipconfig
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/golang/glog"
|
||||
|
||||
utilexec "k8s.io/utils/exec"
|
||||
)
|
||||
|
||||
// Interface is an injectable interface for running ipconfig commands. Implementations must be goroutine-safe.
|
||||
type Interface interface {
|
||||
// GetDnsSuffixSearchList returns the list of DNS suffix to search
|
||||
GetDnsSuffixSearchList() ([]string, error)
|
||||
}
|
||||
|
||||
const (
|
||||
cmdIpconfig string = "ipconfig"
|
||||
|
||||
cmdDefaultArgs string = "/all"
|
||||
|
||||
dnsSuffixSearchLisLabel string = "DNS Suffix Search List"
|
||||
)
|
||||
|
||||
// runner implements Interface in terms of exec("ipconfig").
|
||||
type runner struct {
|
||||
mu sync.Mutex
|
||||
exec utilexec.Interface
|
||||
}
|
||||
|
||||
// New returns a new Interface which will exec ipconfig.
|
||||
func New(exec utilexec.Interface) Interface {
|
||||
runner := &runner{
|
||||
exec: exec,
|
||||
}
|
||||
return runner
|
||||
}
|
||||
|
||||
// GetDnsSuffixSearchList returns the list of DNS suffix to search
|
||||
func (runner *runner) GetDnsSuffixSearchList() ([]string, error) {
|
||||
// Parse the DNS suffix search list from ipconfig output
|
||||
// ipconfig /all on Windows displays the entry of DNS suffix search list
|
||||
// An example output contains:
|
||||
//
|
||||
// DNS Suffix Search List. . . . . . : example1.com
|
||||
// example2.com
|
||||
//
|
||||
// TODO: this does not work when the label is localized
|
||||
suffixList := []string{}
|
||||
if runtime.GOOS != "windows" {
|
||||
glog.V(1).Infof("ipconfig not supported on GOOS=%s", runtime.GOOS)
|
||||
return suffixList, nil
|
||||
}
|
||||
|
||||
out, err := runner.exec.Command(cmdIpconfig, cmdDefaultArgs).Output()
|
||||
|
||||
if err == nil {
|
||||
lines := strings.Split(string(out), "\n")
|
||||
for i, line := range lines {
|
||||
if trimmed := strings.TrimSpace(line); strings.HasPrefix(trimmed, dnsSuffixSearchLisLabel) {
|
||||
if parts := strings.Split(trimmed, ":"); len(parts) > 1 {
|
||||
if trimmed := strings.TrimSpace(parts[1]); trimmed != "" {
|
||||
suffixList = append(suffixList, strings.TrimSpace(parts[1]))
|
||||
}
|
||||
for j := i + 1; j < len(lines); j++ {
|
||||
if trimmed := strings.TrimSpace(lines[j]); trimmed != "" && !strings.Contains(trimmed, ":") {
|
||||
suffixList = append(suffixList, trimmed)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
glog.V(1).Infof("Running %s %s failed: %v", cmdIpconfig, cmdDefaultArgs, err)
|
||||
}
|
||||
|
||||
return suffixList, err
|
||||
}
|
33
vendor/k8s.io/kubernetes/pkg/util/ipconfig/ipconfig_test.go
generated
vendored
Normal file
33
vendor/k8s.io/kubernetes/pkg/util/ipconfig/ipconfig_test.go
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
package ipconfig
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/utils/exec"
|
||||
)
|
||||
|
||||
func TestGetDnsSuffixSearchList(t *testing.T) {
|
||||
// Simple test
|
||||
ipconfigInterface := New(exec.New())
|
||||
|
||||
_, err := ipconfigInterface.GetDnsSuffixSearchList()
|
||||
if err != nil {
|
||||
t.Errorf("expected success, got %v", err)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user