mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Correct import statements
This commit is contained in:
parent
660095776a
commit
bcde05753b
@ -21,6 +21,7 @@ go_library(
|
|||||||
deps = [
|
deps = [
|
||||||
"//pkg/api:go_default_library",
|
"//pkg/api:go_default_library",
|
||||||
"//pkg/api/install:go_default_library",
|
"//pkg/api/install:go_default_library",
|
||||||
|
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
|
||||||
"//vendor:k8s.io/apimachinery/pkg/runtime",
|
"//vendor:k8s.io/apimachinery/pkg/runtime",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -26,6 +26,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
|
|
||||||
@ -57,7 +58,7 @@ func main() {
|
|||||||
nginxCrt := read(*crt)
|
nginxCrt := read(*crt)
|
||||||
nginxKey := read(*key)
|
nginxKey := read(*key)
|
||||||
secret := &api.Secret{
|
secret := &api.Secret{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "nginxsecret",
|
Name: "nginxsecret",
|
||||||
},
|
},
|
||||||
Data: map[string][]byte{
|
Data: map[string][]byte{
|
||||||
|
@ -20,6 +20,7 @@ go_library(
|
|||||||
tags = ["automanaged"],
|
tags = ["automanaged"],
|
||||||
deps = [
|
deps = [
|
||||||
"//pkg/api:go_default_library",
|
"//pkg/api:go_default_library",
|
||||||
|
"//vendor:k8s.io/apimachinery/pkg/apis/meta/v1",
|
||||||
"//vendor:k8s.io/apimachinery/pkg/runtime",
|
"//vendor:k8s.io/apimachinery/pkg/runtime",
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
@ -23,6 +23,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
)
|
)
|
||||||
@ -50,7 +51,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
cfg := read(*kubeconfig)
|
cfg := read(*kubeconfig)
|
||||||
secret := &api.Secret{
|
secret := &api.Secret{
|
||||||
ObjectMeta: api.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: *name,
|
Name: *name,
|
||||||
Namespace: *ns,
|
Namespace: *ns,
|
||||||
},
|
},
|
||||||
|
@ -22,6 +22,7 @@ import (
|
|||||||
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
"k8s.io/apiserver/pkg/storage/names"
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
"k8s.io/kubernetes/pkg/api/resource"
|
"k8s.io/kubernetes/pkg/api/resource"
|
||||||
"k8s.io/kubernetes/pkg/api/testapi"
|
"k8s.io/kubernetes/pkg/api/testapi"
|
||||||
@ -127,7 +128,7 @@ func newPod(podName string, nodeName string, label map[string]string) *v1.Pod {
|
|||||||
DNSPolicy: v1.DNSDefault,
|
DNSPolicy: v1.DNSDefault,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
metav1.GenerateName(v1.SimpleNameGenerator, &pod.ObjectMeta)
|
pod.Name = names.SimpleNameGenerator.GenerateName(podName)
|
||||||
return pod
|
return pod
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset {
|
|||||||
metrics := metricsapi.PodMetricsList{}
|
metrics := metricsapi.PodMetricsList{}
|
||||||
for i, cpu := range tc.reportedLevels {
|
for i, cpu := range tc.reportedLevels {
|
||||||
podMetric := metricsapi.PodMetrics{
|
podMetric := metricsapi.PodMetrics{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: v1.ObjectMeta{
|
||||||
Name: fmt.Sprintf("%s-%d", podNamePrefix, i),
|
Name: fmt.Sprintf("%s-%d", podNamePrefix, i),
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
},
|
},
|
||||||
|
@ -106,7 +106,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset {
|
|||||||
metrics := metricsapi.PodMetricsList{}
|
metrics := metricsapi.PodMetricsList{}
|
||||||
for i, containers := range tc.reportedPodMetrics {
|
for i, containers := range tc.reportedPodMetrics {
|
||||||
metric := metricsapi.PodMetrics{
|
metric := metricsapi.PodMetrics{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: v1.ObjectMeta{
|
||||||
Name: fmt.Sprintf("%s-%d", podNamePrefix, i),
|
Name: fmt.Sprintf("%s-%d", podNamePrefix, i),
|
||||||
Namespace: namespace,
|
Namespace: namespace,
|
||||||
},
|
},
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
--- pkg/controller/podautoscaler/metrics/metrics_client_test.go
|
|
||||||
+++ pkg/controller/podautoscaler/metrics/metrics_client_test.go
|
|
||||||
@@ -110,7 +110,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset {
|
|
||||||
Name: fmt.Sprintf("%s-%d", podNamePrefix, i),
|
|
||||||
Namespace: namespace,
|
|
||||||
},
|
|
||||||
- Timestamp: metav1.Time{Time: fixedTimestamp.Add(time.Duration(tc.targetTimestamp) * time.Minute)},
|
|
||||||
+ Timestamp: unversioned.Time{Time: fixedTimestamp.Add(time.Duration(tc.targetTimestamp) * time.Minute)},
|
|
||||||
Containers: []metrics_api.ContainerMetrics{},
|
|
||||||
}
|
|
||||||
for j, cpu := range containers {
|
|
@ -140,7 +140,7 @@ func (tc *replicaCalcTestCase) prepareTestClient(t *testing.T) *fake.Clientset {
|
|||||||
podName = tc.resource.podNames[i]
|
podName = tc.resource.podNames[i]
|
||||||
}
|
}
|
||||||
podMetric := metricsapi.PodMetrics{
|
podMetric := metricsapi.PodMetrics{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: v1.ObjectMeta{
|
||||||
Name: podName,
|
Name: podName,
|
||||||
Namespace: testNamespace,
|
Namespace: testNamespace,
|
||||||
},
|
},
|
||||||
|
@ -26,13 +26,13 @@ import (
|
|||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/apimachinery/pkg/util/validation"
|
"k8s.io/apimachinery/pkg/util/validation"
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
"k8s.io/kubernetes/pkg/kubectl"
|
"k8s.io/kubernetes/pkg/kubectl"
|
||||||
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
|
"k8s.io/kubernetes/pkg/kubectl/cmd/templates"
|
||||||
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
||||||
|
@ -25,7 +25,6 @@ import (
|
|||||||
|
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
||||||
metricsapi "k8s.io/heapster/metrics/apis/metrics/v1alpha1"
|
metricsapi "k8s.io/heapster/metrics/apis/metrics/v1alpha1"
|
||||||
"k8s.io/kubernetes/pkg/api/resource"
|
"k8s.io/kubernetes/pkg/api/resource"
|
||||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||||
@ -172,7 +171,7 @@ func TestTopPod(t *testing.T) {
|
|||||||
func testPodMetricsData() []metricsapi.PodMetrics {
|
func testPodMetricsData() []metricsapi.PodMetrics {
|
||||||
return []metricsapi.PodMetrics{
|
return []metricsapi.PodMetrics{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "pod1", Namespace: "test", ResourceVersion: "10"},
|
ObjectMeta: v1.ObjectMeta{Name: "pod1", Namespace: "test", ResourceVersion: "10"},
|
||||||
Window: unversioned.Duration{Duration: time.Minute},
|
Window: unversioned.Duration{Duration: time.Minute},
|
||||||
Containers: []metricsapi.ContainerMetrics{
|
Containers: []metricsapi.ContainerMetrics{
|
||||||
{
|
{
|
||||||
@ -194,7 +193,7 @@ func testPodMetricsData() []metricsapi.PodMetrics {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "pod2", Namespace: "test", ResourceVersion: "11"},
|
ObjectMeta: v1.ObjectMeta{Name: "pod2", Namespace: "test", ResourceVersion: "11"},
|
||||||
Window: unversioned.Duration{Duration: time.Minute},
|
Window: unversioned.Duration{Duration: time.Minute},
|
||||||
Containers: []metricsapi.ContainerMetrics{
|
Containers: []metricsapi.ContainerMetrics{
|
||||||
{
|
{
|
||||||
@ -224,7 +223,7 @@ func testPodMetricsData() []metricsapi.PodMetrics {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "pod3", Namespace: "test", ResourceVersion: "12"},
|
ObjectMeta: v1.ObjectMeta{Name: "pod3", Namespace: "test", ResourceVersion: "12"},
|
||||||
Window: unversioned.Duration{Duration: time.Minute},
|
Window: unversioned.Duration{Duration: time.Minute},
|
||||||
Containers: []metricsapi.ContainerMetrics{
|
Containers: []metricsapi.ContainerMetrics{
|
||||||
{
|
{
|
||||||
|
@ -67,7 +67,7 @@ func testNodeMetricsData() (*metricsapi.NodeMetricsList, *api.NodeList) {
|
|||||||
},
|
},
|
||||||
Items: []metricsapi.NodeMetrics{
|
Items: []metricsapi.NodeMetrics{
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "node1", ResourceVersion: "10"},
|
ObjectMeta: v1.ObjectMeta{Name: "node1", ResourceVersion: "10"},
|
||||||
Window: unversioned.Duration{Duration: time.Minute},
|
Window: unversioned.Duration{Duration: time.Minute},
|
||||||
Usage: v1.ResourceList{
|
Usage: v1.ResourceList{
|
||||||
v1.ResourceCPU: *resource.NewMilliQuantity(1, resource.DecimalSI),
|
v1.ResourceCPU: *resource.NewMilliQuantity(1, resource.DecimalSI),
|
||||||
@ -76,7 +76,7 @@ func testNodeMetricsData() (*metricsapi.NodeMetricsList, *api.NodeList) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "node2", ResourceVersion: "11"},
|
ObjectMeta: v1.ObjectMeta{Name: "node2", ResourceVersion: "11"},
|
||||||
Window: unversioned.Duration{Duration: time.Minute},
|
Window: unversioned.Duration{Duration: time.Minute},
|
||||||
Usage: v1.ResourceList{
|
Usage: v1.ResourceList{
|
||||||
v1.ResourceCPU: *resource.NewMilliQuantity(5, resource.DecimalSI),
|
v1.ResourceCPU: *resource.NewMilliQuantity(5, resource.DecimalSI),
|
||||||
|
@ -76,6 +76,7 @@ var typesAllowedTags = map[reflect.Type]bool{
|
|||||||
reflect.TypeOf(metav1.Duration{}): true,
|
reflect.TypeOf(metav1.Duration{}): true,
|
||||||
reflect.TypeOf(metav1.TypeMeta{}): true,
|
reflect.TypeOf(metav1.TypeMeta{}): true,
|
||||||
reflect.TypeOf(metav1.ListMeta{}): true,
|
reflect.TypeOf(metav1.ListMeta{}): true,
|
||||||
|
reflect.TypeOf(metav1.ObjectMeta{}): true,
|
||||||
reflect.TypeOf(metav1.OwnerReference{}): true,
|
reflect.TypeOf(metav1.OwnerReference{}): true,
|
||||||
reflect.TypeOf(metav1.LabelSelector{}): true,
|
reflect.TypeOf(metav1.LabelSelector{}): true,
|
||||||
reflect.TypeOf(metav1.GetOptions{}): true,
|
reflect.TypeOf(metav1.GetOptions{}): true,
|
||||||
|
@ -28,12 +28,12 @@ import (
|
|||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
|
|
||||||
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
kubeschema "k8s.io/apimachinery/pkg/runtime/schema"
|
kubeschema "k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apimachinery/pkg/util/yaml"
|
"k8s.io/apimachinery/pkg/util/yaml"
|
||||||
"k8s.io/apiserver/pkg/util/cache"
|
"k8s.io/apiserver/pkg/util/cache"
|
||||||
"k8s.io/apiserver/pkg/webhook"
|
"k8s.io/apiserver/pkg/webhook"
|
||||||
apierrors "k8s.io/client-go/pkg/api/errors"
|
|
||||||
"k8s.io/client-go/pkg/apis/imagepolicy/v1alpha1"
|
"k8s.io/client-go/pkg/apis/imagepolicy/v1alpha1"
|
||||||
"k8s.io/client-go/rest"
|
"k8s.io/client-go/rest"
|
||||||
"k8s.io/kubernetes/pkg/admission"
|
"k8s.io/kubernetes/pkg/admission"
|
||||||
|
@ -173,7 +173,7 @@ func ClusterRoles() []rbac.ClusterRole {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
// a role to use for heapster's connections back to the API server
|
// a role to use for heapster's connections back to the API server
|
||||||
ObjectMeta: api.ObjectMeta{Name: "system:heapster"},
|
ObjectMeta: metav1.ObjectMeta{Name: "system:heapster"},
|
||||||
Rules: []rbac.PolicyRule{
|
Rules: []rbac.PolicyRule{
|
||||||
rbac.NewRule(Read...).Groups(legacyGroup).Resources("events", "pods", "nodes", "namespaces").RuleOrDie(),
|
rbac.NewRule(Read...).Groups(legacyGroup).Resources("events", "pods", "nodes", "namespaces").RuleOrDie(),
|
||||||
},
|
},
|
||||||
@ -232,7 +232,7 @@ func ClusterRoles() []rbac.ClusterRole {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
// a role to use for bootstrapping a node's client certificates
|
// a role to use for bootstrapping a node's client certificates
|
||||||
ObjectMeta: api.ObjectMeta{Name: "system:node-bootstrapper"},
|
ObjectMeta: metav1.ObjectMeta{Name: "system:node-bootstrapper"},
|
||||||
Rules: []rbac.PolicyRule{
|
Rules: []rbac.PolicyRule{
|
||||||
// used to check if the node already exists
|
// used to check if the node already exists
|
||||||
rbac.NewRule("get").Groups(legacyGroup).Resources("nodes").RuleOrDie(),
|
rbac.NewRule("get").Groups(legacyGroup).Resources("nodes").RuleOrDie(),
|
||||||
|
@ -2824,7 +2824,7 @@ func TestInterPodAffinityWithMultipleNodes(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
pod: &v1.Pod{
|
pod: &v1.Pod{
|
||||||
ObjectMeta: v1.ObjectMeta{Labels: map[string]string{"foo": "123"}},
|
ObjectMeta: metav1.ObjectMeta{Labels: map[string]string{"foo": "123"}},
|
||||||
Spec: v1.PodSpec{
|
Spec: v1.PodSpec{
|
||||||
Affinity: &v1.Affinity{
|
Affinity: &v1.Affinity{
|
||||||
PodAntiAffinity: &v1.PodAntiAffinity{
|
PodAntiAffinity: &v1.PodAntiAffinity{
|
||||||
@ -2847,7 +2847,7 @@ func TestInterPodAffinityWithMultipleNodes(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
pods: []*v1.Pod{
|
pods: []*v1.Pod{
|
||||||
{Spec: v1.PodSpec{NodeName: "nodeA"}, ObjectMeta: v1.ObjectMeta{Labels: map[string]string{"foo": "bar"}}},
|
{Spec: v1.PodSpec{NodeName: "nodeA"}, ObjectMeta: metav1.ObjectMeta{Labels: map[string]string{"foo": "bar"}}},
|
||||||
{
|
{
|
||||||
Spec: v1.PodSpec{
|
Spec: v1.PodSpec{
|
||||||
NodeName: "nodeC",
|
NodeName: "nodeC",
|
||||||
@ -2873,10 +2873,10 @@ func TestInterPodAffinityWithMultipleNodes(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
nodes: []v1.Node{
|
nodes: []v1.Node{
|
||||||
{ObjectMeta: v1.ObjectMeta{Name: "nodeA", Labels: labelRgChina}},
|
{ObjectMeta: metav1.ObjectMeta{Name: "nodeA", Labels: labelRgChina}},
|
||||||
{ObjectMeta: v1.ObjectMeta{Name: "nodeB", Labels: labelRgChinaAzAz1}},
|
{ObjectMeta: metav1.ObjectMeta{Name: "nodeB", Labels: labelRgChinaAzAz1}},
|
||||||
{ObjectMeta: v1.ObjectMeta{Name: "nodeC", Labels: labelRgIndia}},
|
{ObjectMeta: metav1.ObjectMeta{Name: "nodeC", Labels: labelRgIndia}},
|
||||||
{ObjectMeta: v1.ObjectMeta{Name: "nodeD", Labels: labelRgUS}},
|
{ObjectMeta: metav1.ObjectMeta{Name: "nodeD", Labels: labelRgUS}},
|
||||||
},
|
},
|
||||||
fits: map[string]bool{
|
fits: map[string]bool{
|
||||||
"nodeA": false,
|
"nodeA": false,
|
||||||
@ -3214,7 +3214,7 @@ func TestPodToleratesTaints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
pod: &v1.Pod{
|
pod: &v1.Pod{
|
||||||
ObjectMeta: v1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "pod2",
|
Name: "pod2",
|
||||||
},
|
},
|
||||||
Spec: v1.PodSpec{
|
Spec: v1.PodSpec{
|
||||||
@ -3222,7 +3222,7 @@ func TestPodToleratesTaints(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
node: v1.Node{
|
node: v1.Node{
|
||||||
ObjectMeta: v1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Annotations: map[string]string{
|
Annotations: map[string]string{
|
||||||
v1.TaintsAnnotationKey: `
|
v1.TaintsAnnotationKey: `
|
||||||
[{
|
[{
|
||||||
|
@ -21,59 +21,9 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
type nameGeneratorFunc func(base string) string
|
|
||||||
|
|
||||||
func (fn nameGeneratorFunc) GenerateName(base string) string {
|
|
||||||
return fn(base)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGenerateName(t *testing.T) {
|
|
||||||
testCases := []struct {
|
|
||||||
meta ObjectMeta
|
|
||||||
|
|
||||||
base string
|
|
||||||
returned string
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
returned: "",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
meta: ObjectMeta{
|
|
||||||
GenerateName: "test",
|
|
||||||
},
|
|
||||||
base: "test",
|
|
||||||
returned: "test",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
meta: ObjectMeta{
|
|
||||||
Name: "foo",
|
|
||||||
GenerateName: "test",
|
|
||||||
},
|
|
||||||
base: "test",
|
|
||||||
returned: "foo",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for i, testCase := range testCases {
|
|
||||||
GenerateName(nameGeneratorFunc(func(base string) string {
|
|
||||||
if base != testCase.base {
|
|
||||||
t.Errorf("%d: unexpected call with base", i)
|
|
||||||
}
|
|
||||||
return "test"
|
|
||||||
}), &testCase.meta)
|
|
||||||
expect := testCase.returned
|
|
||||||
if expect != testCase.meta.Name {
|
|
||||||
t.Errorf("%d: unexpected name: %#v", i, testCase.meta)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestSimpleNameGenerator(t *testing.T) {
|
func TestSimpleNameGenerator(t *testing.T) {
|
||||||
meta := &metav1.ObjectMeta{
|
name := SimpleNameGenerator.GenerateName("foo")
|
||||||
GenerateName: "foo",
|
if !strings.HasPrefix(name, "foo") || name == "foo" {
|
||||||
}
|
t.Errorf("unexpected name: %s", name)
|
||||||
metav1.GenerateName(SimpleNameGenerator, meta)
|
|
||||||
if !strings.HasPrefix(meta.Name, "foo") || meta.Name == "foo" {
|
|
||||||
t.Errorf("unexpected name: %#v", meta)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,12 +21,12 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
"k8s.io/apimachinery/pkg/util/wait"
|
||||||
"k8s.io/client-go/pkg/api"
|
"k8s.io/client-go/pkg/api"
|
||||||
apierrors "k8s.io/client-go/pkg/api/errors"
|
|
||||||
"k8s.io/client-go/rest"
|
"k8s.io/client-go/rest"
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ import (
|
|||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
|
clientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
|
||||||
"k8s.io/kubernetes/pkg/client/restclient"
|
"k8s.io/kubernetes/pkg/client/restclient"
|
||||||
@ -106,7 +106,7 @@ func main() {
|
|||||||
} else {
|
} else {
|
||||||
// wait until the namespace disappears
|
// wait until the namespace disappears
|
||||||
for i := 0; i < int(namespaceDeleteTimeout/time.Second); i++ {
|
for i := 0; i < int(namespaceDeleteTimeout/time.Second); i++ {
|
||||||
if _, err := client.Core().Namespaces().Get(ns, v1.GetOptions{}); err != nil {
|
if _, err := client.Core().Namespaces().Get(ns, metav1.GetOptions{}); err != nil {
|
||||||
if errors.IsNotFound(err) {
|
if errors.IsNotFound(err) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -221,7 +221,7 @@ func main() {
|
|||||||
for _, podName := range podNames {
|
for _, podName := range podNames {
|
||||||
var pod *api.Pod
|
var pod *api.Pod
|
||||||
for start := time.Now(); time.Since(start) < podStartTimeout; time.Sleep(5 * time.Second) {
|
for start := time.Now(); time.Since(start) < podStartTimeout; time.Sleep(5 * time.Second) {
|
||||||
pod, err = client.Core().Pods(ns).Get(podName, v1.GetOptions{})
|
pod, err = client.Core().Pods(ns).Get(podName, metav1.GetOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Warningf("Get pod %s/%s failed, ignoring for %v: %v", ns, podName, err, podStartTimeout)
|
glog.Warningf("Get pod %s/%s failed, ignoring for %v: %v", ns, podName, err, podStartTimeout)
|
||||||
continue
|
continue
|
||||||
|
Loading…
Reference in New Issue
Block a user