Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activate more linters #3057

Merged
merged 2 commits into from
Oct 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions cmd/skaffold/app/cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ import (
"io"
"io/ioutil"

"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"

"github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/flags"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/config"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion cmd/skaffold/app/cmd/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ import (
"io"
"testing"

"github.com/GoogleContainerTools/skaffold/testutil"
"github.com/spf13/pflag"

"github.com/GoogleContainerTools/skaffold/testutil"
)

func TestNewCmdDescription(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion cmd/skaffold/app/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ limitations under the License.
package cmd

import (
"github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/cmd/config"
"github.com/spf13/cobra"
"github.com/spf13/pflag"

"github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/cmd/config"
)

func NewCmdConfig() *cobra.Command {
Expand Down
3 changes: 2 additions & 1 deletion cmd/skaffold/app/cmd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import (
"context"
"io"

"github.com/spf13/cobra"

debugging "github.com/GoogleContainerTools/skaffold/pkg/skaffold/debug"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/deploy"
"github.com/spf13/cobra"
)

// NewCmdDebug describes the CLI command to run a pipeline in debug mode.
Expand Down
3 changes: 2 additions & 1 deletion cmd/skaffold/app/cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import (
"context"
"io"

"github.com/spf13/cobra"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/spf13/cobra"
)

// NewCmdDelete describes the CLI command to delete deployed resources.
Expand Down
5 changes: 3 additions & 2 deletions cmd/skaffold/app/cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ import (
"fmt"
"io"

"github.com/spf13/cobra"
"github.com/spf13/pflag"

"github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/flags"
"github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/tips"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/build"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

var (
Expand Down
5 changes: 3 additions & 2 deletions cmd/skaffold/app/cmd/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ import (
"context"
"io"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/pflag"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
)

// NewCmdDev describes the CLI command to run a pipeline in development mode.
Expand Down
7 changes: 4 additions & 3 deletions cmd/skaffold/app/cmd/find_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ import (
"io"
"strings"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/color"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/karrick/godirwalk"
"github.com/spf13/cobra"
"github.com/spf13/pflag"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/color"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
)

var (
Expand Down
9 changes: 5 additions & 4 deletions cmd/skaffold/app/cmd/fix.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ import (
"io"
"io/ioutil"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/color"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/validation"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
yaml "gopkg.in/yaml.v2"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/color"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/validation"
)

func NewCmdFix() *cobra.Command {
Expand Down
3 changes: 2 additions & 1 deletion cmd/skaffold/app/cmd/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ package cmd
import (
"testing"

"github.com/GoogleContainerTools/skaffold/testutil"
"github.com/spf13/cobra"

"github.com/GoogleContainerTools/skaffold/testutil"
)

func TestHasCmdAnnotation(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion cmd/skaffold/app/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import (
"context"
"io"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/initializer"
"github.com/spf13/cobra"
"github.com/spf13/pflag"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/initializer"
)

var (
Expand Down
5 changes: 3 additions & 2 deletions cmd/skaffold/app/cmd/render.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ import (
"io"
"io/ioutil"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
)

var (
Expand Down
7 changes: 4 additions & 3 deletions cmd/skaffold/app/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ import (
"context"
"io"

"github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/tips"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"

"github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/tips"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
)

// NewCmdRun describes the CLI command to run a pipeline.
Expand Down
3 changes: 2 additions & 1 deletion cmd/skaffold/app/cmd/runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ import (
"fmt"
"testing"

"github.com/blang/semver"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/config"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/update"
"github.com/GoogleContainerTools/skaffold/testutil"
"github.com/blang/semver"
)

func TestCreateNewRunner(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions cmd/skaffold/app/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ package cmd
import (
"io"

"github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/flags"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/version"
"github.com/spf13/cobra"
"github.com/spf13/pflag"

"github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/flags"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/version"
)

var versionFlag = flags.NewTemplateFlag("{{.Version}}\n", version.Info{})
Expand Down
3 changes: 2 additions & 1 deletion cmd/skaffold/app/flags/build_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import (
"io/ioutil"
"os"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/build"
"github.com/pkg/errors"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/build"
)

// BuildOutputFileFlag describes a flag which contains a BuildOutput.
Expand Down
3 changes: 2 additions & 1 deletion cmd/skaffold/man/man.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ import (
"io"
"os"

"github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/cmd"
"github.com/spf13/cobra"
"github.com/spf13/pflag"

"github.com/GoogleContainerTools/skaffold/cmd/skaffold/app/cmd"
)

func main() {
Expand Down
7 changes: 7 additions & 0 deletions hack/golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,10 @@ linters:
- unparam
- unused
- varcheck
- dogsled
- nakedret
- whitespace

linters-settings:
goimports:
local-prefixes: github.com/GoogleContainerTools/skaffold
3 changes: 2 additions & 1 deletion hack/schemas/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ import (
"regexp"
"strings"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema"
"github.com/pkg/errors"
blackfriday "gopkg.in/russross/blackfriday.v2"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions hack/versions/cmd/new/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ import (

hackschema "github.com/GoogleContainerTools/skaffold/hack/versions/pkg/schema"

"github.com/sirupsen/logrus"

"github.com/GoogleContainerTools/skaffold/hack/versions/pkg/version"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/color"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema"
"github.com/sirupsen/logrus"
)

// Before: prev -> current (latest)
Expand Down Expand Up @@ -95,7 +96,6 @@ func main() {

// Update the docs with the new version
sed("docs/config.toml", current, next)

}

func makeSchemaDir(new string) {
Expand Down
3 changes: 2 additions & 1 deletion hack/versions/cmd/schema_check/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ limitations under the License.
package main

import (
"github.com/GoogleContainerTools/skaffold/hack/versions/pkg/schema"
"github.com/sirupsen/logrus"

"github.com/GoogleContainerTools/skaffold/hack/versions/pkg/schema"
)

func main() {
Expand Down
1 change: 0 additions & 1 deletion hack/versions/cmd/update_comments/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,4 @@ func main() {
}); err != nil {
logrus.Fatalf("%s", err)
}

}
1 change: 0 additions & 1 deletion hack/versions/pkg/diff/godiff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,5 +290,4 @@ func TestCompareSchemas(t *testing.T) {
}
})
}

}
5 changes: 3 additions & 2 deletions hack/versions/pkg/schema/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ import (
"path"
"strings"

"github.com/pkg/errors"
"github.com/sirupsen/logrus"

"github.com/GoogleContainerTools/skaffold/hack/versions/pkg/diff"
"github.com/GoogleContainerTools/skaffold/hack/versions/pkg/version"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/color"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)

func RunSchemaCheckOnChangedFiles() error {
Expand Down
1 change: 0 additions & 1 deletion hack/versions/pkg/schema/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ func printAst(fset *token.FileSet, ast *ast.File) ([]byte, error) {

func addFirstCommentOnVersion(astA *ast.File, commentString string) {
ast.Inspect(astA, func(node ast.Node) bool {

if decl, ok := node.(*ast.GenDecl); ok &&
decl.Tok.String() == "const" &&
len(decl.Specs) == 1 {
Expand Down
3 changes: 0 additions & 3 deletions hack/versions/pkg/schema/comment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ var configWithReleasedComment = fmt.Sprintf(configFileTemplate, releasedComment+
var configWithUnreleasedComment = fmt.Sprintf(configFileTemplate, unreleasedComment+"\n")

func TestUpdateComments(t *testing.T) {

tcs := []struct {
name string
orig string
Expand Down Expand Up @@ -106,13 +105,11 @@ func TestUpdateComments(t *testing.T) {

for _, tc := range tcs {
testutil.Run(t, tc.name, func(t *testutil.T) {

dir := t.NewTempDir()
aFile := dir.Path("a.go")
t.CheckNoError(ioutil.WriteFile(aFile, []byte(tc.orig), 0666))
modified, err := updateVersionComment(aFile, tc.released)
t.CheckErrorAndDeepEqual(false, err, tc.expected, string(modified))
})
}

}
3 changes: 2 additions & 1 deletion hack/versions/pkg/schema/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ import (
"os/exec"
"strings"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/util"
"github.com/pkg/errors"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/util"
)

type gitClient interface {
Expand Down
3 changes: 2 additions & 1 deletion hack/versions/pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ import (

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/update"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
"github.com/sirupsen/logrus"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/schema/latest"
)

func GetLatestVersion() (string, bool) {
Expand Down
7 changes: 4 additions & 3 deletions integration/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"4d63.com/tz"
"github.com/docker/docker/api/types"
"github.com/sirupsen/logrus"
corev1 "k8s.io/api/core/v1"

"github.com/GoogleContainerTools/skaffold/integration/skaffold"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/docker"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/runner/runcontext"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/util"
"github.com/GoogleContainerTools/skaffold/pkg/webhook/kubernetes"
"github.com/GoogleContainerTools/skaffold/testutil"
"github.com/docker/docker/api/types"
"github.com/sirupsen/logrus"
corev1 "k8s.io/api/core/v1"
)

const imageName = "simple-build:"
Expand Down
Loading