Skip to content

Commit

Permalink
Fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
anujc25 committed Jan 21, 2025
1 parent 7424524 commit 9314b92
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 50 deletions.
27 changes: 2 additions & 25 deletions command/extend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func TestVisit(t *testing.T) {
return &cobra.Command{Use: "root"}
},
visitor: func(cmd *cobra.Command) error {
return fmt.Errorf(cmd.Name())
return fmt.Errorf("%s", cmd.Name())
},
err: fmt.Errorf("root"),
}, {
Expand All @@ -139,7 +139,7 @@ func TestVisit(t *testing.T) {
},
visitor: func(cmd *cobra.Command) error {
if cmd.Name() == "child" {
return fmt.Errorf(cmd.Name())
return fmt.Errorf("%s", cmd.Name())
}
return nil
},
Expand All @@ -156,29 +156,6 @@ func TestVisit(t *testing.T) {
}
}

// func TestReadStdin(t *testing.T) {
// // TODO is it possible to test the IsTerminal branch?
// expected := []byte("hello")
// var actual []byte

// scheme := runtime.NewScheme()
// c := NewDefaultConfig("test", scheme)
// c.Stdin = bytes.NewBuffer(expected)
// runE := ReadStdin(c, &actual, "> ")

// cmd := &cobra.Command{}
// args := []string{}

// err := runE(cmd, args)

// if err != nil {
// t.Errorf("expected no error, actually %v", err)
// }
// if string(expected) != string(actual) {
// t.Errorf("expected input %q, actually %q", expected, actual)
// }
// }

func TestCommandFromContext_WithCommand(t *testing.T) {
cmd := &cobra.Command{}
parentCtx := context.Background()
Expand Down
3 changes: 3 additions & 0 deletions component/characters/spaces.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Copyright 2025 VMware, Inc. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

// Package characters provides common set of characters for spaces and icons
//
//nolint:revive
package characters

const (
Expand Down
1 change: 1 addition & 0 deletions component/printer/color.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2025 VMware, Inc. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

// Package printer provides helpers to get different prints with different colors
package printer

import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// Package tabwriter implements a write filter (tabwriter.Writer) that
// Package implements a write filter (tabwriter.Writer) that
// translates tabbed columns in input into properly aligned text.
//
// It is a drop-in replacement for the golang text/tabwriter package (https://golang.org/pkg/text/tabwriter),
Expand All @@ -18,7 +18,10 @@
// repackaged from https://github.com/liggitt/tabwriter/tree/6880f16551ff10c60d3989df2bbd68a55bb3517f
// adds IgnoreAnsiCodes

package tabwriter
// Package internal is repackaged from https://github.com/liggitt/tabwriter/tree/6880f16551ff10c60d3989df2bbd68a55bb3517f and adds IgnoreAnsiCodes
//
//nolint:gocyclo,gocritic,unused,nakedret,stylecheck
package internal

import (
"io"
Expand Down
29 changes: 6 additions & 23 deletions component/tabwriter/tabwriter.go
Original file line number Diff line number Diff line change
@@ -1,45 +1,28 @@
// Copyright 2025 VMware, Inc. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

/*
Copyright 2017 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.
*/

// repackaged https://github.com/kubernetes/cli-runtime/blob/v0.28.1/pkg/printers

package table
// Package tabwriter exposes an tabwriter functionality
package tabwriter

import (
"io"

"github.com/vmware-tanzu/tanzu-plugin-runtime/component/internal/tabwriter"
"github.com/vmware-tanzu/tanzu-plugin-runtime/component/tabwriter/internal"
)

const (
tabwriterMinWidth = 6
tabwriterWidth = 4
tabwriterPadding = 3
tabwriterPadChar = ' '
tabwriterFlags = tabwriter.RememberWidths | tabwriter.IgnoreAnsiCodes
tabwriterFlags = internal.RememberWidths | internal.IgnoreAnsiCodes
)

var (
tabwriterPaddingStart int
)

// GetNewTabWriter returns a tabwriter that translates tabbed columns in input into properly aligned text.
func GetNewTabWriter(output io.Writer) *tabwriter.Writer {
return tabwriter.NewWriter(output, tabwriterMinWidth, tabwriterWidth, tabwriterPadding, tabwriterPadChar, tabwriterPaddingStart, tabwriterFlags)
func GetNewTabWriter(output io.Writer) *internal.Writer {
return internal.NewWriter(output, tabwriterMinWidth, tabwriterWidth, tabwriterPadding, tabwriterPadChar, tabwriterPaddingStart, tabwriterFlags)
}

0 comments on commit 9314b92

Please sign in to comment.