diff options
| author | Shubham Singh <shubhammahar1306@gmail.com> | 2024-07-05 22:08:21 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-10 04:53:32 +0000 |
| commit | 3dbe0fa25198f7a4755fdced52621dec627480a3 (patch) | |
| tree | e41e221e281863ca0c5a9c148f66838c9ad0a402 | |
| parent | added tests covering the debug package (diff) | |
| download | kubeedge-3dbe0fa25198f7a4755fdced52621dec627480a3.tar.gz | |
fixing errors
Signed-off-by: GitHub <noreply@github.com>
| -rw-r--r-- | keadm/cmd/keadm/app/cmd/debug/collect.go | 13 | ||||
| -rw-r--r-- | keadm/cmd/keadm/app/cmd/debug/collect_test.go | 7 | ||||
| -rw-r--r-- | keadm/cmd/keadm/app/cmd/debug/debug_test.go | 5 | ||||
| -rw-r--r-- | keadm/cmd/keadm/app/cmd/debug/diagnose.go | 13 | ||||
| -rw-r--r-- | keadm/cmd/keadm/app/cmd/debug/diagnose_test.go | 7 | ||||
| -rw-r--r-- | keadm/cmd/keadm/app/cmd/debug/get_flags.go | 46 | ||||
| -rw-r--r-- | keadm/cmd/keadm/app/cmd/debug/get_flags_test.go | 8 | ||||
| -rw-r--r-- | keadm/cmd/keadm/app/cmd/debug/get_test.go | 2 |
8 files changed, 42 insertions, 59 deletions
diff --git a/keadm/cmd/keadm/app/cmd/debug/collect.go b/keadm/cmd/keadm/app/cmd/debug/collect.go index d8b4485ba..85e3b9601 100644 --- a/keadm/cmd/keadm/app/cmd/debug/collect.go +++ b/keadm/cmd/keadm/app/cmd/debug/collect.go @@ -1,16 +1,3 @@ -/* -Copyright 2024 The KubeEdge 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 debug import ( diff --git a/keadm/cmd/keadm/app/cmd/debug/collect_test.go b/keadm/cmd/keadm/app/cmd/debug/collect_test.go index 38060f9cb..028cbc303 100644 --- a/keadm/cmd/keadm/app/cmd/debug/collect_test.go +++ b/keadm/cmd/keadm/app/cmd/debug/collect_test.go @@ -1,9 +1,12 @@ /* Copyright 2024 The KubeEdge 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 + + 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. @@ -132,7 +135,7 @@ func TestCollect_AddCollectOtherFlags(t *testing.T) { func TestCollect_NewCollectOptions(t *testing.T) { assert := assert.New(t) - + co := newCollectOptions() assert.NotNil(co) diff --git a/keadm/cmd/keadm/app/cmd/debug/debug_test.go b/keadm/cmd/keadm/app/cmd/debug/debug_test.go index 81f54f1ad..8709320d2 100644 --- a/keadm/cmd/keadm/app/cmd/debug/debug_test.go +++ b/keadm/cmd/keadm/app/cmd/debug/debug_test.go @@ -1,9 +1,12 @@ /* Copyright 2024 The KubeEdge 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 + + 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. diff --git a/keadm/cmd/keadm/app/cmd/debug/diagnose.go b/keadm/cmd/keadm/app/cmd/debug/diagnose.go index 982bbe1d9..ce5cf2e56 100644 --- a/keadm/cmd/keadm/app/cmd/debug/diagnose.go +++ b/keadm/cmd/keadm/app/cmd/debug/diagnose.go @@ -1,16 +1,3 @@ -/* -Copyright 2024 The KubeEdge 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 debug import ( diff --git a/keadm/cmd/keadm/app/cmd/debug/diagnose_test.go b/keadm/cmd/keadm/app/cmd/debug/diagnose_test.go index e6b7b8845..d4832bfd7 100644 --- a/keadm/cmd/keadm/app/cmd/debug/diagnose_test.go +++ b/keadm/cmd/keadm/app/cmd/debug/diagnose_test.go @@ -1,9 +1,12 @@ /* Copyright 2024 The KubeEdge 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 + + 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. @@ -123,7 +126,7 @@ func TestNewSubDiagnose(t *testing.T) { func TestNewDiagnoseOptions(t *testing.T) { assert := assert.New(t) - + do := NewDiagnoseOptions() assert.NotNil(do) diff --git a/keadm/cmd/keadm/app/cmd/debug/get_flags.go b/keadm/cmd/keadm/app/cmd/debug/get_flags.go index fbfa5fbc9..7051ba6eb 100644 --- a/keadm/cmd/keadm/app/cmd/debug/get_flags.go +++ b/keadm/cmd/keadm/app/cmd/debug/get_flags.go @@ -101,33 +101,13 @@ type HumanPrintFlags struct { // AllowedFormats returns more customized formating options func (f *HumanPrintFlags) AllowedFormats() []string { - return []string{"wide"} -} - -// NewHumanPrintFlags returns flags associated with -// human-readable printing, with default values set. -func NewHumanPrintFlags() *HumanPrintFlags { - showLabels := false - sortBy := "" - showKind := false - columnLabels := []string{} - - return &HumanPrintFlags{ - NoHeaders: false, - WithNamespace: false, - ColumnLabels: &columnLabels, - - Kind: schema.GroupKind{}, - ShowLabels: &showLabels, - SortBy: &sortBy, - ShowKind: &showKind, - } + return []string{FormatTypeWIDE} } // ToPrinter receives an outputFormat and returns a printer capable of // handling human-readable output. func (f *HumanPrintFlags) ToPrinter(outputFormat string) (printers.ResourcePrinter, error) { - if len(outputFormat) > 0 && outputFormat != "wide" { + if len(outputFormat) > 0 && outputFormat != FormatTypeWIDE { return nil, genericclioptions.NoCompatiblePrinterError{Options: f, AllowedFormats: f.AllowedFormats()} } @@ -150,7 +130,7 @@ func (f *HumanPrintFlags) ToPrinter(outputFormat string) (printers.ResourcePrint Kind: f.Kind, WithKind: showKind, NoHeaders: f.NoHeaders, - Wide: outputFormat == "wide", + Wide: outputFormat == FormatTypeWIDE, WithNamespace: f.WithNamespace, ColumnLabels: columnLabels, ShowLabels: showLabels, @@ -159,6 +139,26 @@ func (f *HumanPrintFlags) ToPrinter(outputFormat string) (printers.ResourcePrint return p, nil } +// NewHumanPrintFlags returns flags associated with +// human-readable printing, with default values set. +func NewHumanPrintFlags() *HumanPrintFlags { + showLabels := false + sortBy := "" + showKind := false + columnLabels := []string{} + + return &HumanPrintFlags{ + NoHeaders: false, + WithNamespace: false, + ColumnLabels: &columnLabels, + + Kind: schema.GroupKind{}, + ShowLabels: &showLabels, + SortBy: &sortBy, + ShowKind: &showKind, + } +} + // EnsureWithNamespace ensures that humanreadable flags return // a printer capable of printing with a "namespace" column. func (f *PrintFlags) EnsureWithNamespace() error { diff --git a/keadm/cmd/keadm/app/cmd/debug/get_flags_test.go b/keadm/cmd/keadm/app/cmd/debug/get_flags_test.go index 065eceec6..b0fa7701b 100644 --- a/keadm/cmd/keadm/app/cmd/debug/get_flags_test.go +++ b/keadm/cmd/keadm/app/cmd/debug/get_flags_test.go @@ -64,7 +64,7 @@ func TestToPrinter(t *testing.T) { assert.NoError(err) assert.NotNil(printer) - *printFlags.OutputFormat = "wide" + *printFlags.OutputFormat = FormatTypeWIDE printer, err = printFlags.ToPrinter() assert.NoError(err) assert.NotNil(printer) @@ -74,7 +74,7 @@ func TestToPrinter(t *testing.T) { assert.Error(err) assert.Nil(printer) - *printFlags.OutputFormat = "wide" + *printFlags.OutputFormat = FormatTypeWIDE *printFlags.NoHeaders = true printer, err = printFlags.ToPrinter() assert.NoError(err) @@ -119,7 +119,7 @@ func TestHumanPrintFlags_AllowedFormats(t *testing.T) { humanPrintFlags := &HumanPrintFlags{} formats := humanPrintFlags.AllowedFormats() - expectedFormats := []string{"wide"} + expectedFormats := []string{FormatTypeWIDE} assert.Equal(expectedFormats, formats) } @@ -151,7 +151,7 @@ func TestHumanPrintFlags_ToPrinter(t *testing.T) { WithNamespace: false, } - outputFormat := "wide" + outputFormat := FormatTypeWIDE printer, err := humanPrintFlags.ToPrinter(outputFormat) assert.NoError(err) assert.NotNil(printer) diff --git a/keadm/cmd/keadm/app/cmd/debug/get_test.go b/keadm/cmd/keadm/app/cmd/debug/get_test.go index 9fa92e98d..e99668a41 100644 --- a/keadm/cmd/keadm/app/cmd/debug/get_test.go +++ b/keadm/cmd/keadm/app/cmd/debug/get_test.go @@ -1,5 +1,5 @@ /* -Copyright 2024 The KubeEdge Authors. +Copyright 2020 The KubeEdge 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 |
