From 119400ad714b97fee7b139ee70c3b2996aa902ab Mon Sep 17 00:00:00 2001 From: aaa <1693291525@qq.com> Date: Thu, 11 Apr 2019 12:16:29 -0400 Subject: [PATCH] Use constant blocks to define constants in pkg/kubectl --- pkg/kubectl/cmd/apply/apply_test.go | 11 ++++------- pkg/kubectl/cmd/set/set_serviceaccount_test.go | 8 +++++--- pkg/kubectl/explain/model_printer.go | 13 +++++++------ 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pkg/kubectl/cmd/apply/apply_test.go b/pkg/kubectl/cmd/apply/apply_test.go index adae68a0cc3..18e11835b7d 100644 --- a/pkg/kubectl/cmd/apply/apply_test.go +++ b/pkg/kubectl/cmd/apply/apply_test.go @@ -100,8 +100,10 @@ const ( dirName = "../../../../test/fixtures/pkg/kubectl/cmd/apply/testdir" filenameRCJSON = "../../../../test/fixtures/pkg/kubectl/cmd/apply/rc.json" - filenameWidgetClientside = "../../../../test/fixtures/pkg/kubectl/cmd/apply/widget-clientside.yaml" - filenameWidgetServerside = "../../../../test/fixtures/pkg/kubectl/cmd/apply/widget-serverside.yaml" + filenameWidgetClientside = "../../../../test/fixtures/pkg/kubectl/cmd/apply/widget-clientside.yaml" + filenameWidgetServerside = "../../../../test/fixtures/pkg/kubectl/cmd/apply/widget-serverside.yaml" + filenameDeployObjServerside = "../../../../test/fixtures/pkg/kubectl/cmd/apply/deploy-serverside.yaml" + filenameDeployObjClientside = "../../../../test/fixtures/pkg/kubectl/cmd/apply/deploy-clientside.yaml" ) func readConfigMapList(t *testing.T, filename string) [][]byte { @@ -870,11 +872,6 @@ func testApplyMultipleObjects(t *testing.T, asList bool) { } } -const ( - filenameDeployObjServerside = "../../../../test/fixtures/pkg/kubectl/cmd/apply/deploy-serverside.yaml" - filenameDeployObjClientside = "../../../../test/fixtures/pkg/kubectl/cmd/apply/deploy-clientside.yaml" -) - func readDeploymentFromFile(t *testing.T, file string) []byte { raw := readBytesFromFile(t, file) obj := &appsv1.Deployment{} diff --git a/pkg/kubectl/cmd/set/set_serviceaccount_test.go b/pkg/kubectl/cmd/set/set_serviceaccount_test.go index 2bf7cd42533..a518bcb1e4f 100644 --- a/pkg/kubectl/cmd/set/set_serviceaccount_test.go +++ b/pkg/kubectl/cmd/set/set_serviceaccount_test.go @@ -41,14 +41,16 @@ import ( "k8s.io/kubernetes/pkg/kubectl/scheme" ) -const serviceAccount = "serviceaccount1" -const serviceAccountMissingErrString = "serviceaccount is required" -const resourceMissingErrString = `You must provide one or more resources by argument or filename. +const ( + serviceAccount = "serviceaccount1" + serviceAccountMissingErrString = "serviceaccount is required" + resourceMissingErrString = `You must provide one or more resources by argument or filename. Example resource specifications include: '-f rsrc.yaml' '--filename=rsrc.json' ' ' ''` +) func TestSetServiceAccountLocal(t *testing.T) { inputs := []struct { diff --git a/pkg/kubectl/explain/model_printer.go b/pkg/kubectl/explain/model_printer.go index f717cf6a6aa..2de90c11f34 100644 --- a/pkg/kubectl/explain/model_printer.go +++ b/pkg/kubectl/explain/model_printer.go @@ -21,12 +21,13 @@ import ( "k8s.io/kube-openapi/pkg/util/proto" ) -// fieldIndentLevel is the level of indentation for fields. -const fieldIndentLevel = 3 - -// descriptionIndentLevel is the level of indentation for the -// description. -const descriptionIndentLevel = 5 +const ( + // fieldIndentLevel is the level of indentation for fields. + fieldIndentLevel = 3 + // descriptionIndentLevel is the level of indentation for the + // description. + descriptionIndentLevel = 5 +) // modelPrinter prints a schema in Writer. Its "Builder" will decide if // it's recursive or not.