Skip to content

Commit

Permalink
Fix linter errors 🙀
Browse files Browse the repository at this point in the history
Somehow the CI didn't catch those, make sure golang-lint is ran on the cluster.

Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
  • Loading branch information
vdemeester authored and tekton-robot committed Jul 30, 2019
1 parent 12e3331 commit 878d27f
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 26 deletions.
16 changes: 9 additions & 7 deletions pkg/cmd/pipeline/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ import (
"strings"

"github.com/AlecAivazis/survey/v2"
"github.com/AlecAivazis/survey/v2/terminal"
"github.com/spf13/cobra"
"github.com/tektoncd/cli/pkg/cli"
"github.com/tektoncd/cli/pkg/cmd/pipelinerun"
"github.com/tektoncd/cli/pkg/formatted"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/AlecAivazis/survey/v2/terminal"

)

type logOptions struct {
Expand Down Expand Up @@ -59,10 +58,10 @@ func logCommand(p cli.Params) *cobra.Command {
`
c := &cobra.Command{
Use: "logs",
Use: "logs",
DisableFlagsInUseLine: true,
Short: "Show the logs of latest pipelinerun of given pipeline ",
Example: eg,
Short: "Show the logs of latest pipelinerun of given pipeline ",
Example: eg,
RunE: func(cmd *cobra.Command, args []string) error {
opts.stream = &cli.Stream{
Out: cmd.OutOrStdout(),
Expand Down Expand Up @@ -114,8 +113,8 @@ func (opts *logOptions) init(args []string) error {
opts.runName = args[1]

default:
fmt.Fprintln(opts.stream.Err,"too many arguments")
return nil
fmt.Fprintln(opts.stream.Err, "too many arguments")
return nil

}
return nil
Expand Down Expand Up @@ -175,6 +174,9 @@ func (opts *logOptions) initLastRunName() error {
return err
}
lastrun, err := lastRun(cs, opts.params.Namespace(), opts.pipelineName)
if err != nil {
return err
}
opts.runName = lastrun
return nil
}
Expand Down
8 changes: 0 additions & 8 deletions pkg/cmd/pipeline/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,10 @@ func init() {
}

var (
answer = ""
pipelineName = "output-pipeline"
prName = "output-pipeline-run"
prName2 = "output-pipeline-run-2"
prstart = clockwork.NewFakeClock()
ns = "namespace"

task1Name = "output-task"
tr1Name = "output-task-run"
tr1StartTime = prstart.Now().Add(20 * time.Second)
tr1Pod = "output-task-pod-123456"
tr1Step1Name = "writefile-step"
)

func TestInteractiveAskPAndPR(t *testing.T) {
Expand Down
9 changes: 4 additions & 5 deletions pkg/cmd/pipeline/logs_testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import (
"bytes"
"testing"

"github.com/tektoncd/cli/pkg/cli"

"github.com/hinshun/vt10x"

"github.com/AlecAivazis/survey/v2"
Expand All @@ -31,7 +29,6 @@ import (
type promptTest struct {
name string
cmdArgs []string
clientset *cli.Params
procedure func(*expect.Console) error
}

Expand All @@ -50,7 +47,7 @@ func (opts *logOptions) RunPromptTest(t *testing.T, test promptTest) {
}

func stdio(c *expect.Console) terminal.Stdio {
return terminal.Stdio{c.Tty(), c.Tty(), c.Tty()}
return terminal.Stdio{In: c.Tty(), Out: c.Tty(), Err: c.Tty()}
}

func (pt *promptTest) runTest(t *testing.T, procedure func(*expect.Console) error, test func(terminal.Stdio) error) {
Expand All @@ -65,7 +62,9 @@ func (pt *promptTest) runTest(t *testing.T, procedure func(*expect.Console) erro
donec := make(chan struct{})
go func() {
defer close(donec)
procedure(c)
if err := procedure(c); err != nil {
t.Logf("procedure failed: %v", err)
}
}()

err = test(stdio(c))
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/pipelinerun/log_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package pipelinerun

import (
"fmt"

"github.com/tektoncd/cli/pkg/cli"
"github.com/tektoncd/cli/pkg/formatted"
)
Expand Down
11 changes: 5 additions & 6 deletions pkg/cmd/pipelinerun/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ package pipelinerun
import (
"fmt"

"github.com/tektoncd/cli/pkg/helper/pods/stream"

"github.com/spf13/cobra"
"github.com/tektoncd/cli/pkg/cli"
"github.com/tektoncd/cli/pkg/helper/pods"
"github.com/tektoncd/cli/pkg/helper/pods/stream"
)

const (
Expand Down Expand Up @@ -56,11 +55,11 @@ func logCommand(p cli.Params) *cobra.Command {
`

c := &cobra.Command{
Use: "logs",
Use: "logs",
DisableFlagsInUseLine: true,
Short: "Show the logs of PipelineRun",
Example: eg,
Args: cobra.ExactArgs(1),
Short: "Show the logs of PipelineRun",
Example: eg,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
opts.PipelineRunName = args[0]
opts.Stream = &cli.Stream{
Expand Down
4 changes: 4 additions & 0 deletions test/presubmit-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ function pre_build_tests() {
go get -u github.com/knative/test-infra/tools/dep-collector
}

function post_build_tests() {
golangci-lint run
}

# We use the default build, unit and integration test runners.

main $@

0 comments on commit 878d27f

Please sign in to comment.