Skip to content

Commit

Permalink
chore: establish and enforce a convention for import paths (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiught authored Jan 5, 2024
2 parents d6555ee + 3edbd46 commit 655a166
Show file tree
Hide file tree
Showing 48 changed files with 121 additions and 80 deletions.
6 changes: 3 additions & 3 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ linters:
- gochecknoinits
- forbidigo
- gochecknoglobals
- goimports
# deprecated
- exhaustivestruct
- interfacer
Expand All @@ -24,6 +23,7 @@ linters:
- golint
- nosnakecase
- testpackage
- gci
linters-settings:
depguard:
rules:
Expand Down Expand Up @@ -70,5 +70,5 @@ linters-settings:
lines: 120
statements: 80

skip-dirs:
- mocks
goimports:
local-prefixes: "github.com/openfga/cli"
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ $(GO_BIN)/gofumpt:
@echo "==> Installing gofumpt within "${GO_BIN}""
@go install -v mvdan.cc/gofumpt@latest

$(GO_BIN)/gci:
@echo "==> Installing gci within "${GO_BIN}""
@go install -v github.com/daixiang0/gci@latest

$(BUILD_DIR)/$(BINARY_NAME):
@echo "==> Building binary within ${BUILD_DIR}/${BINARY_NAME}"
go build -v -o ${BUILD_DIR}/${BINARY_NAME} main.go
Expand Down Expand Up @@ -62,4 +58,3 @@ audit: $(GO_BIN)/govulncheck
format: $(GO_BIN)/gofumpt $(GO_BIN)/gci
@echo "==> Formatting project files"
gofumpt -w .
gci write -s standard -s default .
7 changes: 4 additions & 3 deletions cmd/model/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ import (
"fmt"
"os"

openfga "github.com/openfga/go-sdk"
"github.com/openfga/go-sdk/client"
"github.com/spf13/cobra"

"github.com/openfga/cli/internal/authorizationmodel"
"github.com/openfga/cli/internal/clierrors"
"github.com/openfga/cli/internal/cmdutils"
"github.com/openfga/cli/internal/fga"
"github.com/openfga/cli/internal/output"
openfga "github.com/openfga/go-sdk"
"github.com/openfga/go-sdk/client"
"github.com/spf13/cobra"
)

func getModel(clientConfig fga.ClientConfig, fgaClient client.SdkClient) (*openfga.ReadAuthorizationModelResponse,
Expand Down
5 changes: 3 additions & 2 deletions cmd/model/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import (
"testing"

"github.com/golang/mock/gomock"
"github.com/openfga/cli/internal/fga"
"github.com/openfga/cli/internal/mocks"
openfga "github.com/openfga/go-sdk"
"github.com/openfga/go-sdk/client"

"github.com/openfga/cli/internal/fga"
mock_client "github.com/openfga/cli/internal/mocks"
)

var errMockGet = errors.New("mock error")
Expand Down
7 changes: 4 additions & 3 deletions cmd/model/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ import (
"fmt"
"os"

"github.com/openfga/cli/internal/authorizationmodel"
"github.com/openfga/cli/internal/cmdutils"
"github.com/openfga/cli/internal/output"
openfga "github.com/openfga/go-sdk"
"github.com/openfga/go-sdk/client"
"github.com/spf13/cobra"

"github.com/openfga/cli/internal/authorizationmodel"
"github.com/openfga/cli/internal/cmdutils"
"github.com/openfga/cli/internal/output"
)

// MaxModelsPagesLength Limit the models so that we are not paginating indefinitely.
Expand Down
3 changes: 2 additions & 1 deletion cmd/model/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (
"testing"

"github.com/golang/mock/gomock"
mockclient "github.com/openfga/cli/internal/mocks"
openfga "github.com/openfga/go-sdk"
"github.com/openfga/go-sdk/client"

mockclient "github.com/openfga/cli/internal/mocks"
)

var errMockList = errors.New("mock error")
Expand Down
5 changes: 3 additions & 2 deletions cmd/model/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ import (
"os"
"path"

"github.com/spf13/cobra"
"gopkg.in/yaml.v3"

"github.com/openfga/cli/internal/cmdutils"
"github.com/openfga/cli/internal/output"
"github.com/openfga/cli/internal/storetest"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"
)

// testCmd represents the test command.
Expand Down
5 changes: 3 additions & 2 deletions cmd/model/transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ package model
import (
"fmt"

"github.com/openfga/cli/internal/authorizationmodel"
"github.com/openfga/cli/internal/output"
openfga "github.com/openfga/go-sdk"
"github.com/spf13/cobra"

"github.com/openfga/cli/internal/authorizationmodel"
"github.com/openfga/cli/internal/output"
)

// transformCmd represents the transform command.
Expand Down
5 changes: 3 additions & 2 deletions cmd/model/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ import (

"github.com/oklog/ulid/v2"
pb "github.com/openfga/api/proto/openfga/v1"
"github.com/openfga/cli/internal/authorizationmodel"
"github.com/openfga/cli/internal/output"
openfga "github.com/openfga/go-sdk"
"github.com/openfga/openfga/pkg/typesystem"
"github.com/spf13/cobra"
"google.golang.org/protobuf/encoding/protojson"

"github.com/openfga/cli/internal/authorizationmodel"
"github.com/openfga/cli/internal/output"
)

type validationResult struct {
Expand Down
3 changes: 2 additions & 1 deletion cmd/model/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"reflect"
"testing"

"github.com/openfga/cli/internal/authorizationmodel"
openfga "github.com/openfga/go-sdk"

"github.com/openfga/cli/internal/authorizationmodel"
)

func TestValidateCmdWithArgs(t *testing.T) {
Expand Down
7 changes: 4 additions & 3 deletions cmd/model/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ import (
"fmt"
"os"

"github.com/openfga/cli/internal/authorizationmodel"
"github.com/openfga/cli/internal/cmdutils"
"github.com/openfga/cli/internal/output"
openfga "github.com/openfga/go-sdk"
"github.com/openfga/go-sdk/client"
"github.com/spf13/cobra"

"github.com/openfga/cli/internal/authorizationmodel"
"github.com/openfga/cli/internal/cmdutils"
"github.com/openfga/cli/internal/output"
)

func Write(
Expand Down
3 changes: 2 additions & 1 deletion cmd/model/write_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (
"testing"

"github.com/golang/mock/gomock"
"github.com/openfga/go-sdk/client"

"github.com/openfga/cli/internal/authorizationmodel"
mockclient "github.com/openfga/cli/internal/mocks"
"github.com/openfga/go-sdk/client"
)

var errMockWrite = errors.New("mock error")
Expand Down
5 changes: 3 additions & 2 deletions cmd/query/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ import (
"context"
"fmt"

cmdutils2 "github.com/openfga/cli/internal/cmdutils"
"github.com/openfga/cli/internal/output"
"github.com/openfga/go-sdk/client"
"github.com/spf13/cobra"

cmdutils2 "github.com/openfga/cli/internal/cmdutils"
"github.com/openfga/cli/internal/output"
)

func check(
Expand Down
3 changes: 2 additions & 1 deletion cmd/query/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"testing"

"github.com/golang/mock/gomock"
"github.com/openfga/cli/internal/mocks"
openfga "github.com/openfga/go-sdk"
"github.com/openfga/go-sdk/client"

mock_client "github.com/openfga/cli/internal/mocks"
)

var errMockCheck = errors.New("mock error")
Expand Down
5 changes: 3 additions & 2 deletions cmd/query/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ import (
"context"
"fmt"

"github.com/openfga/cli/internal/cmdutils"
"github.com/openfga/cli/internal/output"
"github.com/openfga/go-sdk/client"
"github.com/spf13/cobra"

"github.com/openfga/cli/internal/cmdutils"
"github.com/openfga/cli/internal/output"
)

func expand(fgaClient client.SdkClient, relation string, object string) (*client.ClientExpandResponse, error) {
Expand Down
3 changes: 2 additions & 1 deletion cmd/query/expand_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import (
"testing"

"github.com/golang/mock/gomock"
"github.com/openfga/cli/internal/mocks"
"github.com/openfga/go-sdk/client"

mock_client "github.com/openfga/cli/internal/mocks"
)

var errMockExpand = errors.New("mock error")
Expand Down
5 changes: 3 additions & 2 deletions cmd/query/list-objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ import (
"context"
"fmt"

cmdutils2 "github.com/openfga/cli/internal/cmdutils"
"github.com/openfga/cli/internal/output"
"github.com/openfga/go-sdk/client"
"github.com/spf13/cobra"

cmdutils2 "github.com/openfga/cli/internal/cmdutils"
"github.com/openfga/cli/internal/output"
)

// listObjects in the internal function for calling SDK for list objects.
Expand Down
3 changes: 2 additions & 1 deletion cmd/query/list-objects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import (
"testing"

"github.com/golang/mock/gomock"
"github.com/openfga/cli/internal/mocks"
"github.com/openfga/go-sdk/client"

mock_client "github.com/openfga/cli/internal/mocks"
)

var errMockListObjects = errors.New("mock error")
Expand Down
7 changes: 4 additions & 3 deletions cmd/query/list-relations.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ import (
"fmt"
"strings"

cmdutils2 "github.com/openfga/cli/internal/cmdutils"
"github.com/openfga/cli/internal/fga"
"github.com/openfga/cli/internal/output"
openfga "github.com/openfga/go-sdk"
"github.com/openfga/go-sdk/client"
"github.com/spf13/cobra"

cmdutils2 "github.com/openfga/cli/internal/cmdutils"
"github.com/openfga/cli/internal/fga"
"github.com/openfga/cli/internal/output"
)

func getRelationsForType(
Expand Down
5 changes: 3 additions & 2 deletions cmd/query/list-relations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import (
"testing"

"github.com/golang/mock/gomock"
"github.com/openfga/cli/internal/fga"
"github.com/openfga/cli/internal/mocks"
"github.com/openfga/go-sdk/client"

"github.com/openfga/cli/internal/fga"
mock_client "github.com/openfga/cli/internal/mocks"
)

var errMockGet = errors.New("mock get model error")
Expand Down
5 changes: 3 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ import (
"os"
"strings"

"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/openfga/cli/cmd/model"
"github.com/openfga/cli/cmd/query"
"github.com/openfga/cli/cmd/store"
"github.com/openfga/cli/cmd/tuple"
"github.com/openfga/cli/internal/cmdutils"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

var cfgFile string
Expand Down
5 changes: 3 additions & 2 deletions cmd/store/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ import (
"context"
"fmt"

"github.com/openfga/go-sdk/client"
"github.com/spf13/cobra"

"github.com/openfga/cli/cmd/model"
"github.com/openfga/cli/internal/authorizationmodel"
"github.com/openfga/cli/internal/cmdutils"
"github.com/openfga/cli/internal/fga"
"github.com/openfga/cli/internal/output"
"github.com/openfga/go-sdk/client"
"github.com/spf13/cobra"
)

type CreateStoreAndModelResponse struct {
Expand Down
3 changes: 2 additions & 1 deletion cmd/store/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import (
"time"

"github.com/golang/mock/gomock"
"github.com/openfga/cli/internal/mocks"
"github.com/openfga/go-sdk/client"

mock_client "github.com/openfga/cli/internal/mocks"
)

var errMockCreate = errors.New("mock error")
Expand Down
3 changes: 2 additions & 1 deletion cmd/store/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ import (
"fmt"
"os"

"github.com/spf13/cobra"

"github.com/openfga/cli/internal/cmdutils"
"github.com/openfga/cli/internal/confirmation"
"github.com/openfga/cli/internal/output"
"github.com/spf13/cobra"
)

// deleteCmd represents the delete command.
Expand Down
5 changes: 3 additions & 2 deletions cmd/store/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ import (
"fmt"
"os"

"github.com/openfga/go-sdk/client"
"github.com/spf13/cobra"

"github.com/openfga/cli/internal/cmdutils"
"github.com/openfga/cli/internal/fga"
"github.com/openfga/cli/internal/output"
"github.com/openfga/go-sdk/client"
"github.com/spf13/cobra"
)

func getStore(clientConfig fga.ClientConfig, fgaClient client.SdkClient) (*client.ClientGetStoreResponse, error) {
Expand Down
5 changes: 3 additions & 2 deletions cmd/store/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import (
"time"

"github.com/golang/mock/gomock"
"github.com/openfga/cli/internal/fga"
"github.com/openfga/cli/internal/mocks"
"github.com/openfga/go-sdk/client"

"github.com/openfga/cli/internal/fga"
mock_client "github.com/openfga/cli/internal/mocks"
)

var errMockGet = errors.New("mock error")
Expand Down
5 changes: 3 additions & 2 deletions cmd/store/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ import (
"context"
"fmt"

"github.com/openfga/cli/internal/cmdutils"
"github.com/openfga/cli/internal/output"
openfga "github.com/openfga/go-sdk"
"github.com/openfga/go-sdk/client"
"github.com/spf13/cobra"

"github.com/openfga/cli/internal/cmdutils"
"github.com/openfga/cli/internal/output"
)

// MaxStoresPagesLength Limit the pages of stores so that we are not paginating indefinitely.
Expand Down
Loading

0 comments on commit 655a166

Please sign in to comment.