Skip to content

Commit

Permalink
Add configuration file for golangci-lint. Enable goimports.
Browse files Browse the repository at this point in the history
Signed-off-by: Guillaume Rose <guillaume.rose@docker.com>
  • Loading branch information
guillaumerose authored and praveenkumar committed Mar 30, 2020
1 parent 0a318dc commit 87f1453
Show file tree
Hide file tree
Showing 20 changed files with 41 additions and 34 deletions.
8 changes: 8 additions & 0 deletions .golangci.yml
@@ -0,0 +1,8 @@
run:
build-tags:
- build

linters:
enable:
- goimports

9 changes: 4 additions & 5 deletions Makefile
Expand Up @@ -148,15 +148,14 @@ $(GOPATH)/bin/golangci-lint:
GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.17.1

# Run golangci-lint against code
GOLANGCI_FLAGS=--build-tags build
.PHONY: lint cross-lint
lint: $(GOPATH)/bin/golangci-lint
$(GOPATH)/bin/golangci-lint $(GOLANGCI_FLAGS) run
$(GOPATH)/bin/golangci-lint run

cross-lint: $(GOPATH)/bin/golangci-lint
GOOS=darwin $(GOPATH)/bin/golangci-lint $(GOLANGCI_FLAGS) run
GOOS=linux $(GOPATH)/bin/golangci-lint $(GOLANGCI_FLAGS) run
GOOS=windows $(GOPATH)/bin/golangci-lint $(GOLANGCI_FLAGS) run
GOOS=darwin $(GOPATH)/bin/golangci-lint run
GOOS=linux $(GOPATH)/bin/golangci-lint run
GOOS=windows $(GOPATH)/bin/golangci-lint run

$(GOPATH)/bin/gosec:
GO111MODULE=on go get github.com/securego/gosec/cmd/gosec@2.0.0
Expand Down
3 changes: 2 additions & 1 deletion cmd/crc/cmd/config/get.go
@@ -1,11 +1,12 @@
package config

import (
"os"

"github.com/code-ready/crc/pkg/crc/config"
"github.com/code-ready/crc/pkg/crc/errors"
"github.com/code-ready/crc/pkg/crc/output"
"github.com/spf13/cobra"
"os"
)

func init() {
Expand Down
7 changes: 4 additions & 3 deletions cmd/crc/cmd/config/view.go
Expand Up @@ -3,13 +3,14 @@ package config
import (
"bytes"
"fmt"
"github.com/code-ready/crc/pkg/crc/config"
"github.com/code-ready/crc/pkg/crc/logging"
"github.com/spf13/cobra"
"io"
"os"
"sort"
"text/template"

"github.com/code-ready/crc/pkg/crc/config"
"github.com/code-ready/crc/pkg/crc/logging"
"github.com/spf13/cobra"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion cmd/crc/cmd/daemon.go
@@ -1,11 +1,12 @@
package cmd

import (
"os"

"github.com/code-ready/crc/pkg/crc/api"
"github.com/code-ready/crc/pkg/crc/constants"
"github.com/code-ready/crc/pkg/crc/logging"
"github.com/spf13/cobra"
"os"
)

func init() {
Expand Down
4 changes: 2 additions & 2 deletions cmd/crc/cmd/status.go
Expand Up @@ -2,15 +2,15 @@ package cmd

import (
"fmt"
"github.com/docker/go-units"
"github.com/spf13/cobra"
"os"
"path/filepath"
"text/template"

"github.com/code-ready/crc/pkg/crc/constants"
"github.com/code-ready/crc/pkg/crc/errors"
"github.com/code-ready/crc/pkg/crc/machine"
"github.com/docker/go-units"
"github.com/spf13/cobra"
)

func init() {
Expand Down
3 changes: 2 additions & 1 deletion pkg/crc/machine/hyperkit/driver_darwin.go
@@ -1,10 +1,11 @@
package hyperkit

import (
"path/filepath"

"github.com/code-ready/crc/pkg/crc/constants"
"github.com/code-ready/crc/pkg/crc/machine/config"
"github.com/code-ready/machine/libmachine/drivers"
"path/filepath"
)

type hyperkitDriver struct {
Expand Down
3 changes: 1 addition & 2 deletions pkg/crc/machine/libvirt/driver_linux.go
@@ -1,11 +1,10 @@
package libvirt

import (
"github.com/code-ready/crc/pkg/crc/constants"
"path/filepath"

"github.com/code-ready/crc/pkg/crc/constants"
"github.com/code-ready/crc/pkg/crc/machine/config"

"github.com/code-ready/machine/libmachine/drivers"
)

Expand Down
5 changes: 2 additions & 3 deletions pkg/crc/network/utils.go
Expand Up @@ -2,15 +2,14 @@ package network

import (
"fmt"
"github.com/code-ready/crc/pkg/crc/logging"
"net"
"net/url"
"runtime"

"github.com/code-ready/crc/pkg/crc/errors"
"github.com/code-ready/crc/pkg/crc/ssh"

"github.com/code-ready/crc/pkg/crc/logging"
"github.com/code-ready/crc/pkg/crc/machine/bundle"
"github.com/code-ready/crc/pkg/crc/ssh"
)

func executeCommandOrExit(sshRunner *ssh.SSHRunner, command string, errorMessage string) string {
Expand Down
3 changes: 2 additions & 1 deletion pkg/crc/oc/clusteroperator.go
Expand Up @@ -3,8 +3,9 @@ package oc
import (
"encoding/json"
"fmt"
"github.com/code-ready/crc/pkg/crc/logging"
"time"

"github.com/code-ready/crc/pkg/crc/logging"
)

var ignoreClusterOperators = []string{"monitoring", "machine-config", "marketplace", "insights"}
Expand Down
2 changes: 1 addition & 1 deletion pkg/crc/preflight/preflight_checks_darwin.go
Expand Up @@ -2,7 +2,6 @@ package preflight

import (
"fmt"
"golang.org/x/sys/unix"
neturl "net/url"
"os"
"os/user"
Expand All @@ -16,6 +15,7 @@ import (
"github.com/code-ready/crc/pkg/crc/machine/hyperkit"
dl "github.com/code-ready/crc/pkg/download"
crcos "github.com/code-ready/crc/pkg/os"
"golang.org/x/sys/unix"
)

const (
Expand Down
6 changes: 2 additions & 4 deletions pkg/crc/preflight/preflight_checks_linux.go
Expand Up @@ -3,7 +3,6 @@ package preflight
import (
"bytes"
"fmt"
"golang.org/x/sys/unix"
"io/ioutil"
"os"
"os/exec"
Expand All @@ -13,15 +12,14 @@ import (
"strings"
"text/template"

"github.com/Masterminds/semver"
"github.com/code-ready/crc/pkg/crc/constants"
"github.com/code-ready/crc/pkg/crc/logging"
"github.com/code-ready/crc/pkg/crc/machine/libvirt"
"github.com/code-ready/crc/pkg/crc/systemd"
"github.com/code-ready/crc/pkg/download"

"github.com/Masterminds/semver"

crcos "github.com/code-ready/crc/pkg/os"
"golang.org/x/sys/unix"
)

const (
Expand Down
2 changes: 0 additions & 2 deletions pkg/crc/preflight/preflight_linux.go
@@ -1,7 +1,5 @@
package preflight

import ()

var libvirtPreflightChecks = [...]PreflightCheck{
{
configKeySuffix: "check-virt-enabled",
Expand Down
2 changes: 0 additions & 2 deletions pkg/crc/preflight/preflight_windows.go
@@ -1,7 +1,5 @@
package preflight

import ()

var hypervPreflightChecks = [...]PreflightCheck{
{
configKeySuffix: "check-administrator-user",
Expand Down
2 changes: 1 addition & 1 deletion pkg/crc/services/dns/dns.go
Expand Up @@ -2,9 +2,9 @@ package dns

import (
"fmt"
"github.com/code-ready/crc/pkg/crc/errors"
"time"

"github.com/code-ready/crc/pkg/crc/errors"
"github.com/code-ready/crc/pkg/crc/network"
"github.com/code-ready/crc/pkg/crc/services"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/crc/services/dns/dns_darwin.go
Expand Up @@ -3,12 +3,12 @@ package dns
import (
"bytes"
"fmt"
"github.com/code-ready/crc/pkg/crc/errors"
"path/filepath"
"strings"
"text/template"
"time"

"github.com/code-ready/crc/pkg/crc/errors"
"github.com/code-ready/crc/pkg/crc/logging"
"github.com/code-ready/crc/pkg/crc/network"
"github.com/code-ready/crc/pkg/crc/services"
Expand Down
2 changes: 1 addition & 1 deletion pkg/crc/validation/validation.go
Expand Up @@ -3,14 +3,14 @@ package validation
import (
"encoding/json"
"fmt"
"github.com/code-ready/crc/pkg/crc/version"
"net"
"os"
"path/filepath"
"strings"

"github.com/code-ready/crc/pkg/crc/constants"
"github.com/code-ready/crc/pkg/crc/errors"
"github.com/code-ready/crc/pkg/crc/version"
)

// ValidateCPUs checks if provided cpus count is valid
Expand Down
3 changes: 2 additions & 1 deletion pkg/crc/version/version.go
Expand Up @@ -19,10 +19,11 @@ package version
import (
"encoding/json"
"fmt"
"github.com/Masterminds/semver"
"io/ioutil"
"net/http"
"time"

"github.com/Masterminds/semver"
)

// The following variables are private fields and should be set when compiling with ldflags, for example --ldflags="-X github.com/code-ready/crc/pkg/version.crcVersion=vX.Y.Z
Expand Down
3 changes: 2 additions & 1 deletion pkg/os/exec.go
Expand Up @@ -2,10 +2,11 @@ package os

import (
"bytes"
"github.com/code-ready/crc/pkg/crc/logging"
"os"
"os/exec"
"strings"

"github.com/code-ready/crc/pkg/crc/logging"
)

func runCmd(command string, args []string, env map[string]string) (string, string, error) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/os/windows/win32/shell32_windows.go
@@ -1,9 +1,10 @@
package win32

import (
"syscall"

"github.com/code-ready/crc/pkg/crc/logging"
"golang.org/x/sys/windows"
"syscall"
)

const (
Expand Down

0 comments on commit 87f1453

Please sign in to comment.