Skip to content

Commit

Permalink
enforece holy import trinity using goimports
Browse files Browse the repository at this point in the history
This PR changes our gofmt check to
goimports -local github.com/sapcc/kubernikus.

This caused the tests to fail if imports are not ordered in the following way:
```
stdlib
[empty line]
external deps
[empty line]
kubernikus internal deps
````

I purposly excluded the generated files from this check to avoid confusion when we regenerate stuff.
  • Loading branch information
databus23 authored and BugRoger committed Dec 11, 2017
1 parent 34c02de commit ca5afde
Show file tree
Hide file tree
Showing 48 changed files with 107 additions and 64 deletions.
3 changes: 2 additions & 1 deletion Dockerfile.kubernikus-binaries
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM golang:1.9.2-alpine3.6 as builder
WORKDIR /go/src/github.com/sapcc/kubernikus/
RUN apk add --no-cache make
RUN apk add --no-cache make git
RUN go get golang.org/x/tools/cmd/goimports
COPY . .
ARG VERSION
RUN make all
Expand Down
3 changes: 2 additions & 1 deletion pkg/api/auth/authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import (
"github.com/go-openapi/loads"
runtime "github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware/denco"
"github.com/sapcc/kubernikus/pkg/api/models"
flag "github.com/spf13/pflag"

"github.com/sapcc/kubernikus/pkg/api/models"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion pkg/api/auth/authorizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"net/http/httptest"
"testing"

"github.com/stretchr/testify/assert"

"github.com/sapcc/kubernikus/pkg/api/models"
"github.com/sapcc/kubernikus/pkg/api/spec"
"github.com/stretchr/testify/assert"
)

func TestAuthorizer(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions pkg/api/handlers/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net/http"

"github.com/go-openapi/runtime"

"github.com/sapcc/kubernikus/pkg/api/models"
)

Expand Down
3 changes: 2 additions & 1 deletion pkg/api/handlers/get_cluster_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package handlers
import (
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/strfmt"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/sapcc/kubernikus/pkg/api"
"github.com/sapcc/kubernikus/pkg/api/models"
"github.com/sapcc/kubernikus/pkg/api/rest/operations"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func NewGetClusterEvents(rt *api.Runtime) operations.GetClusterEventsHandler {
Expand Down
1 change: 1 addition & 0 deletions pkg/api/handlers/get_cluster_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"sync"

"github.com/go-openapi/runtime/middleware"

"github.com/sapcc/kubernikus/pkg/api"
"github.com/sapcc/kubernikus/pkg/api/models"
"github.com/sapcc/kubernikus/pkg/api/rest/operations"
Expand Down
3 changes: 2 additions & 1 deletion pkg/api/handlers/get_cluster_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (
"net/http/httptest"
"testing"

"github.com/sapcc/kubernikus/pkg/api/models"
"github.com/stretchr/testify/assert"

"github.com/sapcc/kubernikus/pkg/api/models"
)

func TestKubernikusctlDownloadLinks(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions pkg/api/handlers/get_openstack_metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package handlers
import (
"github.com/go-openapi/runtime/middleware"
"github.com/gophercloud/gophercloud/openstack/identity/v3/tokens"

"github.com/sapcc/kubernikus/pkg/api"
"github.com/sapcc/kubernikus/pkg/api/models"
"github.com/sapcc/kubernikus/pkg/api/rest/operations"
Expand Down
1 change: 1 addition & 0 deletions pkg/api/handlers/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package handlers

import (
"github.com/go-openapi/runtime/middleware"

"github.com/sapcc/kubernikus/pkg/api"
"github.com/sapcc/kubernikus/pkg/api/models"
"github.com/sapcc/kubernikus/pkg/api/rest/operations"
Expand Down
1 change: 1 addition & 0 deletions pkg/api/handlers/list_api_versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package handlers

import (
"github.com/go-openapi/runtime/middleware"

"github.com/sapcc/kubernikus/pkg/api"
"github.com/sapcc/kubernikus/pkg/api/models"
"github.com/sapcc/kubernikus/pkg/api/rest/operations"
Expand Down
3 changes: 2 additions & 1 deletion pkg/api/handlers/list_clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package handlers

import (
"github.com/go-openapi/runtime/middleware"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/sapcc/kubernikus/pkg/api"
"github.com/sapcc/kubernikus/pkg/api/models"
"github.com/sapcc/kubernikus/pkg/api/rest/operations"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func NewListClusters(rt *api.Runtime) operations.ListClustersHandler {
Expand Down
5 changes: 3 additions & 2 deletions pkg/api/handlers/show_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package handlers

import (
"github.com/go-openapi/runtime/middleware"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/sapcc/kubernikus/pkg/api"
"github.com/sapcc/kubernikus/pkg/api/models"
"github.com/sapcc/kubernikus/pkg/api/rest/operations"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func NewShowCluster(rt *api.Runtime) operations.ShowClusterHandler {
Expand Down
7 changes: 4 additions & 3 deletions pkg/api/handlers/terminate_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package handlers

import (
"github.com/go-openapi/runtime/middleware"

apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/sapcc/kubernikus/pkg/api"
"github.com/sapcc/kubernikus/pkg/api/models"
"github.com/sapcc/kubernikus/pkg/api/rest/operations"
"github.com/sapcc/kubernikus/pkg/apis/kubernikus/v1"

apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func NewTerminateCluster(rt *api.Runtime) operations.TerminateClusterHandler {
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/handlers/update_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package handlers

import (
"github.com/go-openapi/runtime/middleware"
apierrors "k8s.io/apimachinery/pkg/api/errors"

"github.com/sapcc/kubernikus/pkg/api"
"github.com/sapcc/kubernikus/pkg/api/models"
"github.com/sapcc/kubernikus/pkg/api/rest/operations"
"github.com/sapcc/kubernikus/pkg/apis/kubernikus/v1"

apierrors "k8s.io/apimachinery/pkg/api/errors"
)

func NewUpdateCluster(rt *api.Runtime) operations.UpdateClusterHandler {
Expand Down
11 changes: 6 additions & 5 deletions pkg/api/handlers/util.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package handlers

import (
"fmt"
"strings"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"

"github.com/sapcc/kubernikus/pkg/api/models"
"github.com/sapcc/kubernikus/pkg/api/spec"
"github.com/sapcc/kubernikus/pkg/apis/kubernikus/v1"
kubernikusv1 "github.com/sapcc/kubernikus/pkg/generated/clientset/typed/kubernikus/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"

"fmt"
"strings"
)

var (
Expand Down
1 change: 1 addition & 0 deletions pkg/api/models/kluster_print.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

"github.com/pkg/errors"

"github.com/sapcc/kubernikus/pkg/cmd/printers"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/api/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package api

import (
"github.com/go-kit/kit/log"
"k8s.io/client-go/kubernetes"

"github.com/sapcc/kubernikus/pkg/generated/clientset"
"k8s.io/client-go/kubernetes"
)

type Runtime struct {
Expand Down
1 change: 1 addition & 0 deletions pkg/client/openstack/scoped/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/gophercloud/gophercloud/openstack/networking/v2/ports"
"github.com/gophercloud/gophercloud/openstack/networking/v2/subnets"
"github.com/gophercloud/gophercloud/pagination"

"github.com/sapcc/kubernikus/pkg/api/models"
"github.com/sapcc/kubernikus/pkg/client/openstack/util"
utillog "github.com/sapcc/kubernikus/pkg/util/log"
Expand Down
3 changes: 2 additions & 1 deletion pkg/cmd/kubernikus/certificates.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package kubernikus

import (
"github.com/sapcc/kubernikus/pkg/cmd/kubernikus/certificates"
"github.com/spf13/cobra"

"github.com/sapcc/kubernikus/pkg/cmd/kubernikus/certificates"
)

func NewCertificatesCommand() *cobra.Command {
Expand Down
8 changes: 4 additions & 4 deletions pkg/cmd/kubernikus/certificates/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package certificates
import (
"errors"

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

"github.com/sapcc/kubernikus/pkg/api/models"
"github.com/sapcc/kubernikus/pkg/apis/kubernikus"
"github.com/sapcc/kubernikus/pkg/util"

"github.com/sapcc/kubernikus/pkg/cmd"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/sapcc/kubernikus/pkg/util"
)

func NewFilesCommand() *cobra.Command {
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/kubernikus/certificates/plain.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package certificates
import (
"errors"

"github.com/spf13/cobra"

"github.com/sapcc/kubernikus/pkg/api/models"
"github.com/sapcc/kubernikus/pkg/apis/kubernikus"
"github.com/sapcc/kubernikus/pkg/util"

"github.com/sapcc/kubernikus/pkg/cmd"
"github.com/spf13/cobra"
"github.com/sapcc/kubernikus/pkg/util"
)

func NewPlainCommand() *cobra.Command {
Expand Down
7 changes: 4 additions & 3 deletions pkg/cmd/kubernikus/certificates/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import (
"os"

"github.com/ghodss/yaml"
"github.com/sapcc/kubernikus/pkg/client/kubernetes"
"github.com/sapcc/kubernikus/pkg/cmd"
"github.com/sapcc/kubernikus/pkg/util"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"k8s.io/apimachinery/pkg/apis/meta/v1"
certutil "k8s.io/client-go/util/cert"

"github.com/sapcc/kubernikus/pkg/client/kubernetes"
"github.com/sapcc/kubernikus/pkg/cmd"
"github.com/sapcc/kubernikus/pkg/util"
)

func NewSignCommand() *cobra.Command {
Expand Down
5 changes: 3 additions & 2 deletions pkg/cmd/kubernikus/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import (
"os"
"strings"

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

"github.com/sapcc/kubernikus/pkg/api/models"
"github.com/sapcc/kubernikus/pkg/apis/kubernikus"
"github.com/sapcc/kubernikus/pkg/cmd"
"github.com/sapcc/kubernikus/pkg/util"
"github.com/sapcc/kubernikus/pkg/util/helm"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

func NewHelmCommand() *cobra.Command {
Expand Down
3 changes: 2 additions & 1 deletion pkg/cmd/kubernikus/seed.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package kubernikus

import (
"github.com/sapcc/kubernikus/pkg/cmd/kubernikus/seed"
"github.com/spf13/cobra"

"github.com/sapcc/kubernikus/pkg/cmd/kubernikus/seed"
)

func NewSeedCommand() *cobra.Command {
Expand Down
5 changes: 3 additions & 2 deletions pkg/cmd/kubernikus/seed/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package seed
import (
"errors"

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

"github.com/sapcc/kubernikus/pkg/client/kubernetes"
"github.com/sapcc/kubernikus/pkg/cmd"
"github.com/sapcc/kubernikus/pkg/controller/ground/bootstrap/dns"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

func NewKubeDNSCommand() *cobra.Command {
Expand Down
3 changes: 2 additions & 1 deletion pkg/cmd/kubernikusctl/auth.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package kubernikusctl

import (
"github.com/sapcc/kubernikus/pkg/cmd/kubernikusctl/auth"
"github.com/spf13/cobra"

"github.com/sapcc/kubernikus/pkg/cmd/kubernikusctl/auth"
)

func NewAuthCommand() *cobra.Command {
Expand Down
3 changes: 2 additions & 1 deletion pkg/cmd/kubernikusctl/auth/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import (
"github.com/howeyc/gopass"
"github.com/imdario/mergo"
"github.com/pkg/errors"
"github.com/sapcc/kubernikus/pkg/cmd/kubernikusctl/common"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"k8s.io/client-go/tools/clientcmd"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"

"github.com/sapcc/kubernikus/pkg/cmd/kubernikusctl/common"
)

type InitOptions struct {
Expand Down
5 changes: 3 additions & 2 deletions pkg/cmd/kubernikusctl/auth/refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ import (
"github.com/howeyc/gopass"
"github.com/imdario/mergo"
"github.com/pkg/errors"
"github.com/sapcc/kubernikus/pkg/cmd/kubernikusctl/common"
"github.com/sapcc/kubernikus/pkg/util"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"k8s.io/client-go/tools/clientcmd"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"

"github.com/sapcc/kubernikus/pkg/cmd/kubernikusctl/common"
"github.com/sapcc/kubernikus/pkg/util"
)

type RefreshOptions struct {
Expand Down
3 changes: 2 additions & 1 deletion pkg/cmd/kubernikusctl/create.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package kubernikusctl

import (
"github.com/spf13/cobra"

"github.com/sapcc/kubernikus/pkg/cmd/kubernikusctl/common"
"github.com/sapcc/kubernikus/pkg/cmd/kubernikusctl/create"
"github.com/spf13/cobra"
)

func createRun(c *cobra.Command, args []string) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/cmd/kubernikusctl/get.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package kubernikusctl

import (
"github.com/spf13/cobra"

"github.com/sapcc/kubernikus/pkg/cmd/kubernikusctl/common"
"github.com/sapcc/kubernikus/pkg/cmd/kubernikusctl/get"
"github.com/spf13/cobra"
)

func getRun(c *cobra.Command, args []string) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/cmd/kubernikusctl/get/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package get
import (
"github.com/golang/glog"
"github.com/pkg/errors"
"github.com/spf13/cobra"

"github.com/sapcc/kubernikus/pkg/cmd"
"github.com/sapcc/kubernikus/pkg/cmd/printers"
"github.com/spf13/cobra"
)

func (o *GetOptions) NewClusterCommand() *cobra.Command {
Expand Down
Loading

0 comments on commit ca5afde

Please sign in to comment.