Merge pull request #101004 from lojies/cleanupforkubectl
code cleanup for kubectl Kubernetes-commit: c2c0f913856e92d529ad436c3a93a6300439d8f2
This commit is contained in:
commit
debce2e8f0
6
go.mod
6
go.mod
|
@ -34,7 +34,7 @@ require (
|
|||
k8s.io/api v0.0.0-20211029201511-cca52a076791
|
||||
k8s.io/apimachinery v0.0.0-20211028185107-b255da54548a
|
||||
k8s.io/cli-runtime v0.0.0-20211027005851-fd0a6d95140a
|
||||
k8s.io/client-go v0.0.0-20211030045615-2f5d8b0c528d
|
||||
k8s.io/client-go v0.0.0-20211102163907-e57f40404feb
|
||||
k8s.io/component-base v0.0.0-20211027004438-bd08cb7812c3
|
||||
k8s.io/component-helpers v0.0.0-20211027004542-73bcdef827e4
|
||||
k8s.io/klog/v2 v2.30.0
|
||||
|
@ -50,8 +50,8 @@ replace (
|
|||
k8s.io/api => k8s.io/api v0.0.0-20211029201511-cca52a076791
|
||||
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20211028185107-b255da54548a
|
||||
k8s.io/cli-runtime => k8s.io/cli-runtime v0.0.0-20211027005851-fd0a6d95140a
|
||||
k8s.io/client-go => k8s.io/client-go v0.0.0-20211030045615-2f5d8b0c528d
|
||||
k8s.io/code-generator => k8s.io/code-generator v0.0.0-20211026222709-e92ab9f4d5a1
|
||||
k8s.io/client-go => k8s.io/client-go v0.0.0-20211102163907-e57f40404feb
|
||||
k8s.io/code-generator => k8s.io/code-generator v0.0.0-20211102141458-35fbf2653103
|
||||
k8s.io/component-base => k8s.io/component-base v0.0.0-20211027004438-bd08cb7812c3
|
||||
k8s.io/component-helpers => k8s.io/component-helpers v0.0.0-20211027004542-73bcdef827e4
|
||||
k8s.io/metrics => k8s.io/metrics v0.0.0-20211027005740-e276d9db6a9e
|
||||
|
|
6
go.sum
6
go.sum
|
@ -908,9 +908,9 @@ k8s.io/apimachinery v0.0.0-20211028185107-b255da54548a h1:3NA1KMmF0ie/tLSNnA3v1i
|
|||
k8s.io/apimachinery v0.0.0-20211028185107-b255da54548a/go.mod h1:oyH3LcOKLLooQH1NlpHlilzkWxqsiHWETyHgssntcXg=
|
||||
k8s.io/cli-runtime v0.0.0-20211027005851-fd0a6d95140a h1:6N6d0a80cFO2PI8RssKTsofnWWdzr4LBWKKe0t+1kAk=
|
||||
k8s.io/cli-runtime v0.0.0-20211027005851-fd0a6d95140a/go.mod h1:C/9bEqryTALzT3y/AJFeg2TqzudoaRZrdr4Zdoeetn0=
|
||||
k8s.io/client-go v0.0.0-20211030045615-2f5d8b0c528d h1:x2WpKnettnxR4Y+chwKpBMRSz5ibcRsGkXnn3V1zuVg=
|
||||
k8s.io/client-go v0.0.0-20211030045615-2f5d8b0c528d/go.mod h1:AeiEb+/G5s6RA7edXOQ1MJ1JyCAxXwoAYZ7CJhpF0Ow=
|
||||
k8s.io/code-generator v0.0.0-20211026222709-e92ab9f4d5a1/go.mod h1:alK4pz5+y/zKXOPBnND3TvXOC/iF2oYTBDynHO1+qlI=
|
||||
k8s.io/client-go v0.0.0-20211102163907-e57f40404feb h1:UfnbQ/wq4DHX52UrB9VFuy928tusLs7SnNiM2Q2d0Yc=
|
||||
k8s.io/client-go v0.0.0-20211102163907-e57f40404feb/go.mod h1:AeiEb+/G5s6RA7edXOQ1MJ1JyCAxXwoAYZ7CJhpF0Ow=
|
||||
k8s.io/code-generator v0.0.0-20211102141458-35fbf2653103/go.mod h1:alK4pz5+y/zKXOPBnND3TvXOC/iF2oYTBDynHO1+qlI=
|
||||
k8s.io/component-base v0.0.0-20211027004438-bd08cb7812c3 h1:Hx2Olj7sA4W9r8veeamsvNiiYf5SMTN/N/1uAMQk13c=
|
||||
k8s.io/component-base v0.0.0-20211027004438-bd08cb7812c3/go.mod h1:7xqZFY7A2hOLqh+cOR9jinp+xJVXp6F5I1rOO+kBKJc=
|
||||
k8s.io/component-helpers v0.0.0-20211027004542-73bcdef827e4 h1:8umcjzLRjGapYYFQ4SUIwXCoLi8orNIce0ll3OQ+tmg=
|
||||
|
|
|
@ -121,7 +121,7 @@ func NewCmdAutoscale(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *
|
|||
cmd.Flags().Int32Var(&o.Min, "min", -1, "The lower limit for the number of pods that can be set by the autoscaler. If it's not specified or negative, the server will apply a default value.")
|
||||
cmd.Flags().Int32Var(&o.Max, "max", -1, "The upper limit for the number of pods that can be set by the autoscaler. Required.")
|
||||
cmd.MarkFlagRequired("max")
|
||||
cmd.Flags().Int32Var(&o.CPUPercent, "cpu-percent", -1, fmt.Sprintf("The target average CPU utilization (represented as a percent of requested CPU) over all the pods. If it's not specified or negative, a default autoscaling policy will be used."))
|
||||
cmd.Flags().Int32Var(&o.CPUPercent, "cpu-percent", -1, "The target average CPU utilization (represented as a percent of requested CPU) over all the pods. If it's not specified or negative, a default autoscaling policy will be used.")
|
||||
cmd.Flags().StringVar(&o.Name, "name", "", i18n.T("The name for the newly created object. If not specified, the name of the input resource will be used."))
|
||||
cmdutil.AddDryRunFlag(cmd)
|
||||
cmdutil.AddFilenameOptionFlags(cmd, o.FilenameOptions, "identifying the resource to autoscale.")
|
||||
|
|
|
@ -26,7 +26,6 @@ import (
|
|||
certificatesv1 "k8s.io/api/certificates/v1"
|
||||
certificatesv1beta1 "k8s.io/api/certificates/v1beta1"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
|
@ -259,7 +258,7 @@ func (o *CertificateOptions) modifyCertificateCondition(builder *resource.Builde
|
|||
default:
|
||||
return fmt.Errorf("can only handle certificates.k8s.io CertificateSigningRequest objects, got %T", modifiedCSR)
|
||||
}
|
||||
if errors.IsConflict(err) && i < 10 {
|
||||
if apierrors.IsConflict(err) && i < 10 {
|
||||
if err := info.Get(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -320,8 +320,7 @@ func (o *CreateIngressOptions) buildIngressSpec() networkingv1.IngressSpec {
|
|||
}
|
||||
|
||||
func (o *CreateIngressOptions) buildTLSRules() []networkingv1.IngressTLS {
|
||||
var hostAlreadyPresent map[string]struct{}
|
||||
hostAlreadyPresent = make(map[string]struct{})
|
||||
hostAlreadyPresent := make(map[string]struct{})
|
||||
|
||||
ingressTLSs := []networkingv1.IngressTLS{}
|
||||
var secret string
|
||||
|
|
|
@ -20,7 +20,6 @@ import (
|
|||
"testing"
|
||||
|
||||
networkingv1 "k8s.io/api/networking/v1"
|
||||
v1 "k8s.io/api/networking/v1"
|
||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
@ -192,7 +191,7 @@ func TestCreateIngress(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
TLS: []v1.IngressTLS{},
|
||||
TLS: []networkingv1.IngressTLS{},
|
||||
Rules: []networkingv1.IngressRule{
|
||||
{
|
||||
Host: "",
|
||||
|
@ -245,7 +244,7 @@ func TestCreateIngress(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
TLS: []v1.IngressTLS{
|
||||
TLS: []networkingv1.IngressTLS{
|
||||
{
|
||||
SecretName: "secret1",
|
||||
},
|
||||
|
@ -305,7 +304,7 @@ func TestCreateIngress(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
TLS: []v1.IngressTLS{
|
||||
TLS: []networkingv1.IngressTLS{
|
||||
{
|
||||
Hosts: []string{
|
||||
"foo.com",
|
||||
|
@ -456,7 +455,7 @@ func TestCreateIngress(t *testing.T) {
|
|||
},
|
||||
},
|
||||
Spec: networkingv1.IngressSpec{
|
||||
TLS: []v1.IngressTLS{
|
||||
TLS: []networkingv1.IngressTLS{
|
||||
{
|
||||
Hosts: []string{
|
||||
"foo.com",
|
||||
|
|
|
@ -26,7 +26,6 @@ import (
|
|||
"github.com/google/go-cmp/cmp"
|
||||
"github.com/google/go-cmp/cmp/cmpopts"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
cmdtesting "k8s.io/kubectl/pkg/cmd/testing"
|
||||
|
@ -1300,7 +1299,7 @@ func TestCompleteAndValidate(t *testing.T) {
|
|||
args: "--image=busybox --env=FOO=BAR mypod",
|
||||
wantOpts: &DebugOptions{
|
||||
Args: []string{},
|
||||
Env: []v1.EnvVar{{Name: "FOO", Value: "BAR"}},
|
||||
Env: []corev1.EnvVar{{Name: "FOO", Value: "BAR"}},
|
||||
Image: "busybox",
|
||||
Namespace: "test",
|
||||
ShareProcesses: true,
|
||||
|
|
|
@ -19,7 +19,6 @@ package get
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
encjson "encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
|
@ -124,13 +123,13 @@ func TestGetUnknownSchemaObject(t *testing.T) {
|
|||
for i, obj := range actual {
|
||||
expectedJSON := runtime.EncodeOrDie(codec, expected[i])
|
||||
expectedMap := map[string]interface{}{}
|
||||
if err := encjson.Unmarshal([]byte(expectedJSON), &expectedMap); err != nil {
|
||||
if err := json.Unmarshal([]byte(expectedJSON), &expectedMap); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
actualJSON := runtime.EncodeOrDie(codec, obj)
|
||||
actualMap := map[string]interface{}{}
|
||||
if err := encjson.Unmarshal([]byte(actualJSON), &actualMap); err != nil {
|
||||
if err := json.Unmarshal([]byte(actualJSON), &actualMap); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
@ -879,7 +878,7 @@ func TestGetSortedObjectsUnstructuredTable(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
unstructuredBytes, err := encjson.MarshalIndent(unstructuredMap, "", " ")
|
||||
unstructuredBytes, err := json.MarshalIndent(unstructuredMap, "", " ")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -52,7 +52,6 @@ import (
|
|||
rbacv1 "k8s.io/api/rbac/v1"
|
||||
schedulingv1 "k8s.io/api/scheduling/v1"
|
||||
storagev1 "k8s.io/api/storage/v1"
|
||||
"k8s.io/apimachinery/pkg/api/errors"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
"k8s.io/apimachinery/pkg/api/resource"
|
||||
|
@ -414,7 +413,7 @@ func (d *NamespaceDescriber) Describe(namespace, name string, describerSettings
|
|||
return newList, nil
|
||||
})
|
||||
if err != nil {
|
||||
if errors.IsNotFound(err) {
|
||||
if apierrors.IsNotFound(err) {
|
||||
// Server does not support resource quotas.
|
||||
// Not an error, will not show resource quotas information.
|
||||
resourceQuotaList = nil
|
||||
|
@ -434,7 +433,7 @@ func (d *NamespaceDescriber) Describe(namespace, name string, describerSettings
|
|||
return newList, nil
|
||||
})
|
||||
if err != nil {
|
||||
if errors.IsNotFound(err) {
|
||||
if apierrors.IsNotFound(err) {
|
||||
// Server does not support limit ranges.
|
||||
// Not an error, will not show limit ranges information.
|
||||
limitRangeList = nil
|
||||
|
@ -3493,7 +3492,7 @@ func (d *NodeDescriber) Describe(namespace, name string, describerSettings Descr
|
|||
}
|
||||
nodeNonTerminatedPodsList, err := getPodsInChunks(d.CoreV1().Pods(namespace), initialOpts)
|
||||
if err != nil {
|
||||
if !errors.IsForbidden(err) {
|
||||
if !apierrors.IsForbidden(err) {
|
||||
return "", err
|
||||
}
|
||||
canViewPods = false
|
||||
|
|
Loading…
Reference in New Issue