diff --git a/cmd/endpointList.go b/cmd/endpointList.go index 0fa3209..650bf90 100644 --- a/cmd/endpointList.go +++ b/cmd/endpointList.go @@ -53,7 +53,7 @@ var endpointListCmd = &cobra.Command{ } } else { // Print all endpoint fields as a table - writer, err := util.NewTabWriter([]string{ + writer, err := common.NewTabWriter([]string{ "ENDPOINT ID", "NAME", "TYPE", diff --git a/cmd/stackList.go b/cmd/stackList.go index 1a245b7..f68c4ee 100644 --- a/cmd/stackList.go +++ b/cmd/stackList.go @@ -43,7 +43,7 @@ var stackListCmd = &cobra.Command{ } } else { // Print all stack fields as a table - writer, err := util.NewTabWriter([]string{ + writer, err := common.NewTabWriter([]string{ "STACK ID", "NAME", "TYPE", diff --git a/cmd/status.go b/cmd/status.go index e1d872e..a57e11a 100644 --- a/cmd/status.go +++ b/cmd/status.go @@ -5,8 +5,6 @@ import ( "os" "text/template" - "github.com/greenled/portainer-stack-utils/util" - "github.com/greenled/portainer-stack-utils/common" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -32,7 +30,7 @@ var statusCmd = &cobra.Command{ fmt.Println() } else { // Print status fields as a table - writer, newTabWriterErr := util.NewTabWriter([]string{ + writer, newTabWriterErr := common.NewTabWriter([]string{ "VERSION", "AUTHENTICATION", "ENDPOINT MANAGEMENT", diff --git a/common/printing.go b/common/printing.go new file mode 100644 index 0000000..218d210 --- /dev/null +++ b/common/printing.go @@ -0,0 +1,17 @@ +package common + +import ( + "fmt" + "os" + "strings" + "text/tabwriter" +) + +func NewTabWriter(headers []string) (*tabwriter.Writer, error) { + writer := tabwriter.NewWriter(os.Stdout, 20, 2, 3, ' ', 0) + _, err := fmt.Fprintln(writer, strings.Join(headers, "\t")) + if err != nil { + return &tabwriter.Writer{}, err + } + return writer, nil +} diff --git a/util/printing.go b/util/printing.go index 94a1d73..8a04187 100644 --- a/util/printing.go +++ b/util/printing.go @@ -1,11 +1,7 @@ package util import ( - "fmt" "log" - "os" - "strings" - "text/tabwriter" "github.com/spf13/viper" ) @@ -21,12 +17,3 @@ func PrintDebug(a ...interface{}) { log.Println(a) } } - -func NewTabWriter(headers []string) (*tabwriter.Writer, error) { - writer := tabwriter.NewWriter(os.Stdout, 20, 2, 3, ' ', 0) - _, err := fmt.Fprintln(writer, strings.Join(headers, "\t")) - if err != nil { - return &tabwriter.Writer{}, err - } - return writer, nil -}