Skip to content

Commit

Permalink
Format go imports (flyteplugins)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Dye <[email protected]>
  • Loading branch information
andrewwdye committed Oct 13, 2023
1 parent c6476cc commit b994c5b
Show file tree
Hide file tree
Showing 180 changed files with 731 additions and 971 deletions.
14 changes: 12 additions & 2 deletions flyteplugins/.golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# WARNING: THIS FILE IS MANAGED IN THE 'BOILERPLATE' REPO AND COPIED TO OTHER REPOSITORIES.
# ONLY EDIT THIS FILE FROM WITHIN THE 'LYFT/BOILERPLATE' REPOSITORY:
# ONLY EDIT THIS FILE FROM WITHIN THE 'FLYTEORG/BOILERPLATE' REPOSITORY:
#
# TO OPT OUT OF UPDATES, SEE https://github.com/lyft/boilerplate/blob/master/Readme.rst
# TO OPT OUT OF UPDATES, SEE https://github.com/flyteorg/boilerplate/blob/master/Readme.rst

run:
skip-dirs:
Expand All @@ -13,6 +13,7 @@ linters:
- deadcode
- errcheck
- gas
- gci
- goconst
- goimports
- golint
Expand All @@ -28,3 +29,12 @@ linters:
- unparam
- unused
- varcheck

linters-settings:
gci:
custom-order: true
sections:
- standard
- default
- prefix(github.com/flyteorg)
skip-generated: true
3 changes: 2 additions & 1 deletion flyteplugins/boilerplate/flyte/golang_support_tools/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ package tools
import (
_ "github.com/EngHabu/mockery/cmd/mockery"
_ "github.com/alvaroloes/enumer"
_ "github.com/flyteorg/flyte/flytestdlib/cli/pflags"
_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
_ "github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc"

_ "github.com/flyteorg/flyte/flytestdlib/cli/pflags"
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ tools=(
"github.com/EngHabu/mockery/cmd/mockery"
"github.com/flyteorg/flytestdlib/cli/pflags@latest"
"github.com/golangci/golangci-lint/cmd/golangci-lint"
"github.com/daixiang0/gci"
"github.com/alvaroloes/enumer"
"github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
# TO OPT OUT OF UPDATES, SEE https://github.com/flyteorg/boilerplate/blob/master/Readme.rst

goimports -w $(find . -type f -name '*.go' -not -path "./vendor/*" -not -path "./pkg/client/*" -not -path "./boilerplate/*")
gci write -s standard -s default -s "prefix(github.com/flyteorg)" --custom-order --skip-generated .
40 changes: 40 additions & 0 deletions flyteplugins/boilerplate/flyte/golangci_file/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# WARNING: THIS FILE IS MANAGED IN THE 'BOILERPLATE' REPO AND COPIED TO OTHER REPOSITORIES.
# ONLY EDIT THIS FILE FROM WITHIN THE 'FLYTEORG/BOILERPLATE' REPOSITORY:
#
# TO OPT OUT OF UPDATES, SEE https://github.com/flyteorg/boilerplate/blob/master/Readme.rst

run:
skip-dirs:
- pkg/client

linters:
disable-all: true
enable:
- deadcode
- errcheck
- gas
- gci
- goconst
- goimports
- golint
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- staticcheck
- structcheck
- typecheck
- unconvert
- unparam
- unused
- varcheck

linters-settings:
gci:
custom-order: true
sections:
- standard
- default
- prefix(github.com/flyteorg)
skip-generated: true
8 changes: 8 additions & 0 deletions flyteplugins/boilerplate/flyte/golangci_file/Readme.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
GolangCI File
~~~~~~~~~~~~~

Provides a ``.golangci`` file with the linters we've agreed upon.

**To Enable:**

Add ``flyteorg/golangci_file`` to your ``boilerplate/update.cfg`` file.
14 changes: 14 additions & 0 deletions flyteplugins/boilerplate/flyte/golangci_file/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

# WARNING: THIS FILE IS MANAGED IN THE 'BOILERPLATE' REPO AND COPIED TO OTHER REPOSITORIES.
# ONLY EDIT THIS FILE FROM WITHIN THE 'FLYTEORG/BOILERPLATE' REPOSITORY:
#
# TO OPT OUT OF UPDATES, SEE https://github.com/flyteorg/boilerplate/blob/master/Readme.rst

set -e

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"

# Clone the .golangci file
echo " - copying ${DIR}/.golangci to the root directory."
cp ${DIR}/.golangci.yml ${DIR}/../../../.golangci.yml
5 changes: 3 additions & 2 deletions flyteplugins/boilerplate/update.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
flyte/code_of_conduct
flyte/docker_build
flyte/golang_test_targets
flyte/golang_support_tools
flyte/golangci_file
flyte/pull_request_template
flyte/docker_build
flyte/code_of_conduct
8 changes: 3 additions & 5 deletions flyteplugins/go/tasks/aws/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,16 @@
package aws

import (
"context"
"fmt"
"os"

"github.com/flyteorg/flyte/flytestdlib/errors"

"context"

"sync"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"

"github.com/flyteorg/flyte/flytestdlib/errors"
"github.com/flyteorg/flyte/flytestdlib/logger"
)

Expand Down
2 changes: 1 addition & 1 deletion flyteplugins/go/tasks/aws/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/aws/retry"
awsConfig "github.com/aws/aws-sdk-go-v2/config"
"github.com/flyteorg/flyte/flytestdlib/config"

pluginsConfig "github.com/flyteorg/flyte/flyteplugins/go/tasks/config"
"github.com/flyteorg/flyte/flytestdlib/config"
)

//go:generate pflags Config --default-var defaultConfig
Expand Down
4 changes: 2 additions & 2 deletions flyteplugins/go/tasks/logs/logging_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"fmt"
"time"

"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/tasklog"
v1 "k8s.io/api/core/v1"

"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core"
"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/tasklog"
"github.com/flyteorg/flyte/flytestdlib/logger"
v1 "k8s.io/api/core/v1"
)

type logPlugin struct {
Expand Down
8 changes: 4 additions & 4 deletions flyteplugins/go/tasks/logs/logging_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import (
"context"
"testing"

"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core"
"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/tasklog"
"github.com/go-test/deep"
v12 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/stretchr/testify/assert"
v1 "k8s.io/api/core/v1"
v12 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core"
"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/tasklog"
)

const podName = "PodName"
Expand Down
2 changes: 0 additions & 2 deletions flyteplugins/go/tasks/pluginmachinery/bundle/fail_fast.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import (
"time"

"github.com/flyteorg/flyte/flyteplugins/go/tasks/errors"

pluginMachinery "github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery"

"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/core"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import (
"context"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"

idlCore "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core"
"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/core/mocks"

"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/core"
"github.com/stretchr/testify/assert"
"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/core/mocks"
)

var testHandler = failFastHandler{}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ package catalog
import (
"context"

"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/io"
"github.com/flyteorg/flyte/flytestdlib/bitarray"

"github.com/flyteorg/flyte/flytestdlib/errors"

"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/io"
)

type ResponseStatus uint8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import (
"reflect"
"testing"

"github.com/stretchr/testify/mock"

"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core"
mocks2 "github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/io/mocks"
"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/workqueue"
"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/workqueue/mocks"
"github.com/flyteorg/flyte/flytestdlib/bitarray"
"github.com/stretchr/testify/mock"
)

var exampleInterface = &core.TypedInterface{
Expand Down
1 change: 0 additions & 1 deletion flyteplugins/go/tasks/pluginmachinery/catalog/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core"
"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog"

"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/io"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"context"
"testing"

"github.com/stretchr/testify/assert"

"github.com/flyteorg/flyte/flyteidl/clients/go/coreutils"
"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core"
"github.com/stretchr/testify/assert"
)

func TestHashLiteralMap_LiteralsWithHashSet(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@ import (
"reflect"

"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core"

"github.com/flyteorg/flyte/flyteplugins/go/tasks/errors"

"github.com/flyteorg/flyte/flytestdlib/logger"

"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/io"

"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/workqueue"
"github.com/flyteorg/flyte/flytestdlib/logger"
)

type ReaderWorkItem struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import (
"reflect"

"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core"
"github.com/flyteorg/flyte/flytestdlib/logger"

"github.com/flyteorg/flyte/flyteplugins/go/tasks/errors"
"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/io"
"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/workqueue"
"github.com/flyteorg/flyte/flytestdlib/logger"
)

type WriterWorkItem struct {
Expand Down
3 changes: 2 additions & 1 deletion flyteplugins/go/tasks/pluginmachinery/core/exec_metadata.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package core

import (
"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core"
v1 "k8s.io/api/core/v1"
v12 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"

"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core"
)

// TaskOverrides interface to expose any overrides that have been set for this task (like resource overrides etc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ import (
"reflect"
"sync"

"sigs.k8s.io/controller-runtime/pkg/cache"

"k8s.io/apimachinery/pkg/api/meta"

"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand Down
3 changes: 2 additions & 1 deletion flyteplugins/go/tasks/pluginmachinery/core/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"context"
"testing"

"gotest.tools/assert"

"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/core"
"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/core/mocks"
"gotest.tools/assert"
)

func TestLoadPlugin(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion flyteplugins/go/tasks/pluginmachinery/core/setup_context.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package core

import (
"github.com/flyteorg/flyte/flytestdlib/promutils"
"k8s.io/apimachinery/pkg/types"

"github.com/flyteorg/flyte/flytestdlib/promutils"
)

// When a change is observed, the owning entity with id types.NamespacedName can be triggered for re-validation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ import (
"regexp"
"strings"

"github.com/golang/protobuf/ptypes"
"github.com/pkg/errors"

idlCore "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core"
"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/core"
"github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/io"
"github.com/flyteorg/flyte/flytestdlib/logger"
"github.com/golang/protobuf/ptypes"
"github.com/pkg/errors"
)

var alphaNumericOnly = regexp.MustCompile("[^a-zA-Z0-9_]+")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ import (
"testing"
"time"

pluginsCoreMocks "github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/core/mocks"
"github.com/stretchr/testify/assert"

"github.com/flyteorg/flyte/flyteidl/clients/go/coreutils"
"github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core"
pluginsCoreMocks "github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/core/mocks"
"github.com/flyteorg/flyte/flytestdlib/storage"

"github.com/stretchr/testify/assert"
)

type dummyInputReader struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ package config
import (
"time"

"k8s.io/apimachinery/pkg/api/resource"

config2 "github.com/flyteorg/flyte/flytestdlib/config"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"

"github.com/flyteorg/flyte/flyteplugins/go/tasks/config"
config2 "github.com/flyteorg/flyte/flytestdlib/config"
)

//go:generate pflags K8sPluginConfig --default-var=defaultK8sConfig
Expand Down
Loading

0 comments on commit b994c5b

Please sign in to comment.