Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
mxyng committed Feb 2, 2022
1 parent 8456e39 commit 674971e
Show file tree
Hide file tree
Showing 30 changed files with 66 additions and 51 deletions.
1 change: 1 addition & 0 deletions internal/access/access_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strings"

"github.com/gin-gonic/gin"

"github.com/infrahq/infra/internal"
"github.com/infrahq/infra/internal/registry/data"
"github.com/infrahq/infra/internal/registry/models"
Expand Down
1 change: 1 addition & 0 deletions internal/access/destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package access

import (
"github.com/gin-gonic/gin"

"github.com/infrahq/infra/internal/registry/data"
"github.com/infrahq/infra/internal/registry/models"
"github.com/infrahq/infra/uid"
Expand Down
1 change: 1 addition & 0 deletions internal/access/grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strings"

"github.com/gin-gonic/gin"

"github.com/infrahq/infra/internal/registry/data"
"github.com/infrahq/infra/internal/registry/models"
"github.com/infrahq/infra/uid"
Expand Down
1 change: 1 addition & 0 deletions internal/access/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package access

import (
"github.com/gin-gonic/gin"

"github.com/infrahq/infra/internal/registry/data"
"github.com/infrahq/infra/internal/registry/models"
"github.com/infrahq/infra/uid"
Expand Down
1 change: 1 addition & 0 deletions internal/access/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strings"

"github.com/gin-gonic/gin"

"github.com/infrahq/infra/internal"
"github.com/infrahq/infra/internal/registry/data"
"github.com/infrahq/infra/internal/registry/models"
Expand Down
1 change: 1 addition & 0 deletions internal/access/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"github.com/gin-gonic/gin"

"github.com/infrahq/infra/internal"
"github.com/infrahq/infra/internal/registry/authn"
"github.com/infrahq/infra/internal/registry/data"
Expand Down
1 change: 1 addition & 0 deletions internal/access/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

"github.com/gin-gonic/gin"

"github.com/infrahq/infra/internal/registry/data"
"github.com/infrahq/infra/internal/registry/models"
)
Expand Down
1 change: 1 addition & 0 deletions internal/access/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"strings"

"github.com/gin-gonic/gin"

"github.com/infrahq/infra/internal"
"github.com/infrahq/infra/internal/registry/authn"
"github.com/infrahq/infra/internal/registry/data"
Expand Down
6 changes: 4 additions & 2 deletions internal/api/model_empty.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package api

type EmptyRequest struct{}
type EmptyResponse struct{}
type (
EmptyRequest struct{}
EmptyResponse struct{}
)
5 changes: 3 additions & 2 deletions internal/cmd/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import (
"strings"

"github.com/goware/urlx"
"github.com/infrahq/infra/internal/api"
"github.com/infrahq/infra/internal/logging"
"k8s.io/client-go/tools/clientcmd"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"

"github.com/infrahq/infra/internal/api"
"github.com/infrahq/infra/internal/logging"
)

func clientConfig() clientcmd.ClientConfig {
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"strings"

survey "github.com/AlecAivazis/survey/v2"

"github.com/infrahq/infra/internal/api"
)

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

"github.com/go-playground/validator/v10"

"github.com/infrahq/infra/internal/api"
"github.com/infrahq/infra/uid"
)
Expand Down
3 changes: 1 addition & 2 deletions internal/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"golang.org/x/crypto/acme/autocert"
"gopkg.in/square/go-jose.v2"
"gopkg.in/square/go-jose.v2/jwt"
rbacv1 "k8s.io/api/rbac/v1"

"github.com/infrahq/infra/internal"
"github.com/infrahq/infra/internal/api"
Expand All @@ -32,8 +33,6 @@ import (
"github.com/infrahq/infra/internal/logging"
"github.com/infrahq/infra/internal/timer"
"github.com/infrahq/infra/uid"

rbacv1 "k8s.io/api/rbac/v1"
)

type Options struct {
Expand Down
5 changes: 3 additions & 2 deletions internal/registry/authn/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import (
"time"

"github.com/coreos/go-oidc/v3/oidc"
"github.com/infrahq/infra/internal"
"github.com/infrahq/infra/internal/registry/models"
"golang.org/x/oauth2"
"gopkg.in/square/go-jose.v2/jwt"

"github.com/infrahq/infra/internal"
"github.com/infrahq/infra/internal/registry/models"
)

// UserInfo captures the fields from a user-info response that we care about
Expand Down
3 changes: 2 additions & 1 deletion internal/registry/data/access_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import (
"strings"
"time"

"gorm.io/gorm"

"github.com/infrahq/infra/internal/generate"
"github.com/infrahq/infra/internal/registry/models"
"github.com/infrahq/infra/uid"
"gorm.io/gorm"
)

func CreateAccessKey(db *gorm.DB, authnKey *models.AccessKey) (body string, err error) {
Expand Down
4 changes: 2 additions & 2 deletions internal/registry/data/grant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package data
import (
"testing"

"github.com/infrahq/infra/internal/registry/models"
"github.com/stretchr/testify/require"
"gorm.io/gorm"

"github.com/infrahq/infra/internal/registry/models"
)

var tom = &models.User{Email: "tom@infrahq.com"}
Expand All @@ -25,7 +26,6 @@ func TestBasicGrant(t *testing.T) {
can(t, db, "steven", "read", "infra.groups.1")
can(t, db, "steven", "read", "infra.groups.2")
cant(t, db, "steven", "write", "infra.groups.1")

}

func grant(t *testing.T, db *gorm.DB, currentUser *models.User, identity, privilege, resource string) {
Expand Down
28 changes: 12 additions & 16 deletions internal/registry/data/group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ import (
func TestGroup(t *testing.T) {
db := setup(t)

var providerID = uid.New()
providerID := uid.New()

var (
everyone = models.Group{Name: "Everyone", ProviderID: providerID}
)
everyone := models.Group{Name: "Everyone", ProviderID: providerID}

err := db.Create(&everyone).Error
require.NoError(t, err)
Expand All @@ -32,11 +30,9 @@ func TestGroup(t *testing.T) {
func TestCreateGroup(t *testing.T) {
db := setup(t)

var providerID = uid.New()
providerID := uid.New()

var (
everyone = models.Group{Name: "Everyone", ProviderID: providerID}
)
everyone := models.Group{Name: "Everyone", ProviderID: providerID}

err := CreateGroup(db, &everyone)
group := everyone
Expand All @@ -53,7 +49,7 @@ func createGroups(t *testing.T, db *gorm.DB, groups ...models.Group) {
}

func TestCreateGroupDuplicate(t *testing.T) {
var providerID = uid.New()
providerID := uid.New()

var (
everyone = models.Group{Name: "Everyone", ProviderID: providerID}
Expand All @@ -71,7 +67,7 @@ func TestCreateGroupDuplicate(t *testing.T) {
func TestGetGroup(t *testing.T) {
db := setup(t)

var providerID = uid.New()
providerID := uid.New()

var (
everyone = models.Group{Name: "Everyone", ProviderID: providerID}
Expand All @@ -89,7 +85,7 @@ func TestGetGroup(t *testing.T) {
func TestListGroups(t *testing.T) {
db := setup(t)

var providerID = uid.New()
providerID := uid.New()

var (
everyone = models.Group{Name: "Everyone", ProviderID: providerID}
Expand All @@ -111,7 +107,7 @@ func TestListGroups(t *testing.T) {
func TestGroupBindUsers(t *testing.T) {
db := setup(t)

var providerID = uid.New()
providerID := uid.New()

var (
everyone = models.Group{Name: "Everyone", ProviderID: providerID}
Expand Down Expand Up @@ -148,7 +144,7 @@ func TestGroupBindUsers(t *testing.T) {
func TestGroupBindMoreUsers(t *testing.T) {
db := setup(t)

var providerID = uid.New()
providerID := uid.New()

var (
everyone = models.Group{Name: "Everyone", ProviderID: providerID}
Expand Down Expand Up @@ -188,7 +184,7 @@ func TestGroupBindMoreUsers(t *testing.T) {
func TestGroupBindLessUsers(t *testing.T) {
db := setup(t)

var providerID = uid.New()
providerID := uid.New()

var (
everyone = models.Group{Name: "Everyone", ProviderID: providerID}
Expand Down Expand Up @@ -228,7 +224,7 @@ func TestGroupBindLessUsers(t *testing.T) {
func TestDeleteGroup(t *testing.T) {
db := setup(t)

var providerID = uid.New()
providerID := uid.New()

var (
everyone = models.Group{Name: "Everyone", ProviderID: providerID}
Expand Down Expand Up @@ -259,7 +255,7 @@ func TestDeleteGroup(t *testing.T) {
func TestRecreateGroupSameName(t *testing.T) {
db := setup(t)

var providerID = uid.New()
providerID := uid.New()

var (
everyone = models.Group{Name: "Everyone", ProviderID: providerID}
Expand Down
3 changes: 2 additions & 1 deletion internal/registry/data/machine.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package data

import (
"gorm.io/gorm"

"github.com/infrahq/infra/internal/registry/models"
"github.com/infrahq/infra/uid"
"gorm.io/gorm"
)

func CreateMachine(db *gorm.DB, machine *models.Machine) error {
Expand Down
3 changes: 2 additions & 1 deletion internal/registry/data/machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package data
import (
"testing"

"github.com/stretchr/testify/require"

"github.com/infrahq/infra/internal"
"github.com/infrahq/infra/internal/registry/models"
"github.com/stretchr/testify/require"
)

func TestCreateMachineExistingName(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions internal/registry/data/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func TestProvider(t *testing.T) {
db := setup(t)

var providerDevelop = models.Provider{Name: "okta-development", URL: "dev.okta.com"}
providerDevelop := models.Provider{Name: "okta-development", URL: "dev.okta.com"}

err := db.Create(&providerDevelop).Error
require.NoError(t, err)
Expand All @@ -27,7 +27,7 @@ func TestProvider(t *testing.T) {
func TestCreateProviderOkta(t *testing.T) {
db := setup(t)

var providerDevelop = models.Provider{Name: "okta-development", URL: "dev.okta.com"}
providerDevelop := models.Provider{Name: "okta-development", URL: "dev.okta.com"}

p := providerDevelop
err := CreateProvider(db, &p)
Expand Down
3 changes: 2 additions & 1 deletion internal/registry/data/selectors.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package data

import (
"github.com/infrahq/infra/uid"
"gorm.io/gorm"

"github.com/infrahq/infra/uid"
)

type SelectorFunc func(db *gorm.DB) *gorm.DB
Expand Down
5 changes: 3 additions & 2 deletions internal/registry/data/token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import (
"testing"
"time"

"github.com/infrahq/infra/internal/generate"
"github.com/infrahq/infra/internal/registry/models"
"github.com/stretchr/testify/require"
"gorm.io/gorm"

"github.com/infrahq/infra/internal/generate"
"github.com/infrahq/infra/internal/registry/models"
)

func createAccessKey(t *testing.T, db *gorm.DB, sessionDuration time.Duration) (string, *models.AccessKey) {
Expand Down
16 changes: 7 additions & 9 deletions internal/registry/data/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ import (
func TestUser(t *testing.T) {
db := setup(t)

var providerID = uid.New()
providerID := uid.New()

var (
bond = models.User{Email: "jbond@infrahq.com", ProviderID: providerID}
)
bond := models.User{Email: "jbond@infrahq.com", ProviderID: providerID}

err := db.Create(&bond).Error
require.NoError(t, err)
Expand All @@ -39,7 +37,7 @@ func createUsers(t *testing.T, db *gorm.DB, users ...models.User) {
func TestCreateDuplicateUser(t *testing.T) {
db := setup(t)

var providerID = uid.New()
providerID := uid.New()

var (
bond = models.User{Email: "jbond@infrahq.com", ProviderID: providerID}
Expand All @@ -58,7 +56,7 @@ func TestCreateDuplicateUser(t *testing.T) {
func TestGetUser(t *testing.T) {
db := setup(t)

var providerID = uid.New()
providerID := uid.New()

var (
bond = models.User{Email: "jbond@infrahq.com", ProviderID: providerID}
Expand All @@ -76,7 +74,7 @@ func TestGetUser(t *testing.T) {
func TestListUsers(t *testing.T) {
db := setup(t)

var providerID = uid.New()
providerID := uid.New()

var (
bond = models.User{Email: "jbond@infrahq.com", ProviderID: providerID}
Expand All @@ -98,7 +96,7 @@ func TestListUsers(t *testing.T) {
func TestDeleteUser(t *testing.T) {
db := setup(t)

var providerID = uid.New()
providerID := uid.New()

var (
bond = models.User{Email: "jbond@infrahq.com", ProviderID: providerID}
Expand Down Expand Up @@ -129,7 +127,7 @@ func TestDeleteUser(t *testing.T) {
func TestRecreateUserSameEmail(t *testing.T) {
db := setup(t)

var providerID = uid.New()
providerID := uid.New()

var (
bond = models.User{Email: "jbond@infrahq.com", ProviderID: providerID}
Expand Down
Loading

0 comments on commit 674971e

Please sign in to comment.