diff --git a/datacatalog/.golangci.yml b/datacatalog/.golangci.yml index 5d53f35295..7f4dbc80e8 100644 --- a/datacatalog/.golangci.yml +++ b/datacatalog/.golangci.yml @@ -13,6 +13,7 @@ linters: - deadcode - errcheck - gas + - gci - goconst - goimports - golint @@ -28,3 +29,12 @@ linters: - unparam - unused - varcheck + +linters-settings: + gci: + custom-order: true + sections: + - standard + - default + - prefix(github.com/flyteorg) + skip-generated: true diff --git a/datacatalog/boilerplate/flyte/golang_support_tools/tools.go b/datacatalog/boilerplate/flyte/golang_support_tools/tools.go index a78b61162a..6c3da04107 100644 --- a/datacatalog/boilerplate/flyte/golang_support_tools/tools.go +++ b/datacatalog/boilerplate/flyte/golang_support_tools/tools.go @@ -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" ) diff --git a/datacatalog/boilerplate/flyte/golang_test_targets/download_tooling.sh b/datacatalog/boilerplate/flyte/golang_test_targets/download_tooling.sh index c7e5577ef3..9cd49959f4 100755 --- a/datacatalog/boilerplate/flyte/golang_test_targets/download_tooling.sh +++ b/datacatalog/boilerplate/flyte/golang_test_targets/download_tooling.sh @@ -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" ) diff --git a/datacatalog/boilerplate/flyte/golang_test_targets/goimports b/datacatalog/boilerplate/flyte/golang_test_targets/goimports index af1829036c..40f50d106e 100755 --- a/datacatalog/boilerplate/flyte/golang_test_targets/goimports +++ b/datacatalog/boilerplate/flyte/golang_test_targets/goimports @@ -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 . diff --git a/datacatalog/boilerplate/flyte/golangci_file/.golangci.yml b/datacatalog/boilerplate/flyte/golangci_file/.golangci.yml index 5d53f35295..7f4dbc80e8 100644 --- a/datacatalog/boilerplate/flyte/golangci_file/.golangci.yml +++ b/datacatalog/boilerplate/flyte/golangci_file/.golangci.yml @@ -13,6 +13,7 @@ linters: - deadcode - errcheck - gas + - gci - goconst - goimports - golint @@ -28,3 +29,12 @@ linters: - unparam - unused - varcheck + +linters-settings: + gci: + custom-order: true + sections: + - standard + - default + - prefix(github.com/flyteorg) + skip-generated: true diff --git a/datacatalog/cmd/entrypoints/migrate.go b/datacatalog/cmd/entrypoints/migrate.go index 1c8a7971a0..1c47518baf 100644 --- a/datacatalog/cmd/entrypoints/migrate.go +++ b/datacatalog/cmd/entrypoints/migrate.go @@ -1,11 +1,11 @@ package entrypoints import ( - "github.com/flyteorg/flyte/datacatalog/pkg/repositories" - "context" "github.com/spf13/cobra" + + "github.com/flyteorg/flyte/datacatalog/pkg/repositories" ) var parentMigrateCmd = &cobra.Command{ diff --git a/datacatalog/cmd/entrypoints/root.go b/datacatalog/cmd/entrypoints/root.go index 218249abb2..32ff30f8d8 100644 --- a/datacatalog/cmd/entrypoints/root.go +++ b/datacatalog/cmd/entrypoints/root.go @@ -6,12 +6,12 @@ import ( "fmt" "os" - "github.com/flyteorg/flyte/flytestdlib/logger" + "github.com/spf13/cobra" + "github.com/spf13/pflag" "github.com/flyteorg/flyte/flytestdlib/config" "github.com/flyteorg/flyte/flytestdlib/config/viper" - "github.com/spf13/cobra" - "github.com/spf13/pflag" + "github.com/flyteorg/flyte/flytestdlib/logger" ) var ( diff --git a/datacatalog/cmd/entrypoints/serve.go b/datacatalog/cmd/entrypoints/serve.go index c60a7e0bce..1cd7e94a72 100644 --- a/datacatalog/cmd/entrypoints/serve.go +++ b/datacatalog/cmd/entrypoints/serve.go @@ -3,6 +3,8 @@ package entrypoints import ( "context" + "github.com/spf13/cobra" + "github.com/flyteorg/flyte/datacatalog/pkg/config" "github.com/flyteorg/flyte/datacatalog/pkg/rpc/datacatalogservice" "github.com/flyteorg/flyte/datacatalog/pkg/runtime" @@ -10,8 +12,6 @@ import ( "github.com/flyteorg/flyte/flytestdlib/logger" "github.com/flyteorg/flyte/flytestdlib/profutils" "github.com/flyteorg/flyte/flytestdlib/promutils/labeled" - - "github.com/spf13/cobra" ) var serveCmd = &cobra.Command{ diff --git a/datacatalog/cmd/entrypoints/serve_dummy.go b/datacatalog/cmd/entrypoints/serve_dummy.go index 5296fd4686..a7bcb7cb62 100644 --- a/datacatalog/cmd/entrypoints/serve_dummy.go +++ b/datacatalog/cmd/entrypoints/serve_dummy.go @@ -3,10 +3,11 @@ package entrypoints import ( "context" + "github.com/spf13/cobra" + "github.com/flyteorg/flyte/datacatalog/pkg/config" "github.com/flyteorg/flyte/datacatalog/pkg/rpc/datacatalogservice" "github.com/flyteorg/flyte/flytestdlib/logger" - "github.com/spf13/cobra" ) var serveDummyCmd = &cobra.Command{ diff --git a/datacatalog/cmd/main.go b/datacatalog/cmd/main.go index b5db86d40b..62b613b39e 100644 --- a/datacatalog/cmd/main.go +++ b/datacatalog/cmd/main.go @@ -1,8 +1,9 @@ package main import ( - "github.com/flyteorg/flyte/datacatalog/cmd/entrypoints" "github.com/golang/glog" + + "github.com/flyteorg/flyte/datacatalog/cmd/entrypoints" ) func main() { diff --git a/datacatalog/pkg/errors/errors_test.go b/datacatalog/pkg/errors/errors_test.go index f59de14d69..b3e32c36a0 100644 --- a/datacatalog/pkg/errors/errors_test.go +++ b/datacatalog/pkg/errors/errors_test.go @@ -1,9 +1,8 @@ package errors import ( - "testing" - "fmt" + "testing" "github.com/stretchr/testify/assert" "google.golang.org/grpc/codes" diff --git a/datacatalog/pkg/manager/impl/artifact_data_store.go b/datacatalog/pkg/manager/impl/artifact_data_store.go index 2a03cefa23..5cbd3cc3e0 100644 --- a/datacatalog/pkg/manager/impl/artifact_data_store.go +++ b/datacatalog/pkg/manager/impl/artifact_data_store.go @@ -3,12 +3,13 @@ package impl import ( "context" + "google.golang.org/grpc/codes" + "github.com/flyteorg/flyte/datacatalog/pkg/errors" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/models" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" "github.com/flyteorg/flyte/flytestdlib/storage" - "google.golang.org/grpc/codes" ) const artifactDataFile = "data.pb" diff --git a/datacatalog/pkg/manager/impl/artifact_manager.go b/datacatalog/pkg/manager/impl/artifact_manager.go index 569c72634d..8a05ad1c44 100644 --- a/datacatalog/pkg/manager/impl/artifact_manager.go +++ b/datacatalog/pkg/manager/impl/artifact_manager.go @@ -5,22 +5,21 @@ import ( "strconv" "time" + "google.golang.org/grpc/codes" + + "github.com/flyteorg/flyte/datacatalog/pkg/common" "github.com/flyteorg/flyte/datacatalog/pkg/errors" "github.com/flyteorg/flyte/datacatalog/pkg/manager/impl/validators" "github.com/flyteorg/flyte/datacatalog/pkg/manager/interfaces" "github.com/flyteorg/flyte/datacatalog/pkg/repositories" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" - "github.com/flyteorg/flyte/datacatalog/pkg/repositories/models" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/transformers" - - "github.com/flyteorg/flyte/datacatalog/pkg/common" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" "github.com/flyteorg/flyte/flytestdlib/contextutils" "github.com/flyteorg/flyte/flytestdlib/logger" "github.com/flyteorg/flyte/flytestdlib/promutils" "github.com/flyteorg/flyte/flytestdlib/promutils/labeled" "github.com/flyteorg/flyte/flytestdlib/storage" - "google.golang.org/grpc/codes" ) type artifactMetrics struct { diff --git a/datacatalog/pkg/manager/impl/artifact_manager_test.go b/datacatalog/pkg/manager/impl/artifact_manager_test.go index 50477a7146..a40672550f 100644 --- a/datacatalog/pkg/manager/impl/artifact_manager_test.go +++ b/datacatalog/pkg/manager/impl/artifact_manager_test.go @@ -3,11 +3,17 @@ package impl import ( "context" stdErrors "errors" + "fmt" "os" "testing" "time" - "fmt" + "github.com/golang/protobuf/proto" + "github.com/golang/protobuf/ptypes" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" "github.com/flyteorg/flyte/datacatalog/pkg/common" "github.com/flyteorg/flyte/datacatalog/pkg/errors" @@ -20,12 +26,6 @@ import ( mockScope "github.com/flyteorg/flyte/flytestdlib/promutils" "github.com/flyteorg/flyte/flytestdlib/promutils/labeled" "github.com/flyteorg/flyte/flytestdlib/storage" - "github.com/golang/protobuf/proto" - "github.com/golang/protobuf/ptypes" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" ) func init() { diff --git a/datacatalog/pkg/manager/impl/dataset_manager.go b/datacatalog/pkg/manager/impl/dataset_manager.go index 2645c30c64..0db84d6360 100644 --- a/datacatalog/pkg/manager/impl/dataset_manager.go +++ b/datacatalog/pkg/manager/impl/dataset_manager.go @@ -5,6 +5,8 @@ import ( "strconv" "time" + "google.golang.org/grpc/codes" + "github.com/flyteorg/flyte/datacatalog/pkg/common" "github.com/flyteorg/flyte/datacatalog/pkg/errors" "github.com/flyteorg/flyte/datacatalog/pkg/manager/impl/validators" @@ -16,7 +18,6 @@ import ( "github.com/flyteorg/flyte/flytestdlib/promutils" "github.com/flyteorg/flyte/flytestdlib/promutils/labeled" "github.com/flyteorg/flyte/flytestdlib/storage" - "google.golang.org/grpc/codes" ) type datasetMetrics struct { diff --git a/datacatalog/pkg/manager/impl/dataset_manager_test.go b/datacatalog/pkg/manager/impl/dataset_manager_test.go index 536d4aff76..2ebd107304 100644 --- a/datacatalog/pkg/manager/impl/dataset_manager_test.go +++ b/datacatalog/pkg/manager/impl/dataset_manager_test.go @@ -1,9 +1,14 @@ package impl import ( + "context" "testing" - "context" + "github.com/golang/protobuf/proto" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" "github.com/flyteorg/flyte/datacatalog/pkg/common" "github.com/flyteorg/flyte/datacatalog/pkg/errors" @@ -14,11 +19,6 @@ import ( "github.com/flyteorg/flyte/flytestdlib/contextutils" mockScope "github.com/flyteorg/flyte/flytestdlib/promutils" "github.com/flyteorg/flyte/flytestdlib/promutils/labeled" - "github.com/golang/protobuf/proto" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" ) func init() { diff --git a/datacatalog/pkg/manager/impl/reservation_manager.go b/datacatalog/pkg/manager/impl/reservation_manager.go index 54c4c4abde..394ad5a55d 100644 --- a/datacatalog/pkg/manager/impl/reservation_manager.go +++ b/datacatalog/pkg/manager/impl/reservation_manager.go @@ -4,19 +4,16 @@ import ( "context" "time" - "github.com/flyteorg/flyte/flytestdlib/logger" - "github.com/flyteorg/flyte/flytestdlib/promutils" - "github.com/flyteorg/flyte/flytestdlib/promutils/labeled" - "github.com/flyteorg/flyte/datacatalog/pkg/errors" + "github.com/flyteorg/flyte/datacatalog/pkg/manager/interfaces" "github.com/flyteorg/flyte/datacatalog/pkg/repositories" repo_errors "github.com/flyteorg/flyte/datacatalog/pkg/repositories/errors" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/models" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/transformers" - - "github.com/flyteorg/flyte/datacatalog/pkg/manager/interfaces" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" + "github.com/flyteorg/flyte/flytestdlib/logger" + "github.com/flyteorg/flyte/flytestdlib/promutils" + "github.com/flyteorg/flyte/flytestdlib/promutils/labeled" ) type reservationMetrics struct { diff --git a/datacatalog/pkg/manager/impl/reservation_manager_test.go b/datacatalog/pkg/manager/impl/reservation_manager_test.go index e86ede2212..0dd7408792 100644 --- a/datacatalog/pkg/manager/impl/reservation_manager_test.go +++ b/datacatalog/pkg/manager/impl/reservation_manager_test.go @@ -3,21 +3,20 @@ package impl import ( "context" "fmt" - - mockScope "github.com/flyteorg/flyte/flytestdlib/promutils" - "testing" "time" + "github.com/golang/protobuf/ptypes" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" + "google.golang.org/grpc/codes" + errors2 "github.com/flyteorg/flyte/datacatalog/pkg/errors" errors3 "github.com/flyteorg/flyte/datacatalog/pkg/repositories/errors" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/mocks" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/models" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" - "github.com/golang/protobuf/ptypes" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" - "google.golang.org/grpc/codes" + mockScope "github.com/flyteorg/flyte/flytestdlib/promutils" ) var tagName = "tag" diff --git a/datacatalog/pkg/manager/impl/tag_manager.go b/datacatalog/pkg/manager/impl/tag_manager.go index 52828822d3..784af9164c 100644 --- a/datacatalog/pkg/manager/impl/tag_manager.go +++ b/datacatalog/pkg/manager/impl/tag_manager.go @@ -4,15 +4,13 @@ import ( "context" "time" + "github.com/flyteorg/flyte/datacatalog/pkg/errors" "github.com/flyteorg/flyte/datacatalog/pkg/manager/impl/validators" "github.com/flyteorg/flyte/datacatalog/pkg/manager/interfaces" "github.com/flyteorg/flyte/datacatalog/pkg/repositories" - "github.com/flyteorg/flyte/datacatalog/pkg/repositories/models" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/transformers" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" - - "github.com/flyteorg/flyte/datacatalog/pkg/errors" "github.com/flyteorg/flyte/flytestdlib/contextutils" "github.com/flyteorg/flyte/flytestdlib/logger" "github.com/flyteorg/flyte/flytestdlib/promutils" diff --git a/datacatalog/pkg/manager/impl/tag_manager_test.go b/datacatalog/pkg/manager/impl/tag_manager_test.go index 56581e00f3..98e4b41dfd 100644 --- a/datacatalog/pkg/manager/impl/tag_manager_test.go +++ b/datacatalog/pkg/manager/impl/tag_manager_test.go @@ -4,17 +4,17 @@ import ( "context" "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/mock" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "github.com/flyteorg/flyte/datacatalog/pkg/repositories/mocks" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/models" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" - "github.com/flyteorg/flyte/flytestdlib/contextutils" mockScope "github.com/flyteorg/flyte/flytestdlib/promutils" "github.com/flyteorg/flyte/flytestdlib/promutils/labeled" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/mock" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" ) func init() { diff --git a/datacatalog/pkg/manager/impl/validators/errors.go b/datacatalog/pkg/manager/impl/validators/errors.go index ec8f94d90f..dae123ebfd 100644 --- a/datacatalog/pkg/manager/impl/validators/errors.go +++ b/datacatalog/pkg/manager/impl/validators/errors.go @@ -3,10 +3,10 @@ package validators import ( "fmt" - "github.com/flyteorg/flyte/datacatalog/pkg/errors" + "google.golang.org/grpc/codes" "github.com/flyteorg/flyte/datacatalog/pkg/common" - "google.golang.org/grpc/codes" + "github.com/flyteorg/flyte/datacatalog/pkg/errors" ) const missingFieldFormat = "missing %s" diff --git a/datacatalog/pkg/manager/impl/validators/pagination_validator.go b/datacatalog/pkg/manager/impl/validators/pagination_validator.go index 367a1d7a4f..7f37dbe7d5 100644 --- a/datacatalog/pkg/manager/impl/validators/pagination_validator.go +++ b/datacatalog/pkg/manager/impl/validators/pagination_validator.go @@ -4,9 +4,10 @@ import ( "strconv" "strings" + "google.golang.org/grpc/codes" + "github.com/flyteorg/flyte/datacatalog/pkg/errors" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" - "google.golang.org/grpc/codes" ) // The token is a string that should be opaque to the client diff --git a/datacatalog/pkg/manager/impl/validators/partition_validator.go b/datacatalog/pkg/manager/impl/validators/partition_validator.go index f672413b05..2b94e0e366 100644 --- a/datacatalog/pkg/manager/impl/validators/partition_validator.go +++ b/datacatalog/pkg/manager/impl/validators/partition_validator.go @@ -3,9 +3,10 @@ package validators import ( "fmt" + "google.golang.org/grpc/codes" + "github.com/flyteorg/flyte/datacatalog/pkg/errors" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" - "google.golang.org/grpc/codes" ) const ( diff --git a/datacatalog/pkg/repositories/config/postgres.go b/datacatalog/pkg/repositories/config/postgres.go index 49c263f3fc..3cd5b62a3a 100644 --- a/datacatalog/pkg/repositories/config/postgres.go +++ b/datacatalog/pkg/repositories/config/postgres.go @@ -4,13 +4,13 @@ import ( "context" "fmt" - "github.com/flyteorg/flyte/flytestdlib/database" - stdlibLogger "github.com/flyteorg/flyte/flytestdlib/logger" - "github.com/flyteorg/flyte/flytestdlib/promutils" - "gorm.io/driver/postgres" "gorm.io/gorm" "gorm.io/gorm/logger" + + "github.com/flyteorg/flyte/flytestdlib/database" + stdlibLogger "github.com/flyteorg/flyte/flytestdlib/logger" + "github.com/flyteorg/flyte/flytestdlib/promutils" ) const ( diff --git a/datacatalog/pkg/repositories/config/postgres_test.go b/datacatalog/pkg/repositories/config/postgres_test.go index 3d968e9090..0da78b4182 100644 --- a/datacatalog/pkg/repositories/config/postgres_test.go +++ b/datacatalog/pkg/repositories/config/postgres_test.go @@ -6,14 +6,13 @@ import ( "testing" "time" - "github.com/flyteorg/flyte/flytestdlib/config" - "github.com/flyteorg/flyte/flytestdlib/database" - mockScope "github.com/flyteorg/flyte/flytestdlib/promutils" - "github.com/stretchr/testify/assert" - "gorm.io/driver/sqlite" "gorm.io/gorm" + + "github.com/flyteorg/flyte/flytestdlib/config" + "github.com/flyteorg/flyte/flytestdlib/database" + mockScope "github.com/flyteorg/flyte/flytestdlib/promutils" ) func TestConstructGormArgs(t *testing.T) { diff --git a/datacatalog/pkg/repositories/errors/errors.go b/datacatalog/pkg/repositories/errors/errors.go index 9dee09b23e..37476a0df0 100644 --- a/datacatalog/pkg/repositories/errors/errors.go +++ b/datacatalog/pkg/repositories/errors/errors.go @@ -2,10 +2,11 @@ package errors import ( - "github.com/flyteorg/flyte/datacatalog/pkg/common" - "github.com/flyteorg/flyte/datacatalog/pkg/errors" "github.com/golang/protobuf/proto" "google.golang.org/grpc/codes" + + "github.com/flyteorg/flyte/datacatalog/pkg/common" + "github.com/flyteorg/flyte/datacatalog/pkg/errors" ) const ( diff --git a/datacatalog/pkg/repositories/errors/postgres.go b/datacatalog/pkg/repositories/errors/postgres.go index e30bd419f8..861903938b 100644 --- a/datacatalog/pkg/repositories/errors/postgres.go +++ b/datacatalog/pkg/repositories/errors/postgres.go @@ -5,13 +5,12 @@ import ( "fmt" "reflect" - "github.com/flyteorg/flyte/flytestdlib/logger" - "github.com/jackc/pgconn" - - catalogErrors "github.com/flyteorg/flyte/datacatalog/pkg/errors" "google.golang.org/grpc/codes" "gorm.io/gorm" + + catalogErrors "github.com/flyteorg/flyte/datacatalog/pkg/errors" + "github.com/flyteorg/flyte/flytestdlib/logger" ) // Postgres error codes diff --git a/datacatalog/pkg/repositories/factory.go b/datacatalog/pkg/repositories/factory.go index c5d6e15711..65f747baa2 100644 --- a/datacatalog/pkg/repositories/factory.go +++ b/datacatalog/pkg/repositories/factory.go @@ -4,11 +4,10 @@ import ( "context" "fmt" - "github.com/flyteorg/flyte/flytestdlib/database" - "github.com/flyteorg/flyte/datacatalog/pkg/repositories/config" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/errors" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/interfaces" + "github.com/flyteorg/flyte/flytestdlib/database" "github.com/flyteorg/flyte/flytestdlib/promutils" ) diff --git a/datacatalog/pkg/repositories/gormimpl/artifact.go b/datacatalog/pkg/repositories/gormimpl/artifact.go index 7045c6fa71..5d66c4839e 100644 --- a/datacatalog/pkg/repositories/gormimpl/artifact.go +++ b/datacatalog/pkg/repositories/gormimpl/artifact.go @@ -3,15 +3,15 @@ package gormimpl import ( "context" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" + "gorm.io/gorm" + "gorm.io/gorm/clause" "github.com/flyteorg/flyte/datacatalog/pkg/common" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/errors" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/interfaces" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/models" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" "github.com/flyteorg/flyte/flytestdlib/promutils" - "gorm.io/gorm" - "gorm.io/gorm/clause" ) type artifactRepo struct { diff --git a/datacatalog/pkg/repositories/gormimpl/artifact_test.go b/datacatalog/pkg/repositories/gormimpl/artifact_test.go index 598f9c5026..18b819d45f 100644 --- a/datacatalog/pkg/repositories/gormimpl/artifact_test.go +++ b/datacatalog/pkg/repositories/gormimpl/artifact_test.go @@ -2,12 +2,12 @@ package gormimpl import ( "context" + "database/sql/driver" "testing" mocket "github.com/Selvatico/go-mocket" "github.com/stretchr/testify/assert" - - "database/sql/driver" + "google.golang.org/grpc/codes" "github.com/flyteorg/flyte/datacatalog/pkg/common" apiErrors "github.com/flyteorg/flyte/datacatalog/pkg/errors" @@ -18,7 +18,6 @@ import ( "github.com/flyteorg/flyte/flytestdlib/contextutils" "github.com/flyteorg/flyte/flytestdlib/promutils" "github.com/flyteorg/flyte/flytestdlib/promutils/labeled" - "google.golang.org/grpc/codes" ) func init() { diff --git a/datacatalog/pkg/repositories/gormimpl/dataset.go b/datacatalog/pkg/repositories/gormimpl/dataset.go index b4bbe59f3a..24451d0a3f 100644 --- a/datacatalog/pkg/repositories/gormimpl/dataset.go +++ b/datacatalog/pkg/repositories/gormimpl/dataset.go @@ -3,15 +3,15 @@ package gormimpl import ( "context" - idl_datacatalog "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" + "gorm.io/gorm" "github.com/flyteorg/flyte/datacatalog/pkg/common" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/errors" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/interfaces" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/models" + idl_datacatalog "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" "github.com/flyteorg/flyte/flytestdlib/logger" "github.com/flyteorg/flyte/flytestdlib/promutils" - "gorm.io/gorm" ) type dataSetRepo struct { diff --git a/datacatalog/pkg/repositories/gormimpl/dataset_test.go b/datacatalog/pkg/repositories/gormimpl/dataset_test.go index 8df5857886..01475248fb 100644 --- a/datacatalog/pkg/repositories/gormimpl/dataset_test.go +++ b/datacatalog/pkg/repositories/gormimpl/dataset_test.go @@ -2,15 +2,13 @@ package gormimpl import ( "context" + "database/sql/driver" "testing" "time" mocket "github.com/Selvatico/go-mocket" - "google.golang.org/grpc/codes" - "github.com/stretchr/testify/assert" - - "database/sql/driver" + "google.golang.org/grpc/codes" "github.com/flyteorg/flyte/datacatalog/pkg/common" datacatalog_error "github.com/flyteorg/flyte/datacatalog/pkg/errors" diff --git a/datacatalog/pkg/repositories/gormimpl/filter_test.go b/datacatalog/pkg/repositories/gormimpl/filter_test.go index c267e86fef..68d46022ea 100644 --- a/datacatalog/pkg/repositories/gormimpl/filter_test.go +++ b/datacatalog/pkg/repositories/gormimpl/filter_test.go @@ -3,8 +3,9 @@ package gormimpl import ( "testing" - "github.com/flyteorg/flyte/datacatalog/pkg/common" "github.com/stretchr/testify/assert" + + "github.com/flyteorg/flyte/datacatalog/pkg/common" ) func TestGormValueFilter(t *testing.T) { diff --git a/datacatalog/pkg/repositories/gormimpl/join_test.go b/datacatalog/pkg/repositories/gormimpl/join_test.go index df9843e448..28d463adf5 100644 --- a/datacatalog/pkg/repositories/gormimpl/join_test.go +++ b/datacatalog/pkg/repositories/gormimpl/join_test.go @@ -3,8 +3,9 @@ package gormimpl import ( "testing" - "github.com/flyteorg/flyte/datacatalog/pkg/common" "github.com/stretchr/testify/assert" + + "github.com/flyteorg/flyte/datacatalog/pkg/common" ) func TestGormJoinCondition(t *testing.T) { diff --git a/datacatalog/pkg/repositories/gormimpl/list.go b/datacatalog/pkg/repositories/gormimpl/list.go index 260039cc8a..f1d5ad15e5 100644 --- a/datacatalog/pkg/repositories/gormimpl/list.go +++ b/datacatalog/pkg/repositories/gormimpl/list.go @@ -3,13 +3,13 @@ package gormimpl import ( "fmt" - errors2 "github.com/flyteorg/flyte/datacatalog/pkg/errors" + "google.golang.org/grpc/codes" + "gorm.io/gorm" "github.com/flyteorg/flyte/datacatalog/pkg/common" + errors2 "github.com/flyteorg/flyte/datacatalog/pkg/errors" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/errors" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/models" - "google.golang.org/grpc/codes" - "gorm.io/gorm" ) const ( diff --git a/datacatalog/pkg/repositories/gormimpl/list_test.go b/datacatalog/pkg/repositories/gormimpl/list_test.go index 44e944dfcf..c46b438f28 100644 --- a/datacatalog/pkg/repositories/gormimpl/list_test.go +++ b/datacatalog/pkg/repositories/gormimpl/list_test.go @@ -6,11 +6,12 @@ import ( "testing" mocket "github.com/Selvatico/go-mocket" + "github.com/stretchr/testify/assert" + "github.com/flyteorg/flyte/datacatalog/pkg/common" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/models" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/utils" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" - "github.com/stretchr/testify/assert" ) func TestApplyFilter(t *testing.T) { diff --git a/datacatalog/pkg/repositories/gormimpl/reservation.go b/datacatalog/pkg/repositories/gormimpl/reservation.go index 4f4e069cf4..8e387afec4 100644 --- a/datacatalog/pkg/repositories/gormimpl/reservation.go +++ b/datacatalog/pkg/repositories/gormimpl/reservation.go @@ -2,20 +2,18 @@ package gormimpl import ( "context" - - datacatalog_error "github.com/flyteorg/flyte/datacatalog/pkg/errors" - "google.golang.org/grpc/codes" - "time" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" + "google.golang.org/grpc/codes" + "gorm.io/gorm" + "gorm.io/gorm/clause" + datacatalog_error "github.com/flyteorg/flyte/datacatalog/pkg/errors" errors2 "github.com/flyteorg/flyte/datacatalog/pkg/repositories/errors" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/interfaces" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/models" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" "github.com/flyteorg/flyte/flytestdlib/promutils" - "gorm.io/gorm" - "gorm.io/gorm/clause" ) type reservationRepo struct { diff --git a/datacatalog/pkg/repositories/gormimpl/reservation_test.go b/datacatalog/pkg/repositories/gormimpl/reservation_test.go index 2a357a09f7..dbef22ec21 100644 --- a/datacatalog/pkg/repositories/gormimpl/reservation_test.go +++ b/datacatalog/pkg/repositories/gormimpl/reservation_test.go @@ -6,19 +6,17 @@ import ( "testing" "time" + mocket "github.com/Selvatico/go-mocket" + "github.com/stretchr/testify/assert" + "google.golang.org/grpc/codes" "gorm.io/driver/postgres" "gorm.io/gorm" - "github.com/flyteorg/flyte/datacatalog/pkg/repositories/interfaces" - apiErrors "github.com/flyteorg/flyte/datacatalog/pkg/errors" - "google.golang.org/grpc/codes" - - mocket "github.com/Selvatico/go-mocket" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/errors" + "github.com/flyteorg/flyte/datacatalog/pkg/repositories/interfaces" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/models" "github.com/flyteorg/flyte/flytestdlib/promutils" - "github.com/stretchr/testify/assert" ) func TestCreate(t *testing.T) { diff --git a/datacatalog/pkg/repositories/gormimpl/sort_test.go b/datacatalog/pkg/repositories/gormimpl/sort_test.go index 136cc6ea03..d6709ce0c2 100644 --- a/datacatalog/pkg/repositories/gormimpl/sort_test.go +++ b/datacatalog/pkg/repositories/gormimpl/sort_test.go @@ -3,8 +3,9 @@ package gormimpl import ( "testing" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" "github.com/stretchr/testify/assert" + + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" ) func TestSortAsc(t *testing.T) { diff --git a/datacatalog/pkg/repositories/gormimpl/tag.go b/datacatalog/pkg/repositories/gormimpl/tag.go index 0fd3bf54d6..51e24fdf35 100644 --- a/datacatalog/pkg/repositories/gormimpl/tag.go +++ b/datacatalog/pkg/repositories/gormimpl/tag.go @@ -3,13 +3,13 @@ package gormimpl import ( "context" - idl_datacatalog "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" + "gorm.io/gorm" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/errors" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/interfaces" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/models" + idl_datacatalog "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" "github.com/flyteorg/flyte/flytestdlib/promutils" - "gorm.io/gorm" ) type tagRepo struct { diff --git a/datacatalog/pkg/repositories/gormimpl/tag_test.go b/datacatalog/pkg/repositories/gormimpl/tag_test.go index b8e73d5f4a..9619c8a473 100644 --- a/datacatalog/pkg/repositories/gormimpl/tag_test.go +++ b/datacatalog/pkg/repositories/gormimpl/tag_test.go @@ -1,28 +1,23 @@ package gormimpl import ( - "testing" - - "github.com/jackc/pgconn" - - "gorm.io/gorm" - "context" + "database/sql/driver" + "testing" mocket "github.com/Selvatico/go-mocket" + "github.com/jackc/pgconn" "github.com/stretchr/testify/assert" - - "database/sql/driver" + "google.golang.org/grpc/codes" + "gorm.io/gorm" datacatalog_error "github.com/flyteorg/flyte/datacatalog/pkg/errors" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/errors" - "github.com/flyteorg/flyte/datacatalog/pkg/repositories/models" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/utils" "github.com/flyteorg/flyte/flytestdlib/contextutils" "github.com/flyteorg/flyte/flytestdlib/promutils" "github.com/flyteorg/flyte/flytestdlib/promutils/labeled" - "google.golang.org/grpc/codes" ) func init() { diff --git a/datacatalog/pkg/repositories/handle.go b/datacatalog/pkg/repositories/handle.go index 540ba3c7a9..e552fb9d01 100644 --- a/datacatalog/pkg/repositories/handle.go +++ b/datacatalog/pkg/repositories/handle.go @@ -2,18 +2,16 @@ package repositories import ( "context" - - "gorm.io/driver/sqlite" - "fmt" - "github.com/flyteorg/flyte/flytestdlib/database" + "gorm.io/driver/sqlite" + "gorm.io/gorm" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/config" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/models" + "github.com/flyteorg/flyte/flytestdlib/database" "github.com/flyteorg/flyte/flytestdlib/logger" "github.com/flyteorg/flyte/flytestdlib/promutils" - "gorm.io/gorm" ) type DBHandle struct { diff --git a/datacatalog/pkg/repositories/handle_test.go b/datacatalog/pkg/repositories/handle_test.go index cda0822ac6..c762a569df 100644 --- a/datacatalog/pkg/repositories/handle_test.go +++ b/datacatalog/pkg/repositories/handle_test.go @@ -2,17 +2,16 @@ package repositories import ( "context" + "database/sql/driver" "path" "testing" mocket "github.com/Selvatico/go-mocket" - "github.com/flyteorg/flyte/datacatalog/pkg/repositories/config" - "github.com/flyteorg/flyte/flytestdlib/database" "github.com/stretchr/testify/assert" - "database/sql/driver" - + "github.com/flyteorg/flyte/datacatalog/pkg/repositories/config" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/utils" + "github.com/flyteorg/flyte/flytestdlib/database" ) func TestCreateDB(t *testing.T) { diff --git a/datacatalog/pkg/repositories/initialize.go b/datacatalog/pkg/repositories/initialize.go index b5bde058db..e020f5dc04 100644 --- a/datacatalog/pkg/repositories/initialize.go +++ b/datacatalog/pkg/repositories/initialize.go @@ -5,11 +5,12 @@ import ( "errors" "reflect" + "github.com/jackc/pgconn" + errors2 "github.com/flyteorg/flyte/datacatalog/pkg/repositories/errors" "github.com/flyteorg/flyte/datacatalog/pkg/runtime" "github.com/flyteorg/flyte/flytestdlib/logger" "github.com/flyteorg/flyte/flytestdlib/promutils" - "github.com/jackc/pgconn" ) var migrationsScope = promutils.NewScope("migrations") diff --git a/datacatalog/pkg/repositories/postgres_repo.go b/datacatalog/pkg/repositories/postgres_repo.go index a2a0330aea..abdebcb4a0 100644 --- a/datacatalog/pkg/repositories/postgres_repo.go +++ b/datacatalog/pkg/repositories/postgres_repo.go @@ -1,11 +1,12 @@ package repositories import ( + "gorm.io/gorm" + "github.com/flyteorg/flyte/datacatalog/pkg/repositories/errors" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/gormimpl" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/interfaces" "github.com/flyteorg/flyte/flytestdlib/promutils" - "gorm.io/gorm" ) type PostgresRepo struct { diff --git a/datacatalog/pkg/repositories/transformers/artifact.go b/datacatalog/pkg/repositories/transformers/artifact.go index 6eeb54568a..52eba4b8bd 100644 --- a/datacatalog/pkg/repositories/transformers/artifact.go +++ b/datacatalog/pkg/repositories/transformers/artifact.go @@ -1,11 +1,12 @@ package transformers import ( + "github.com/golang/protobuf/ptypes" + "google.golang.org/grpc/codes" + "github.com/flyteorg/flyte/datacatalog/pkg/errors" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/models" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" - "github.com/golang/protobuf/ptypes" - "google.golang.org/grpc/codes" ) func CreateArtifactModel(request *datacatalog.CreateArtifactRequest, artifactData []models.ArtifactData, dataset models.Dataset) (models.Artifact, error) { diff --git a/datacatalog/pkg/repositories/transformers/artifact_test.go b/datacatalog/pkg/repositories/transformers/artifact_test.go index 89463ecc00..633ec9175a 100644 --- a/datacatalog/pkg/repositories/transformers/artifact_test.go +++ b/datacatalog/pkg/repositories/transformers/artifact_test.go @@ -2,14 +2,14 @@ package transformers import ( "testing" - "time" + "github.com/golang/protobuf/ptypes" + "github.com/stretchr/testify/assert" + "github.com/flyteorg/flyte/datacatalog/pkg/repositories/models" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" - "github.com/golang/protobuf/ptypes" - "github.com/stretchr/testify/assert" ) func getTestArtifactData() []*datacatalog.ArtifactData { diff --git a/datacatalog/pkg/repositories/transformers/dataset_test.go b/datacatalog/pkg/repositories/transformers/dataset_test.go index 93f5509c2a..25062cf264 100644 --- a/datacatalog/pkg/repositories/transformers/dataset_test.go +++ b/datacatalog/pkg/repositories/transformers/dataset_test.go @@ -3,9 +3,10 @@ package transformers import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/flyteorg/flyte/datacatalog/pkg/repositories/models" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" - "github.com/stretchr/testify/assert" ) var metadata = &datacatalog.Metadata{ diff --git a/datacatalog/pkg/repositories/transformers/filters.go b/datacatalog/pkg/repositories/transformers/filters.go index bf14d715b2..c4ed8b6f08 100644 --- a/datacatalog/pkg/repositories/transformers/filters.go +++ b/datacatalog/pkg/repositories/transformers/filters.go @@ -4,7 +4,6 @@ import ( "context" "github.com/flyteorg/flyte/datacatalog/pkg/common" - "github.com/flyteorg/flyte/datacatalog/pkg/manager/impl/validators" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/gormimpl" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/models" diff --git a/datacatalog/pkg/repositories/transformers/filters_test.go b/datacatalog/pkg/repositories/transformers/filters_test.go index 0285b32f0c..91cdf518e4 100644 --- a/datacatalog/pkg/repositories/transformers/filters_test.go +++ b/datacatalog/pkg/repositories/transformers/filters_test.go @@ -4,10 +4,11 @@ import ( "context" "testing" + "github.com/stretchr/testify/assert" + "github.com/flyteorg/flyte/datacatalog/pkg/common" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/models" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" - "github.com/stretchr/testify/assert" ) func assertJoinExpression(t *testing.T, joinCondition models.ModelJoinCondition, sourceTableName string, joiningTableName string, joiningTableAlias string, expectedJoinStatement string) { diff --git a/datacatalog/pkg/repositories/transformers/pagination.go b/datacatalog/pkg/repositories/transformers/pagination.go index fb80857002..793779ab46 100644 --- a/datacatalog/pkg/repositories/transformers/pagination.go +++ b/datacatalog/pkg/repositories/transformers/pagination.go @@ -4,12 +4,13 @@ import ( "strconv" "strings" + "google.golang.org/grpc/codes" + "github.com/flyteorg/flyte/datacatalog/pkg/common" "github.com/flyteorg/flyte/datacatalog/pkg/errors" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/gormimpl" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/models" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" - "google.golang.org/grpc/codes" ) func ApplyPagination(paginationOpts *datacatalog.PaginationOptions, input *models.ListModelsInput) error { diff --git a/datacatalog/pkg/repositories/transformers/pagination_test.go b/datacatalog/pkg/repositories/transformers/pagination_test.go index 8ae86b1113..0a05766a9b 100644 --- a/datacatalog/pkg/repositories/transformers/pagination_test.go +++ b/datacatalog/pkg/repositories/transformers/pagination_test.go @@ -3,10 +3,11 @@ package transformers import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/flyteorg/flyte/datacatalog/pkg/common" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/models" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" - "github.com/stretchr/testify/assert" ) func TestPaginationDefaults(t *testing.T) { diff --git a/datacatalog/pkg/repositories/transformers/reservation.go b/datacatalog/pkg/repositories/transformers/reservation.go index d002b6650b..2ae215be82 100644 --- a/datacatalog/pkg/repositories/transformers/reservation.go +++ b/datacatalog/pkg/repositories/transformers/reservation.go @@ -3,13 +3,12 @@ package transformers import ( "time" + "github.com/golang/protobuf/ptypes" + "google.golang.org/grpc/codes" + "github.com/flyteorg/flyte/datacatalog/pkg/errors" "github.com/flyteorg/flyte/datacatalog/pkg/repositories/models" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" - - "github.com/golang/protobuf/ptypes" - - "google.golang.org/grpc/codes" ) func FromReservationID(reservationID *datacatalog.ReservationID) models.ReservationKey { diff --git a/datacatalog/pkg/repositories/transformers/reservation_test.go b/datacatalog/pkg/repositories/transformers/reservation_test.go index 49ebb574d2..95ca7795ce 100644 --- a/datacatalog/pkg/repositories/transformers/reservation_test.go +++ b/datacatalog/pkg/repositories/transformers/reservation_test.go @@ -4,9 +4,10 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" + "github.com/flyteorg/flyte/datacatalog/pkg/repositories/models" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" - "github.com/stretchr/testify/assert" ) func TestFromReservationID(t *testing.T) { diff --git a/datacatalog/pkg/repositories/transformers/tag_test.go b/datacatalog/pkg/repositories/transformers/tag_test.go index 899306e72c..c2820f6260 100644 --- a/datacatalog/pkg/repositories/transformers/tag_test.go +++ b/datacatalog/pkg/repositories/transformers/tag_test.go @@ -3,9 +3,10 @@ package transformers import ( "testing" + "github.com/stretchr/testify/assert" + "github.com/flyteorg/flyte/datacatalog/pkg/repositories/models" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" - "github.com/stretchr/testify/assert" ) func TestToTagKey(t *testing.T) { diff --git a/datacatalog/pkg/repositories/transformers/util.go b/datacatalog/pkg/repositories/transformers/util.go index 755ef02b72..6fddb9508a 100644 --- a/datacatalog/pkg/repositories/transformers/util.go +++ b/datacatalog/pkg/repositories/transformers/util.go @@ -1,10 +1,11 @@ package transformers import ( - "github.com/flyteorg/flyte/datacatalog/pkg/errors" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" "github.com/golang/protobuf/proto" "google.golang.org/grpc/codes" + + "github.com/flyteorg/flyte/datacatalog/pkg/errors" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/datacatalog" ) func marshalMetadata(metadata *datacatalog.Metadata) ([]byte, error) { diff --git a/datacatalog/pkg/runtime/application_config_provider.go b/datacatalog/pkg/runtime/application_config_provider.go index 7d0938912f..a1a64c4a0a 100644 --- a/datacatalog/pkg/runtime/application_config_provider.go +++ b/datacatalog/pkg/runtime/application_config_provider.go @@ -6,9 +6,8 @@ import ( "os" "strings" - "github.com/flyteorg/flyte/flytestdlib/config" - "github.com/flyteorg/flyte/datacatalog/pkg/runtime/configs" + "github.com/flyteorg/flyte/flytestdlib/config" "github.com/flyteorg/flyte/flytestdlib/database" "github.com/flyteorg/flyte/flytestdlib/logger" ) diff --git a/datacatalog/pull_request_template.md b/datacatalog/pull_request_template.md index 0907563271..9cdab99b46 100644 --- a/datacatalog/pull_request_template.md +++ b/datacatalog/pull_request_template.md @@ -1,6 +1,5 @@ ## _Read then delete this section_ - _- Make sure to use a concise title for the pull-request._ _- Use #patch, #minor or #major in the pull-request title to bump the corresponding version. Otherwise, the patch version diff --git a/flyteadmin/.golangci.yml b/flyteadmin/.golangci.yml index 3df02b549d..7135275462 100644 --- a/flyteadmin/.golangci.yml +++ b/flyteadmin/.golangci.yml @@ -10,6 +10,7 @@ linters: - deadcode - errcheck - gas + - gci - goconst - goimports - golint @@ -25,3 +26,13 @@ linters: - unparam - unused - varcheck + +linters-settings: + gci: + custom-order: true + sections: + - standard + - default + - prefix(github.com/flyteorg) + skip-generated: true + diff --git a/flyteadmin/auth/auth_context.go b/flyteadmin/auth/auth_context.go index 99eb7ef514..012fa36f41 100644 --- a/flyteadmin/auth/auth_context.go +++ b/flyteadmin/auth/auth_context.go @@ -10,15 +10,15 @@ import ( "strings" "time" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" - "github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/core" - "github.com/coreos/go-oidc" + "golang.org/x/oauth2" + "github.com/flyteorg/flyte/flyteadmin/auth/config" "github.com/flyteorg/flyte/flyteadmin/auth/interfaces" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" + "github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/core" "github.com/flyteorg/flyte/flytestdlib/errors" "github.com/flyteorg/flyte/flytestdlib/logger" - "golang.org/x/oauth2" ) const ( diff --git a/flyteadmin/auth/authzserver/authorize.go b/flyteadmin/auth/authzserver/authorize.go index d0e8ecbdb0..27f145e0df 100644 --- a/flyteadmin/auth/authzserver/authorize.go +++ b/flyteadmin/auth/authzserver/authorize.go @@ -6,9 +6,9 @@ import ( "net/http" "time" - "github.com/flyteorg/flyte/flyteadmin/auth" "github.com/ory/fosite" + "github.com/flyteorg/flyte/flyteadmin/auth" "github.com/flyteorg/flyte/flyteadmin/auth/interfaces" "github.com/flyteorg/flyte/flytestdlib/logger" ) diff --git a/flyteadmin/auth/authzserver/authorize_test.go b/flyteadmin/auth/authzserver/authorize_test.go index 08c5df2898..5377981a11 100644 --- a/flyteadmin/auth/authzserver/authorize_test.go +++ b/flyteadmin/auth/authzserver/authorize_test.go @@ -8,18 +8,14 @@ import ( "net/http/httptest" "testing" - config2 "github.com/flyteorg/flyte/flytestdlib/config" - - "github.com/flyteorg/flyte/flyteadmin/auth" + "github.com/ory/fosite" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" - "github.com/flyteorg/flyte/flyteadmin/auth/interfaces/mocks" - + "github.com/flyteorg/flyte/flyteadmin/auth" "github.com/flyteorg/flyte/flyteadmin/auth/config" - - "github.com/ory/fosite" - - "github.com/stretchr/testify/assert" + "github.com/flyteorg/flyte/flyteadmin/auth/interfaces/mocks" + config2 "github.com/flyteorg/flyte/flytestdlib/config" ) func TestAuthEndpoint(t *testing.T) { diff --git a/flyteadmin/auth/authzserver/initialize.go b/flyteadmin/auth/authzserver/initialize.go index 74417403ee..ef5a0d2ad4 100644 --- a/flyteadmin/auth/authzserver/initialize.go +++ b/flyteadmin/auth/authzserver/initialize.go @@ -3,14 +3,12 @@ package authzserver import ( "crypto/rsa" - "github.com/ory/fosite/handler/oauth2" - "github.com/ory/fosite" - - "github.com/flyteorg/flyte/flyteadmin/auth/interfaces" - "github.com/ory/fosite/compose" + "github.com/ory/fosite/handler/oauth2" "github.com/ory/fosite/token/jwt" + + "github.com/flyteorg/flyte/flyteadmin/auth/interfaces" ) // RegisterHandlers registers http endpoints for handling OAuth2 flow (/authorize, diff --git a/flyteadmin/auth/authzserver/initialize_test.go b/flyteadmin/auth/authzserver/initialize_test.go index e9dae7ba28..9f7ecb0491 100644 --- a/flyteadmin/auth/authzserver/initialize_test.go +++ b/flyteadmin/auth/authzserver/initialize_test.go @@ -3,10 +3,8 @@ package authzserver import ( "testing" - "github.com/ory/fosite/storage" - "github.com/ory/fosite/compose" - + "github.com/ory/fosite/storage" "github.com/stretchr/testify/mock" "github.com/flyteorg/flyte/flyteadmin/auth" diff --git a/flyteadmin/auth/authzserver/metadata.go b/flyteadmin/auth/authzserver/metadata.go index 043de89d87..4c701cfca8 100644 --- a/flyteadmin/auth/authzserver/metadata.go +++ b/flyteadmin/auth/authzserver/metadata.go @@ -7,14 +7,12 @@ import ( "fmt" "net/http" - "github.com/flyteorg/flyte/flyteadmin/auth" - "github.com/flyteorg/flyte/flyteadmin/auth/config" - "github.com/lestrrat-go/jwx/jwk" - "github.com/flyteorg/flyte/flytestdlib/logger" - + "github.com/flyteorg/flyte/flyteadmin/auth" + "github.com/flyteorg/flyte/flyteadmin/auth/config" "github.com/flyteorg/flyte/flyteadmin/auth/interfaces" + "github.com/flyteorg/flyte/flytestdlib/logger" ) var ( diff --git a/flyteadmin/auth/authzserver/metadata_provider.go b/flyteadmin/auth/authzserver/metadata_provider.go index 6752ecbcee..61802964c6 100644 --- a/flyteadmin/auth/authzserver/metadata_provider.go +++ b/flyteadmin/auth/authzserver/metadata_provider.go @@ -2,16 +2,22 @@ package authzserver import ( "context" + "errors" + "fmt" "io/ioutil" "net/http" "net/url" "strings" + "time" - "github.com/flyteorg/flyte/flyteadmin/auth" + "google.golang.org/grpc/codes" + "github.com/flyteorg/flyte/flyteadmin/auth" authConfig "github.com/flyteorg/flyte/flyteadmin/auth/config" - + "github.com/flyteorg/flyte/flyteadmin/pkg/async" + flyteErrors "github.com/flyteorg/flyte/flyteadmin/pkg/errors" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" + "github.com/flyteorg/flyte/flytestdlib/logger" ) type OAuth2MetadataProvider struct { @@ -73,10 +79,15 @@ func (s OAuth2MetadataProvider) GetOAuth2Metadata(ctx context.Context, r *servic } httpClient.Transport = transport } - - response, err := httpClient.Get(externalMetadataURL.String()) + logger.Printf(ctx, "retryAttempts: %v retryDuration: %v", s.cfg.AppAuth.ExternalAuthServer.RetryAttempts, s.cfg.AppAuth.ExternalAuthServer.RetryDelayMilliseconds) + response, err := sendAndRetryHttpRequest(httpClient, externalMetadataURL.String(), s.cfg.AppAuth.ExternalAuthServer.RetryAttempts, s.cfg.AppAuth.ExternalAuthServer.RetryDelayMilliseconds.Duration) if err != nil { - return nil, err + if response != nil { + logger.Errorf(ctx, "Failed to get oauth metadata. Error code: %v. Err: %v", response.StatusCode, err) + return nil, flyteErrors.NewFlyteAdminError(codes.Code(response.StatusCode), "Failed to get oauth metadata.") + } + logger.Errorf(ctx, "Failed to get oauth metadata. Err: %v", err) + return nil, flyteErrors.NewFlyteAdminError(codes.Code(500), "Failed to get oauth metadata.") } raw, err := ioutil.ReadAll(response.Body) @@ -109,3 +120,29 @@ func NewService(config *authConfig.Config) OAuth2MetadataProvider { cfg: config, } } + +func sendAndRetryHttpRequest(client *http.Client, url string, retryAttempts int, retryDelay time.Duration) (*http.Response, error) { + var response *http.Response + var err error + err = async.RetryOnSpecificErrorCodes(retryAttempts, retryDelay, func() (*http.Response, error) { + response, err = client.Get(url) + return response, err + }, isTransientErrorCode) + + if err != nil { + return nil, err + } + + if response.StatusCode != http.StatusOK { + return response, errors.New(fmt.Sprint("Failed to get oauth metadata")) + } + + return response, nil +} + +func isTransientErrorCode(resp *http.Response) bool { + if resp.StatusCode >= 500 && resp.StatusCode <= 599 { + return true + } + return false +} diff --git a/flyteadmin/auth/authzserver/metadata_provider_test.go b/flyteadmin/auth/authzserver/metadata_provider_test.go index 79bcc7b727..1ed8b0b56a 100644 --- a/flyteadmin/auth/authzserver/metadata_provider_test.go +++ b/flyteadmin/auth/authzserver/metadata_provider_test.go @@ -8,14 +8,16 @@ import ( "strings" "testing" - config2 "github.com/flyteorg/flyte/flytestdlib/config" + "github.com/stretchr/testify/assert" "github.com/flyteorg/flyte/flyteadmin/auth/config" authConfig "github.com/flyteorg/flyte/flyteadmin/auth/config" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" - "github.com/stretchr/testify/assert" + config2 "github.com/flyteorg/flyte/flytestdlib/config" ) +var oauthMetadataFailureErrorMessage = "Failed to get oauth metadata" + func TestOAuth2MetadataProvider_FlyteClient(t *testing.T) { provider := NewService(&authConfig.Config{ AppAuth: authConfig.OAuth2Options{ @@ -111,3 +113,29 @@ func TestOAuth2MetadataProvider_OAuth2Metadata(t *testing.T) { assert.Equal(t, "https://dev-14186422.okta.com", resp.Issuer) }) } + +func TestSendAndRetryHttpRequest(t *testing.T) { + hf := func(w http.ResponseWriter, r *http.Request) { + switch strings.TrimSpace(r.URL.Path) { + case "/": + mockExternalMetadataEndpointTransientFailure(w, r) + default: + http.NotFoundHandler().ServeHTTP(w, r) + } + + } + + server := httptest.NewServer(http.HandlerFunc(hf)) + defer server.Close() + http.DefaultClient = server.Client() + + resp, err := sendAndRetryHttpRequest(server.Client(), server.URL, 5, 0) + assert.Error(t, err) + assert.Equal(t, oauthMetadataFailureErrorMessage, err.Error()) + assert.NotNil(t, resp) + assert.Equal(t, 500, resp.StatusCode) +} + +func mockExternalMetadataEndpointTransientFailure(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(500) +} diff --git a/flyteadmin/auth/authzserver/metadata_test.go b/flyteadmin/auth/authzserver/metadata_test.go index 8b32559a9f..8da8057974 100644 --- a/flyteadmin/auth/authzserver/metadata_test.go +++ b/flyteadmin/auth/authzserver/metadata_test.go @@ -7,12 +7,11 @@ import ( "net/http/httptest" "testing" - "github.com/flyteorg/flyte/flyteadmin/auth/interfaces/mocks" "github.com/lestrrat-go/jwx/jwk" + "github.com/stretchr/testify/assert" "github.com/flyteorg/flyte/flyteadmin/auth" - - "github.com/stretchr/testify/assert" + "github.com/flyteorg/flyte/flyteadmin/auth/interfaces/mocks" ) func Test_newJSONWebKeySet(t *testing.T) { diff --git a/flyteadmin/auth/authzserver/provider.go b/flyteadmin/auth/authzserver/provider.go index ab6a91becd..be33ac28f4 100644 --- a/flyteadmin/auth/authzserver/provider.go +++ b/flyteadmin/auth/authzserver/provider.go @@ -9,27 +9,21 @@ import ( "fmt" "time" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" - "github.com/flyteorg/flyte/flytestdlib/logger" - - "k8s.io/apimachinery/pkg/util/sets" - - "github.com/lestrrat-go/jwx/jwk" - - "github.com/flyteorg/flyte/flyteadmin/auth/interfaces" - - "github.com/flyteorg/flyte/flyteadmin/auth" - "github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/core" - jwtgo "github.com/golang-jwt/jwt/v4" + "github.com/lestrrat-go/jwx/jwk" + "github.com/ory/fosite" + "github.com/ory/fosite/compose" fositeOAuth2 "github.com/ory/fosite/handler/oauth2" + "github.com/ory/fosite/storage" "github.com/ory/fosite/token/jwt" + "k8s.io/apimachinery/pkg/util/sets" + "github.com/flyteorg/flyte/flyteadmin/auth" "github.com/flyteorg/flyte/flyteadmin/auth/config" - - "github.com/ory/fosite" - "github.com/ory/fosite/compose" - "github.com/ory/fosite/storage" + "github.com/flyteorg/flyte/flyteadmin/auth/interfaces" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" + "github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/core" + "github.com/flyteorg/flyte/flytestdlib/logger" ) const ( diff --git a/flyteadmin/auth/authzserver/provider_test.go b/flyteadmin/auth/authzserver/provider_test.go index b3892e7fed..4659e603a4 100644 --- a/flyteadmin/auth/authzserver/provider_test.go +++ b/flyteadmin/auth/authzserver/provider_test.go @@ -12,13 +12,11 @@ import ( "time" jwtgo "github.com/golang-jwt/jwt/v4" - - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" - "github.com/stretchr/testify/assert" "github.com/flyteorg/flyte/flyteadmin/auth" "github.com/flyteorg/flyte/flyteadmin/auth/config" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" "github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/core/mocks" ) diff --git a/flyteadmin/auth/authzserver/resource_server.go b/flyteadmin/auth/authzserver/resource_server.go index c7db85c949..325923af1e 100644 --- a/flyteadmin/auth/authzserver/resource_server.go +++ b/flyteadmin/auth/authzserver/resource_server.go @@ -10,17 +10,15 @@ import ( "net/url" "strings" + "github.com/coreos/go-oidc" jwtgo "github.com/golang-jwt/jwt/v4" - + "golang.org/x/oauth2" "k8s.io/apimachinery/pkg/util/sets" - "github.com/flyteorg/flyte/flytestdlib/config" - - "github.com/coreos/go-oidc" authConfig "github.com/flyteorg/flyte/flyteadmin/auth/config" "github.com/flyteorg/flyte/flyteadmin/auth/interfaces" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" - "golang.org/x/oauth2" + "github.com/flyteorg/flyte/flytestdlib/config" ) // External auth server implementation diff --git a/flyteadmin/auth/authzserver/resource_server_test.go b/flyteadmin/auth/authzserver/resource_server_test.go index b3adfab931..611ea5f4d9 100644 --- a/flyteadmin/auth/authzserver/resource_server_test.go +++ b/flyteadmin/auth/authzserver/resource_server_test.go @@ -14,13 +14,11 @@ import ( "testing" "time" + "github.com/coreos/go-oidc" "github.com/golang-jwt/jwt/v4" - - "github.com/stretchr/testify/assert" - "github.com/lestrrat-go/jwx/jwk" + "github.com/stretchr/testify/assert" - "github.com/coreos/go-oidc" "github.com/flyteorg/flyte/flyteadmin/auth/config" authConfig "github.com/flyteorg/flyte/flyteadmin/auth/config" stdlibConfig "github.com/flyteorg/flyte/flytestdlib/config" diff --git a/flyteadmin/auth/authzserver/stateless_token_store.go b/flyteadmin/auth/authzserver/stateless_token_store.go index 9b53618a80..837d9ab50a 100644 --- a/flyteadmin/auth/authzserver/stateless_token_store.go +++ b/flyteadmin/auth/authzserver/stateless_token_store.go @@ -8,17 +8,15 @@ import ( "strings" "time" - "github.com/flyteorg/flyte/flyteadmin/auth" - - "github.com/flyteorg/flyte/flyteadmin/auth/config" - "k8s.io/apimachinery/pkg/util/sets" - + "github.com/ory/fosite" "github.com/ory/fosite/handler/oauth2" oauth22 "github.com/ory/fosite/handler/oauth2" + "github.com/ory/fosite/storage" "github.com/ory/fosite/token/jwt" + "k8s.io/apimachinery/pkg/util/sets" - "github.com/ory/fosite" - "github.com/ory/fosite/storage" + "github.com/flyteorg/flyte/flyteadmin/auth" + "github.com/flyteorg/flyte/flyteadmin/auth/config" ) const ( diff --git a/flyteadmin/auth/authzserver/token.go b/flyteadmin/auth/authzserver/token.go index 9a12891ac5..c36e8cef49 100644 --- a/flyteadmin/auth/authzserver/token.go +++ b/flyteadmin/auth/authzserver/token.go @@ -7,9 +7,8 @@ import ( "github.com/ory/fosite" - "github.com/flyteorg/flyte/flytestdlib/logger" - "github.com/flyteorg/flyte/flyteadmin/auth/interfaces" + "github.com/flyteorg/flyte/flytestdlib/logger" ) var ( diff --git a/flyteadmin/auth/authzserver/token_test.go b/flyteadmin/auth/authzserver/token_test.go index f8f5185c82..14f7ffba27 100644 --- a/flyteadmin/auth/authzserver/token_test.go +++ b/flyteadmin/auth/authzserver/token_test.go @@ -14,11 +14,9 @@ import ( "time" jwtgo "github.com/golang-jwt/jwt/v4" - - "github.com/flyteorg/flyte/flyteadmin/auth/config" - "github.com/stretchr/testify/assert" + "github.com/flyteorg/flyte/flyteadmin/auth/config" "github.com/flyteorg/flyte/flyteadmin/auth/interfaces/mocks" ) diff --git a/flyteadmin/auth/authzserver/utils.go b/flyteadmin/auth/authzserver/utils.go index 03ebbb38fd..a06501c5b5 100644 --- a/flyteadmin/auth/authzserver/utils.go +++ b/flyteadmin/auth/authzserver/utils.go @@ -5,10 +5,11 @@ import ( "encoding/base64" "net/http" - "github.com/flyteorg/flyte/flyteadmin/auth" - "github.com/flyteorg/flyte/flyteadmin/auth/config" "github.com/gtank/cryptopasta" "github.com/ory/fosite" + + "github.com/flyteorg/flyte/flyteadmin/auth" + "github.com/flyteorg/flyte/flyteadmin/auth/config" ) func interfaceSliceToStringSlice(raw []interface{}) []string { diff --git a/flyteadmin/auth/config/config.go b/flyteadmin/auth/config/config.go index 217983683e..8ba4f7aca6 100644 --- a/flyteadmin/auth/config/config.go +++ b/flyteadmin/auth/config/config.go @@ -79,6 +79,10 @@ var ( }, }, AppAuth: OAuth2Options{ + ExternalAuthServer: ExternalAuthorizationServer{ + RetryAttempts: 5, + RetryDelayMilliseconds: config.Duration{Duration: 1000 * time.Millisecond}, + }, AuthServerType: AuthorizationServerTypeSelf, ThirdParty: ThirdPartyConfigOptions{ FlyteClientConfig: FlyteClientConfig{ @@ -191,7 +195,9 @@ type ExternalAuthorizationServer struct { AllowedAudience []string `json:"allowedAudience" pflag:",Optional: A list of allowed audiences. If not provided, the audience is expected to be the public Uri of the service."` MetadataEndpointURL config.URL `json:"metadataUrl" pflag:",Optional: If the server doesn't support /.well-known/oauth-authorization-server, you can set a custom metadata url here.'"` // HTTPProxyURL allows operators to access external OAuth2 servers using an external HTTP Proxy - HTTPProxyURL config.URL `json:"httpProxyURL" pflag:",OPTIONAL: HTTP Proxy to be used for OAuth requests."` + HTTPProxyURL config.URL `json:"httpProxyURL" pflag:",OPTIONAL: HTTP Proxy to be used for OAuth requests."` + RetryAttempts int `json:"retryAttempts" pflag:", Optional: The number of attempted retries on a transient failure to get the OAuth metadata"` + RetryDelayMilliseconds config.Duration `json:"retryDelayMilliseconds" pflag:", Optional, Duration in milliseconds to wait between retries"` } // OAuth2Options defines settings for app auth. diff --git a/flyteadmin/auth/config/config_flags.go b/flyteadmin/auth/config/config_flags.go index 225e8a5c9d..a1cb45b501 100755 --- a/flyteadmin/auth/config/config_flags.go +++ b/flyteadmin/auth/config/config_flags.go @@ -77,6 +77,8 @@ func (cfg Config) GetPFlagSet(prefix string) *pflag.FlagSet { cmdFlags.StringSlice(fmt.Sprintf("%v%v", prefix, "appAuth.externalAuthServer.allowedAudience"), DefaultConfig.AppAuth.ExternalAuthServer.AllowedAudience, "Optional: A list of allowed audiences. If not provided, the audience is expected to be the public Uri of the service.") cmdFlags.String(fmt.Sprintf("%v%v", prefix, "appAuth.externalAuthServer.metadataUrl"), DefaultConfig.AppAuth.ExternalAuthServer.MetadataEndpointURL.String(), "Optional: If the server doesn't support /.well-known/oauth-authorization-server, you can set a custom metadata url here.'") cmdFlags.String(fmt.Sprintf("%v%v", prefix, "appAuth.externalAuthServer.httpProxyURL"), DefaultConfig.AppAuth.ExternalAuthServer.HTTPProxyURL.String(), "OPTIONAL: HTTP Proxy to be used for OAuth requests.") + cmdFlags.Int(fmt.Sprintf("%v%v", prefix, "appAuth.externalAuthServer.retryAttempts"), DefaultConfig.AppAuth.ExternalAuthServer.RetryAttempts, " Optional: The number of attempted retries on a transient failure to get the OAuth metadata") + cmdFlags.String(fmt.Sprintf("%v%v", prefix, "appAuth.externalAuthServer.retryDelayMilliseconds"), DefaultConfig.AppAuth.ExternalAuthServer.RetryDelayMilliseconds.String(), " Optional, Duration in milliseconds to wait between retries") cmdFlags.String(fmt.Sprintf("%v%v", prefix, "appAuth.thirdPartyConfig.flyteClient.clientId"), DefaultConfig.AppAuth.ThirdParty.FlyteClientConfig.ClientID, "public identifier for the app which handles authorization for a Flyte deployment") cmdFlags.String(fmt.Sprintf("%v%v", prefix, "appAuth.thirdPartyConfig.flyteClient.redirectUri"), DefaultConfig.AppAuth.ThirdParty.FlyteClientConfig.RedirectURI, "This is the callback uri registered with the app which handles authorization for a Flyte deployment") cmdFlags.StringSlice(fmt.Sprintf("%v%v", prefix, "appAuth.thirdPartyConfig.flyteClient.scopes"), DefaultConfig.AppAuth.ThirdParty.FlyteClientConfig.Scopes, "Recommended scopes for the client to request.") diff --git a/flyteadmin/auth/config/config_flags_test.go b/flyteadmin/auth/config/config_flags_test.go index 28efafc380..3145c826f2 100755 --- a/flyteadmin/auth/config/config_flags_test.go +++ b/flyteadmin/auth/config/config_flags_test.go @@ -477,6 +477,34 @@ func TestConfig_SetFlags(t *testing.T) { } }) }) + t.Run("Test_appAuth.externalAuthServer.retryAttempts", func(t *testing.T) { + + t.Run("Override", func(t *testing.T) { + testValue := "1" + + cmdFlags.Set("appAuth.externalAuthServer.retryAttempts", testValue) + if vInt, err := cmdFlags.GetInt("appAuth.externalAuthServer.retryAttempts"); err == nil { + testDecodeJson_Config(t, fmt.Sprintf("%v", vInt), &actual.AppAuth.ExternalAuthServer.RetryAttempts) + + } else { + assert.FailNow(t, err.Error()) + } + }) + }) + t.Run("Test_appAuth.externalAuthServer.retryDelayMilliseconds", func(t *testing.T) { + + t.Run("Override", func(t *testing.T) { + testValue := DefaultConfig.AppAuth.ExternalAuthServer.RetryDelayMilliseconds.String() + + cmdFlags.Set("appAuth.externalAuthServer.retryDelayMilliseconds", testValue) + if vString, err := cmdFlags.GetString("appAuth.externalAuthServer.retryDelayMilliseconds"); err == nil { + testDecodeJson_Config(t, fmt.Sprintf("%v", vString), &actual.AppAuth.ExternalAuthServer.RetryDelayMilliseconds) + + } else { + assert.FailNow(t, err.Error()) + } + }) + }) t.Run("Test_appAuth.thirdPartyConfig.flyteClient.clientId", func(t *testing.T) { t.Run("Override", func(t *testing.T) { diff --git a/flyteadmin/auth/config/config_test.go b/flyteadmin/auth/config/config_test.go index 381d28d1bc..fa06506ee5 100644 --- a/flyteadmin/auth/config/config_test.go +++ b/flyteadmin/auth/config/config_test.go @@ -6,15 +6,13 @@ import ( "path/filepath" "testing" - "github.com/flyteorg/flyte/flytestdlib/logger" - - "github.com/flyteorg/flyte/flytestdlib/config" - "github.com/flyteorg/flyte/flytestdlib/config/viper" - "github.com/ghodss/yaml" + "github.com/ory/fosite" "github.com/stretchr/testify/assert" - "github.com/ory/fosite" + "github.com/flyteorg/flyte/flytestdlib/config" + "github.com/flyteorg/flyte/flytestdlib/config/viper" + "github.com/flyteorg/flyte/flytestdlib/logger" ) func TestHashFlyteClientSecret(t *testing.T) { diff --git a/flyteadmin/auth/cookie.go b/flyteadmin/auth/cookie.go index 96034642ff..bf80c1f920 100644 --- a/flyteadmin/auth/cookie.go +++ b/flyteadmin/auth/cookie.go @@ -9,11 +9,11 @@ import ( "net/url" "time" - "github.com/flyteorg/flyte/flytestdlib/errors" - "github.com/flyteorg/flyte/flytestdlib/logger" "github.com/gorilla/securecookie" "github.com/flyteorg/flyte/flyteadmin/auth/interfaces" + "github.com/flyteorg/flyte/flytestdlib/errors" + "github.com/flyteorg/flyte/flytestdlib/logger" ) const ( diff --git a/flyteadmin/auth/cookie_manager.go b/flyteadmin/auth/cookie_manager.go index 1ab5fbcfca..9bc64b88cf 100644 --- a/flyteadmin/auth/cookie_manager.go +++ b/flyteadmin/auth/cookie_manager.go @@ -8,12 +8,12 @@ import ( "net/http" "time" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" - "github.com/flyteorg/flyte/flytestdlib/errors" - "github.com/flyteorg/flyte/flytestdlib/logger" "golang.org/x/oauth2" "github.com/flyteorg/flyte/flyteadmin/auth/config" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" + "github.com/flyteorg/flyte/flytestdlib/errors" + "github.com/flyteorg/flyte/flytestdlib/logger" ) type CookieManager struct { diff --git a/flyteadmin/auth/cookie_manager_test.go b/flyteadmin/auth/cookie_manager_test.go index e36bb61671..6dd67a0473 100644 --- a/flyteadmin/auth/cookie_manager_test.go +++ b/flyteadmin/auth/cookie_manager_test.go @@ -10,13 +10,12 @@ import ( "testing" "time" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "golang.org/x/oauth2" "github.com/flyteorg/flyte/flyteadmin/auth/config" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" ) func TestCookieManager(t *testing.T) { diff --git a/flyteadmin/auth/cookie_test.go b/flyteadmin/auth/cookie_test.go index f4cab8fd76..a5c58ad2ff 100644 --- a/flyteadmin/auth/cookie_test.go +++ b/flyteadmin/auth/cookie_test.go @@ -9,11 +9,12 @@ import ( "net/url" "testing" + "github.com/gorilla/securecookie" + "github.com/stretchr/testify/assert" + "github.com/flyteorg/flyte/flyteadmin/auth/config" "github.com/flyteorg/flyte/flyteadmin/auth/interfaces/mocks" stdConfig "github.com/flyteorg/flyte/flytestdlib/config" - "github.com/gorilla/securecookie" - "github.com/stretchr/testify/assert" ) func mustParseURL(t testing.TB, u string) url.URL { diff --git a/flyteadmin/auth/create_secrets.go b/flyteadmin/auth/create_secrets.go index 2f831571aa..26c0af8300 100644 --- a/flyteadmin/auth/create_secrets.go +++ b/flyteadmin/auth/create_secrets.go @@ -8,24 +8,21 @@ import ( "path/filepath" "strings" - "k8s.io/client-go/rest" - - "github.com/flyteorg/flyte/flytestdlib/logger" - kubeErrors "k8s.io/apimachinery/pkg/api/errors" - + "github.com/spf13/cobra" + "github.com/spf13/pflag" corev1 "k8s.io/api/core/v1" + kubeErrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/kubernetes" + "k8s.io/client-go/rest" "github.com/flyteorg/flyte/flyteadmin/pkg/config" executioncluster "github.com/flyteorg/flyte/flyteadmin/pkg/executioncluster/impl" "github.com/flyteorg/flyte/flyteadmin/pkg/executioncluster/interfaces" "github.com/flyteorg/flyte/flyteadmin/pkg/runtime" "github.com/flyteorg/flyte/flytestdlib/errors" + "github.com/flyteorg/flyte/flytestdlib/logger" "github.com/flyteorg/flyte/flytestdlib/promutils" - - "github.com/spf13/cobra" - "github.com/spf13/pflag" - "k8s.io/client-go/kubernetes" ) const ( diff --git a/flyteadmin/auth/handler_utils.go b/flyteadmin/auth/handler_utils.go index 18a9d781dd..e6fd1a7236 100644 --- a/flyteadmin/auth/handler_utils.go +++ b/flyteadmin/auth/handler_utils.go @@ -5,9 +5,9 @@ import ( "net/http" "net/url" - "github.com/flyteorg/flyte/flyteadmin/auth/config" - "github.com/grpc-ecosystem/go-grpc-middleware/util/metautils" + + "github.com/flyteorg/flyte/flyteadmin/auth/config" ) const ( diff --git a/flyteadmin/auth/handler_utils_test.go b/flyteadmin/auth/handler_utils_test.go index fe5c9db135..441f83dbbb 100644 --- a/flyteadmin/auth/handler_utils_test.go +++ b/flyteadmin/auth/handler_utils_test.go @@ -3,13 +3,12 @@ package auth import ( "context" "net/http" - "testing" - config2 "github.com/flyteorg/flyte/flytestdlib/config" + "github.com/stretchr/testify/assert" "github.com/flyteorg/flyte/flyteadmin/auth/config" - "github.com/stretchr/testify/assert" + config2 "github.com/flyteorg/flyte/flytestdlib/config" ) func TestGetPublicURL(t *testing.T) { diff --git a/flyteadmin/auth/handlers.go b/flyteadmin/auth/handlers.go index a5bacdc06e..26e6428df3 100644 --- a/flyteadmin/auth/handlers.go +++ b/flyteadmin/auth/handlers.go @@ -8,9 +8,6 @@ import ( "strings" "time" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" - "github.com/flyteorg/flyte/flytestdlib/errors" - "github.com/flyteorg/flyte/flytestdlib/logger" "github.com/grpc-ecosystem/go-grpc-middleware/util/metautils" "golang.org/x/oauth2" "google.golang.org/grpc" @@ -23,6 +20,9 @@ import ( "github.com/flyteorg/flyte/flyteadmin/auth/interfaces" "github.com/flyteorg/flyte/flyteadmin/pkg/common" "github.com/flyteorg/flyte/flyteadmin/plugins" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" + "github.com/flyteorg/flyte/flytestdlib/errors" + "github.com/flyteorg/flyte/flytestdlib/logger" ) const ( diff --git a/flyteadmin/auth/handlers_test.go b/flyteadmin/auth/handlers_test.go index 63facc8bfa..4b4471ad7b 100644 --- a/flyteadmin/auth/handlers_test.go +++ b/flyteadmin/auth/handlers_test.go @@ -12,8 +12,6 @@ import ( "testing" "github.com/coreos/go-oidc" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" - stdConfig "github.com/flyteorg/flyte/flytestdlib/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" @@ -25,6 +23,8 @@ import ( "github.com/flyteorg/flyte/flyteadmin/auth/interfaces/mocks" "github.com/flyteorg/flyte/flyteadmin/pkg/common" "github.com/flyteorg/flyte/flyteadmin/plugins" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" + stdConfig "github.com/flyteorg/flyte/flytestdlib/config" ) const ( diff --git a/flyteadmin/auth/identity_context.go b/flyteadmin/auth/identity_context.go index 4da330e101..05889f7537 100644 --- a/flyteadmin/auth/identity_context.go +++ b/flyteadmin/auth/identity_context.go @@ -5,11 +5,10 @@ import ( "fmt" "time" - "github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/utils" + "k8s.io/apimachinery/pkg/util/sets" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" - - "k8s.io/apimachinery/pkg/util/sets" + "github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/utils" ) var ( diff --git a/flyteadmin/auth/init_secrets.go b/flyteadmin/auth/init_secrets.go index 0cccf74cc9..6e3d4a3078 100644 --- a/flyteadmin/auth/init_secrets.go +++ b/flyteadmin/auth/init_secrets.go @@ -12,11 +12,10 @@ import ( "os" "path/filepath" - "github.com/flyteorg/flyte/flyteadmin/auth/config" + "github.com/spf13/cobra" + "github.com/flyteorg/flyte/flyteadmin/auth/config" "github.com/flyteorg/flyte/flytestdlib/logger" - - "github.com/spf13/cobra" ) const ( diff --git a/flyteadmin/auth/interceptor.go b/flyteadmin/auth/interceptor.go index c347dd63c4..499d79d195 100644 --- a/flyteadmin/auth/interceptor.go +++ b/flyteadmin/auth/interceptor.go @@ -3,10 +3,11 @@ package auth import ( "context" - "github.com/flyteorg/flyte/flytestdlib/logger" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + + "github.com/flyteorg/flyte/flytestdlib/logger" ) func BlanketAuthorization(ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) ( diff --git a/flyteadmin/auth/interfaces/context.go b/flyteadmin/auth/interfaces/context.go index 7b73c56d21..1eff82faa7 100644 --- a/flyteadmin/auth/interfaces/context.go +++ b/flyteadmin/auth/interfaces/context.go @@ -6,18 +6,15 @@ import ( "net/url" "time" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" - - "k8s.io/apimachinery/pkg/util/sets" - + "github.com/coreos/go-oidc" "github.com/lestrrat-go/jwx/jwk" - "github.com/ory/fosite" fositeOAuth2 "github.com/ory/fosite/handler/oauth2" + "golang.org/x/oauth2" + "k8s.io/apimachinery/pkg/util/sets" - "github.com/coreos/go-oidc" "github.com/flyteorg/flyte/flyteadmin/auth/config" - "golang.org/x/oauth2" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" ) //go:generate mockery -all -case=underscore diff --git a/flyteadmin/auth/interfaces/cookie.go b/flyteadmin/auth/interfaces/cookie.go index 272fab8d6a..8896e4c329 100644 --- a/flyteadmin/auth/interfaces/cookie.go +++ b/flyteadmin/auth/interfaces/cookie.go @@ -4,9 +4,9 @@ import ( "context" "net/http" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" - "golang.org/x/oauth2" + + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" ) //go:generate mockery -name=CookieHandler -output=mocks/ -case=underscore diff --git a/flyteadmin/auth/token.go b/flyteadmin/auth/token.go index e864c96123..9b90a2d108 100644 --- a/flyteadmin/auth/token.go +++ b/flyteadmin/auth/token.go @@ -6,19 +6,16 @@ import ( "strings" "time" + "github.com/coreos/go-oidc" + grpcauth "github.com/grpc-ecosystem/go-grpc-middleware/auth" "github.com/grpc-ecosystem/go-grpc-middleware/util/metautils" - - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" - + "golang.org/x/oauth2" "k8s.io/apimachinery/pkg/util/sets" "github.com/flyteorg/flyte/flyteadmin/auth/interfaces" - - "github.com/coreos/go-oidc" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" "github.com/flyteorg/flyte/flytestdlib/errors" "github.com/flyteorg/flyte/flytestdlib/logger" - grpcauth "github.com/grpc-ecosystem/go-grpc-middleware/auth" - "golang.org/x/oauth2" ) const ( diff --git a/flyteadmin/boilerplate/flyte/golang_support_tools/tools.go b/flyteadmin/boilerplate/flyte/golang_support_tools/tools.go index a78b61162a..6c3da04107 100644 --- a/flyteadmin/boilerplate/flyte/golang_support_tools/tools.go +++ b/flyteadmin/boilerplate/flyte/golang_support_tools/tools.go @@ -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" ) diff --git a/flyteadmin/boilerplate/flyte/golang_test_targets/download_tooling.sh b/flyteadmin/boilerplate/flyte/golang_test_targets/download_tooling.sh index c7e5577ef3..9cd49959f4 100755 --- a/flyteadmin/boilerplate/flyte/golang_test_targets/download_tooling.sh +++ b/flyteadmin/boilerplate/flyte/golang_test_targets/download_tooling.sh @@ -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" ) diff --git a/flyteadmin/boilerplate/flyte/golang_test_targets/goimports b/flyteadmin/boilerplate/flyte/golang_test_targets/goimports index af1829036c..40f50d106e 100755 --- a/flyteadmin/boilerplate/flyte/golang_test_targets/goimports +++ b/flyteadmin/boilerplate/flyte/golang_test_targets/goimports @@ -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 . diff --git a/flyteadmin/boilerplate/flyte/golangci_file/.golangci.yml b/flyteadmin/boilerplate/flyte/golangci_file/.golangci.yml index 5d53f35295..7f4dbc80e8 100644 --- a/flyteadmin/boilerplate/flyte/golangci_file/.golangci.yml +++ b/flyteadmin/boilerplate/flyte/golangci_file/.golangci.yml @@ -13,6 +13,7 @@ linters: - deadcode - errcheck - gas + - gci - goconst - goimports - golint @@ -28,3 +29,12 @@ linters: - unparam - unused - varcheck + +linters-settings: + gci: + custom-order: true + sections: + - standard + - default + - prefix(github.com/flyteorg) + skip-generated: true diff --git a/flyteadmin/cmd/entrypoints/clusterresource.go b/flyteadmin/cmd/entrypoints/clusterresource.go index fa38491b62..bb47d8775f 100644 --- a/flyteadmin/cmd/entrypoints/clusterresource.go +++ b/flyteadmin/cmd/entrypoints/clusterresource.go @@ -4,15 +4,13 @@ import ( "context" errors2 "github.com/pkg/errors" - - "github.com/flyteorg/flyte/flytestdlib/promutils" + "github.com/spf13/cobra" + _ "gorm.io/driver/postgres" // Required to import database driver. "github.com/flyteorg/flyte/flyteadmin/pkg/clusterresource" "github.com/flyteorg/flyte/flyteadmin/pkg/runtime" "github.com/flyteorg/flyte/flytestdlib/logger" - - "github.com/spf13/cobra" - _ "gorm.io/driver/postgres" // Required to import database driver. + "github.com/flyteorg/flyte/flytestdlib/promutils" ) var parentClusterResourceCmd = &cobra.Command{ diff --git a/flyteadmin/cmd/entrypoints/k8s_secret.go b/flyteadmin/cmd/entrypoints/k8s_secret.go index 7a24f70dba..8bd14ab78e 100644 --- a/flyteadmin/cmd/entrypoints/k8s_secret.go +++ b/flyteadmin/cmd/entrypoints/k8s_secret.go @@ -1,8 +1,9 @@ package entrypoints import ( - "github.com/flyteorg/flyte/flyteadmin/auth" "github.com/spf13/cobra" + + "github.com/flyteorg/flyte/flyteadmin/auth" ) var secretsCmd = &cobra.Command{ diff --git a/flyteadmin/cmd/entrypoints/migrate.go b/flyteadmin/cmd/entrypoints/migrate.go index bb0d79788b..c7ad6058c5 100644 --- a/flyteadmin/cmd/entrypoints/migrate.go +++ b/flyteadmin/cmd/entrypoints/migrate.go @@ -3,10 +3,10 @@ package entrypoints import ( "context" - "github.com/flyteorg/flyte/flyteadmin/pkg/server" - "github.com/spf13/cobra" _ "gorm.io/driver/postgres" // Required to import database driver. + + "github.com/flyteorg/flyte/flyteadmin/pkg/server" ) var parentMigrateCmd = &cobra.Command{ diff --git a/flyteadmin/cmd/entrypoints/root.go b/flyteadmin/cmd/entrypoints/root.go index 04775b47ee..5f493d0bbc 100644 --- a/flyteadmin/cmd/entrypoints/root.go +++ b/flyteadmin/cmd/entrypoints/root.go @@ -6,14 +6,13 @@ import ( "fmt" "os" - "github.com/flyteorg/flyte/flyteadmin/plugins" - - "github.com/flyteorg/flyte/flytestdlib/logger" + "github.com/spf13/cobra" + "github.com/spf13/pflag" + "github.com/flyteorg/flyte/flyteadmin/plugins" "github.com/flyteorg/flyte/flytestdlib/config" "github.com/flyteorg/flyte/flytestdlib/config/viper" - "github.com/spf13/cobra" - "github.com/spf13/pflag" + "github.com/flyteorg/flyte/flytestdlib/logger" ) var ( diff --git a/flyteadmin/cmd/entrypoints/serve.go b/flyteadmin/cmd/entrypoints/serve.go index 56eb4483e9..680795c28f 100644 --- a/flyteadmin/cmd/entrypoints/serve.go +++ b/flyteadmin/cmd/entrypoints/serve.go @@ -2,19 +2,15 @@ package entrypoints import ( "context" - - "github.com/flyteorg/flyte/flyteadmin/plugins" - - "github.com/flyteorg/flyte/flytestdlib/profutils" - _ "net/http/pprof" // Required to serve application. - "github.com/flyteorg/flyte/flyteadmin/pkg/server" - - "github.com/flyteorg/flyte/flytestdlib/logger" "github.com/spf13/cobra" runtimeConfig "github.com/flyteorg/flyte/flyteadmin/pkg/runtime" + "github.com/flyteorg/flyte/flyteadmin/pkg/server" + "github.com/flyteorg/flyte/flyteadmin/plugins" + "github.com/flyteorg/flyte/flytestdlib/logger" + "github.com/flyteorg/flyte/flytestdlib/profutils" ) var pluginRegistryStore = plugins.NewAtomicRegistry(plugins.NewRegistry()) diff --git a/flyteadmin/cmd/entrypoints/serve_test.go b/flyteadmin/cmd/entrypoints/serve_test.go index e2269388ad..897a56f389 100644 --- a/flyteadmin/cmd/entrypoints/serve_test.go +++ b/flyteadmin/cmd/entrypoints/serve_test.go @@ -10,13 +10,14 @@ import ( "fmt" "testing" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" "github.com/stretchr/testify/assert" "golang.org/x/oauth2" "google.golang.org/grpc" "google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials/oauth" + + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" ) func TestClient(t *testing.T) { diff --git a/flyteadmin/cmd/main.go b/flyteadmin/cmd/main.go index d64c8a5dbf..26b79007c8 100644 --- a/flyteadmin/cmd/main.go +++ b/flyteadmin/cmd/main.go @@ -1,9 +1,10 @@ package main import ( + "github.com/golang/glog" + "github.com/flyteorg/flyte/flyteadmin/cmd/entrypoints" "github.com/flyteorg/flyte/flyteadmin/plugins" - "github.com/golang/glog" ) func main() { diff --git a/flyteadmin/cmd/scheduler/entrypoints/precheck.go b/flyteadmin/cmd/scheduler/entrypoints/precheck.go index a3e3e8add5..c183429969 100644 --- a/flyteadmin/cmd/scheduler/entrypoints/precheck.go +++ b/flyteadmin/cmd/scheduler/entrypoints/precheck.go @@ -4,11 +4,11 @@ import ( "context" "fmt" - "github.com/flyteorg/flyte/flyteidl/clients/go/admin" - "github.com/flyteorg/flyte/flytestdlib/logger" - "github.com/spf13/cobra" "google.golang.org/grpc/health/grpc_health_v1" + + "github.com/flyteorg/flyte/flyteidl/clients/go/admin" + "github.com/flyteorg/flyte/flytestdlib/logger" ) const ( diff --git a/flyteadmin/cmd/scheduler/entrypoints/root.go b/flyteadmin/cmd/scheduler/entrypoints/root.go index 1f37a11df9..dd50b03b19 100644 --- a/flyteadmin/cmd/scheduler/entrypoints/root.go +++ b/flyteadmin/cmd/scheduler/entrypoints/root.go @@ -6,12 +6,12 @@ import ( "fmt" "os" - "github.com/flyteorg/flyte/flytestdlib/logger" + "github.com/spf13/cobra" + "github.com/spf13/pflag" "github.com/flyteorg/flyte/flytestdlib/config" "github.com/flyteorg/flyte/flytestdlib/config/viper" - "github.com/spf13/cobra" - "github.com/spf13/pflag" + "github.com/flyteorg/flyte/flytestdlib/logger" ) var ( diff --git a/flyteadmin/cmd/scheduler/entrypoints/scheduler.go b/flyteadmin/cmd/scheduler/entrypoints/scheduler.go index 15935bcb04..a541444f19 100644 --- a/flyteadmin/cmd/scheduler/entrypoints/scheduler.go +++ b/flyteadmin/cmd/scheduler/entrypoints/scheduler.go @@ -3,14 +3,14 @@ package entrypoints import ( "context" - "github.com/flyteorg/flyte/flyteadmin/pkg/server" + "github.com/spf13/cobra" + _ "gorm.io/driver/postgres" // Required to import database driver. "github.com/flyteorg/flyte/flyteadmin/pkg/runtime" + "github.com/flyteorg/flyte/flyteadmin/pkg/server" "github.com/flyteorg/flyte/flyteadmin/scheduler" "github.com/flyteorg/flyte/flytestdlib/logger" "github.com/flyteorg/flyte/flytestdlib/profutils" - "github.com/spf13/cobra" - _ "gorm.io/driver/postgres" // Required to import database driver. ) var schedulerRunCmd = &cobra.Command{ diff --git a/flyteadmin/cmd/scheduler/main.go b/flyteadmin/cmd/scheduler/main.go index 9b12d85116..260afede08 100644 --- a/flyteadmin/cmd/scheduler/main.go +++ b/flyteadmin/cmd/scheduler/main.go @@ -1,8 +1,9 @@ package main import ( - "github.com/flyteorg/flyte/flyteadmin/cmd/scheduler/entrypoints" "github.com/golang/glog" + + "github.com/flyteorg/flyte/flyteadmin/cmd/scheduler/entrypoints" ) func main() { diff --git a/flyteadmin/dataproxy/service.go b/flyteadmin/dataproxy/service.go index 049bd14b1e..07c8ae1196 100644 --- a/flyteadmin/dataproxy/service.go +++ b/flyteadmin/dataproxy/service.go @@ -12,30 +12,22 @@ import ( "strings" "time" - "github.com/flyteorg/flyte/flyteadmin/pkg/common" - - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core" - "github.com/flyteorg/flyte/flytestdlib/logger" - - "github.com/flyteorg/flyte/flyteadmin/pkg/errors" "google.golang.org/grpc/codes" + "google.golang.org/protobuf/types/known/durationpb" + "google.golang.org/protobuf/types/known/timestamppb" + "k8s.io/apimachinery/pkg/util/rand" + "github.com/flyteorg/flyte/flyteadmin/pkg/common" + "github.com/flyteorg/flyte/flyteadmin/pkg/config" + "github.com/flyteorg/flyte/flyteadmin/pkg/errors" "github.com/flyteorg/flyte/flyteadmin/pkg/manager/interfaces" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" - + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" "github.com/flyteorg/flyte/flyteplugins/go/tasks/pluginmachinery/ioutils" - - "google.golang.org/protobuf/types/known/durationpb" - - "github.com/flyteorg/flyte/flyteadmin/pkg/config" - - "google.golang.org/protobuf/types/known/timestamppb" - + "github.com/flyteorg/flyte/flytestdlib/logger" "github.com/flyteorg/flyte/flytestdlib/storage" "github.com/flyteorg/stow" - "k8s.io/apimachinery/pkg/util/rand" - - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" ) type Service struct { diff --git a/flyteadmin/dataproxy/service_test.go b/flyteadmin/dataproxy/service_test.go index 814ac38ecd..3716b98914 100644 --- a/flyteadmin/dataproxy/service_test.go +++ b/flyteadmin/dataproxy/service_test.go @@ -8,27 +8,22 @@ import ( "testing" "time" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" "github.com/golang/protobuf/proto" - - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core" - - "github.com/flyteorg/flyte/flyteadmin/pkg/manager/mocks" + "github.com/stretchr/testify/assert" + "google.golang.org/protobuf/types/known/durationpb" commonMocks "github.com/flyteorg/flyte/flyteadmin/pkg/common/mocks" - stdlibConfig "github.com/flyteorg/flyte/flytestdlib/config" - + "github.com/flyteorg/flyte/flyteadmin/pkg/config" "github.com/flyteorg/flyte/flyteadmin/pkg/errors" - "github.com/flyteorg/flyte/flytestdlib/contextutils" - "github.com/flyteorg/flyte/flytestdlib/promutils/labeled" - "google.golang.org/protobuf/types/known/durationpb" - + "github.com/flyteorg/flyte/flyteadmin/pkg/manager/mocks" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/service" - - "github.com/flyteorg/flyte/flyteadmin/pkg/config" + stdlibConfig "github.com/flyteorg/flyte/flytestdlib/config" + "github.com/flyteorg/flyte/flytestdlib/contextutils" "github.com/flyteorg/flyte/flytestdlib/promutils" + "github.com/flyteorg/flyte/flytestdlib/promutils/labeled" "github.com/flyteorg/flyte/flytestdlib/storage" - "github.com/stretchr/testify/assert" ) func TestNewService(t *testing.T) { diff --git a/flyteadmin/pkg/async/cloudevent/factory.go b/flyteadmin/pkg/async/cloudevent/factory.go index 976aa34532..efa0848ccb 100644 --- a/flyteadmin/pkg/async/cloudevent/factory.go +++ b/flyteadmin/pkg/async/cloudevent/factory.go @@ -10,6 +10,7 @@ import ( "github.com/Shopify/sarama" "github.com/cloudevents/sdk-go/protocol/kafka_sarama/v2" cloudevents "github.com/cloudevents/sdk-go/v2" + "github.com/flyteorg/flyte/flyteadmin/pkg/async" cloudEventImplementations "github.com/flyteorg/flyte/flyteadmin/pkg/async/cloudevent/implementations" "github.com/flyteorg/flyte/flyteadmin/pkg/async/cloudevent/interfaces" diff --git a/flyteadmin/pkg/async/cloudevent/factory_test.go b/flyteadmin/pkg/async/cloudevent/factory_test.go index e5ccdbee22..6d6c1a881c 100644 --- a/flyteadmin/pkg/async/cloudevent/factory_test.go +++ b/flyteadmin/pkg/async/cloudevent/factory_test.go @@ -4,11 +4,12 @@ import ( "context" "testing" + "github.com/stretchr/testify/assert" + "github.com/flyteorg/flyte/flyteadmin/pkg/async/cloudevent/implementations" "github.com/flyteorg/flyte/flyteadmin/pkg/common" runtimeInterfaces "github.com/flyteorg/flyte/flyteadmin/pkg/runtime/interfaces" "github.com/flyteorg/flyte/flytestdlib/promutils" - "github.com/stretchr/testify/assert" ) func TestGetCloudEventPublisher(t *testing.T) { diff --git a/flyteadmin/pkg/async/cloudevent/implementations/cloudevent_publisher.go b/flyteadmin/pkg/async/cloudevent/implementations/cloudevent_publisher.go index 8eafefffc0..925e7ef18f 100644 --- a/flyteadmin/pkg/async/cloudevent/implementations/cloudevent_publisher.go +++ b/flyteadmin/pkg/async/cloudevent/implementations/cloudevent_publisher.go @@ -7,21 +7,16 @@ import ( "reflect" "time" - "github.com/golang/protobuf/jsonpb" - - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" - - "github.com/flyteorg/flyte/flyteadmin/pkg/async/notifications/implementations" - cloudevents "github.com/cloudevents/sdk-go/v2" - + "github.com/golang/protobuf/jsonpb" + "github.com/golang/protobuf/proto" "k8s.io/apimachinery/pkg/util/sets" "github.com/flyteorg/flyte/flyteadmin/pkg/async/cloudevent/interfaces" - + "github.com/flyteorg/flyte/flyteadmin/pkg/async/notifications/implementations" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" "github.com/flyteorg/flyte/flytestdlib/logger" "github.com/flyteorg/flyte/flytestdlib/promutils" - "github.com/golang/protobuf/proto" ) const ( diff --git a/flyteadmin/pkg/async/cloudevent/implementations/cloudevent_publisher_test.go b/flyteadmin/pkg/async/cloudevent/implementations/cloudevent_publisher_test.go index 65bedaac47..d9108aa3ff 100644 --- a/flyteadmin/pkg/async/cloudevent/implementations/cloudevent_publisher_test.go +++ b/flyteadmin/pkg/async/cloudevent/implementations/cloudevent_publisher_test.go @@ -7,20 +7,19 @@ import ( "testing" "time" - "github.com/golang/protobuf/jsonpb" - - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/event" - "github.com/golang/protobuf/ptypes" - "github.com/NYTimes/gizmo/pubsub" "github.com/NYTimes/gizmo/pubsub/pubsubtest" pbcloudevents "github.com/cloudevents/sdk-go/binding/format/protobuf/v2" cloudevents "github.com/cloudevents/sdk-go/v2" - "github.com/flyteorg/flyte/flytestdlib/promutils" + "github.com/golang/protobuf/jsonpb" "github.com/golang/protobuf/proto" + "github.com/golang/protobuf/ptypes" "github.com/stretchr/testify/assert" + + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/event" + "github.com/flyteorg/flyte/flytestdlib/promutils" ) type mockKafkaSender struct{} diff --git a/flyteadmin/pkg/async/cloudevent/implementations/sender.go b/flyteadmin/pkg/async/cloudevent/implementations/sender.go index 263e4cfd56..4e7ba23d8a 100644 --- a/flyteadmin/pkg/async/cloudevent/implementations/sender.go +++ b/flyteadmin/pkg/async/cloudevent/implementations/sender.go @@ -9,6 +9,7 @@ import ( pbcloudevents "github.com/cloudevents/sdk-go/binding/format/protobuf/v2" "github.com/cloudevents/sdk-go/protocol/kafka_sarama/v2" cloudevents "github.com/cloudevents/sdk-go/v2" + "github.com/flyteorg/flyte/flytestdlib/logger" ) diff --git a/flyteadmin/pkg/async/cloudevent/implementations/sender_test.go b/flyteadmin/pkg/async/cloudevent/implementations/sender_test.go index 93c05829f1..684eb36c56 100644 --- a/flyteadmin/pkg/async/cloudevent/implementations/sender_test.go +++ b/flyteadmin/pkg/async/cloudevent/implementations/sender_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/NYTimes/gizmo/pubsub/pubsubtest" - cloudevents "github.com/cloudevents/sdk-go/v2" "github.com/cloudevents/sdk-go/v2/event" "github.com/cloudevents/sdk-go/v2/protocol" diff --git a/flyteadmin/pkg/async/events/implementations/node_execution_event_writer.go b/flyteadmin/pkg/async/events/implementations/node_execution_event_writer.go index fbcc50aa83..623baf354d 100644 --- a/flyteadmin/pkg/async/events/implementations/node_execution_event_writer.go +++ b/flyteadmin/pkg/async/events/implementations/node_execution_event_writer.go @@ -3,9 +3,8 @@ package implementations import ( "context" - repositoryInterfaces "github.com/flyteorg/flyte/flyteadmin/pkg/repositories/interfaces" - "github.com/flyteorg/flyte/flyteadmin/pkg/async/events/interfaces" + repositoryInterfaces "github.com/flyteorg/flyte/flyteadmin/pkg/repositories/interfaces" "github.com/flyteorg/flyte/flyteadmin/pkg/repositories/transformers" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" "github.com/flyteorg/flyte/flytestdlib/logger" diff --git a/flyteadmin/pkg/async/events/implementations/workflow_execution_event_writer.go b/flyteadmin/pkg/async/events/implementations/workflow_execution_event_writer.go index 6d326d4708..7521dee4b8 100644 --- a/flyteadmin/pkg/async/events/implementations/workflow_execution_event_writer.go +++ b/flyteadmin/pkg/async/events/implementations/workflow_execution_event_writer.go @@ -3,9 +3,8 @@ package implementations import ( "context" - repositoryInterfaces "github.com/flyteorg/flyte/flyteadmin/pkg/repositories/interfaces" - "github.com/flyteorg/flyte/flyteadmin/pkg/async/events/interfaces" + repositoryInterfaces "github.com/flyteorg/flyte/flyteadmin/pkg/repositories/interfaces" "github.com/flyteorg/flyte/flyteadmin/pkg/repositories/transformers" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" "github.com/flyteorg/flyte/flytestdlib/logger" diff --git a/flyteadmin/pkg/async/notifications/email.go b/flyteadmin/pkg/async/notifications/email.go index 6481d0cc20..94eb71719c 100644 --- a/flyteadmin/pkg/async/notifications/email.go +++ b/flyteadmin/pkg/async/notifications/email.go @@ -2,7 +2,6 @@ package notifications import ( "fmt" - "strings" runtimeInterfaces "github.com/flyteorg/flyte/flyteadmin/pkg/runtime/interfaces" diff --git a/flyteadmin/pkg/async/notifications/email_test.go b/flyteadmin/pkg/async/notifications/email_test.go index 53fcb585c1..f05f893124 100644 --- a/flyteadmin/pkg/async/notifications/email_test.go +++ b/flyteadmin/pkg/async/notifications/email_test.go @@ -2,16 +2,16 @@ package notifications import ( "fmt" + "strings" "testing" - "strings" + "github.com/gogo/protobuf/proto" + "github.com/stretchr/testify/assert" runtimeInterfaces "github.com/flyteorg/flyte/flyteadmin/pkg/runtime/interfaces" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/event" - "github.com/gogo/protobuf/proto" - "github.com/stretchr/testify/assert" ) const executionProjectValue = "proj" diff --git a/flyteadmin/pkg/async/notifications/factory.go b/flyteadmin/pkg/async/notifications/factory.go index 54496376dd..53e96f7e67 100644 --- a/flyteadmin/pkg/async/notifications/factory.go +++ b/flyteadmin/pkg/async/notifications/factory.go @@ -6,13 +6,6 @@ import ( "sync" "time" - "github.com/flyteorg/flyte/flyteadmin/pkg/async" - - "github.com/flyteorg/flyte/flyteadmin/pkg/async/notifications/implementations" - "github.com/flyteorg/flyte/flyteadmin/pkg/async/notifications/interfaces" - runtimeInterfaces "github.com/flyteorg/flyte/flyteadmin/pkg/runtime/interfaces" - "github.com/flyteorg/flyte/flytestdlib/logger" - "github.com/NYTimes/gizmo/pubsub" gizmoAWS "github.com/NYTimes/gizmo/pubsub/aws" gizmoGCP "github.com/NYTimes/gizmo/pubsub/gcp" @@ -20,7 +13,12 @@ import ( "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ses" + "github.com/flyteorg/flyte/flyteadmin/pkg/async" + "github.com/flyteorg/flyte/flyteadmin/pkg/async/notifications/implementations" + "github.com/flyteorg/flyte/flyteadmin/pkg/async/notifications/interfaces" "github.com/flyteorg/flyte/flyteadmin/pkg/common" + runtimeInterfaces "github.com/flyteorg/flyte/flyteadmin/pkg/runtime/interfaces" + "github.com/flyteorg/flyte/flytestdlib/logger" "github.com/flyteorg/flyte/flytestdlib/promutils" ) diff --git a/flyteadmin/pkg/async/notifications/factory_test.go b/flyteadmin/pkg/async/notifications/factory_test.go index f52989d386..1bfd1f4596 100644 --- a/flyteadmin/pkg/async/notifications/factory_test.go +++ b/flyteadmin/pkg/async/notifications/factory_test.go @@ -4,11 +4,12 @@ import ( "context" "testing" + "github.com/stretchr/testify/assert" + "github.com/flyteorg/flyte/flyteadmin/pkg/async/notifications/implementations" runtimeInterfaces "github.com/flyteorg/flyte/flyteadmin/pkg/runtime/interfaces" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" "github.com/flyteorg/flyte/flytestdlib/promutils" - "github.com/stretchr/testify/assert" ) var ( diff --git a/flyteadmin/pkg/async/notifications/implementations/aws_emailer.go b/flyteadmin/pkg/async/notifications/implementations/aws_emailer.go index 94f96a1c57..72985c9548 100644 --- a/flyteadmin/pkg/async/notifications/implementations/aws_emailer.go +++ b/flyteadmin/pkg/async/notifications/implementations/aws_emailer.go @@ -5,13 +5,14 @@ import ( "github.com/aws/aws-sdk-go/service/ses" "github.com/aws/aws-sdk-go/service/ses/sesiface" + "google.golang.org/grpc/codes" + "github.com/flyteorg/flyte/flyteadmin/pkg/async/notifications/interfaces" "github.com/flyteorg/flyte/flyteadmin/pkg/errors" runtimeInterfaces "github.com/flyteorg/flyte/flyteadmin/pkg/runtime/interfaces" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" "github.com/flyteorg/flyte/flytestdlib/logger" "github.com/flyteorg/flyte/flytestdlib/promutils" - "google.golang.org/grpc/codes" ) type AwsEmailer struct { diff --git a/flyteadmin/pkg/async/notifications/implementations/aws_emailer_test.go b/flyteadmin/pkg/async/notifications/implementations/aws_emailer_test.go index aa8e1585b3..c06d818eec 100644 --- a/flyteadmin/pkg/async/notifications/implementations/aws_emailer_test.go +++ b/flyteadmin/pkg/async/notifications/implementations/aws_emailer_test.go @@ -1,19 +1,19 @@ package implementations import ( - "testing" - "context" + "testing" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ses" "github.com/aws/aws-sdk-go/service/ses/sesiface" + "github.com/pkg/errors" + "github.com/stretchr/testify/assert" + "github.com/flyteorg/flyte/flyteadmin/pkg/async/notifications/mocks" runtimeInterfaces "github.com/flyteorg/flyte/flyteadmin/pkg/runtime/interfaces" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" "github.com/flyteorg/flyte/flytestdlib/promutils" - "github.com/pkg/errors" - "github.com/stretchr/testify/assert" ) func getNotificationsConfig() runtimeInterfaces.NotificationsConfig { diff --git a/flyteadmin/pkg/async/notifications/implementations/aws_processor.go b/flyteadmin/pkg/async/notifications/implementations/aws_processor.go index fe99ad0af9..fb3b3c2a1b 100644 --- a/flyteadmin/pkg/async/notifications/implementations/aws_processor.go +++ b/flyteadmin/pkg/async/notifications/implementations/aws_processor.go @@ -7,12 +7,13 @@ import ( "time" "github.com/NYTimes/gizmo/pubsub" + "github.com/golang/protobuf/proto" + "github.com/flyteorg/flyte/flyteadmin/pkg/async" "github.com/flyteorg/flyte/flyteadmin/pkg/async/notifications/interfaces" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" "github.com/flyteorg/flyte/flytestdlib/logger" "github.com/flyteorg/flyte/flytestdlib/promutils" - "github.com/golang/protobuf/proto" ) // TODO: Add a counter that encompasses the publisher stats grouped by project and domain. diff --git a/flyteadmin/pkg/async/notifications/implementations/aws_processor_test.go b/flyteadmin/pkg/async/notifications/implementations/aws_processor_test.go index f189ec1cb8..ef27f1f3a8 100644 --- a/flyteadmin/pkg/async/notifications/implementations/aws_processor_test.go +++ b/flyteadmin/pkg/async/notifications/implementations/aws_processor_test.go @@ -2,16 +2,15 @@ package implementations import ( "context" + "encoding/base64" "errors" "testing" - "encoding/base64" - "github.com/aws/aws-sdk-go/aws" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" + "github.com/stretchr/testify/assert" "github.com/flyteorg/flyte/flyteadmin/pkg/async/notifications/mocks" - "github.com/stretchr/testify/assert" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" ) var mockEmailer mocks.MockEmailer diff --git a/flyteadmin/pkg/async/notifications/implementations/email_metrics.go b/flyteadmin/pkg/async/notifications/implementations/email_metrics.go index 00195b3d26..3607cee286 100644 --- a/flyteadmin/pkg/async/notifications/implementations/email_metrics.go +++ b/flyteadmin/pkg/async/notifications/implementations/email_metrics.go @@ -1,8 +1,9 @@ package implementations import ( - "github.com/flyteorg/flyte/flytestdlib/promutils" "github.com/prometheus/client_golang/prometheus" + + "github.com/flyteorg/flyte/flytestdlib/promutils" ) type emailMetrics struct { diff --git a/flyteadmin/pkg/async/notifications/implementations/event_publisher.go b/flyteadmin/pkg/async/notifications/implementations/event_publisher.go index fc501ff12f..d91f54de33 100644 --- a/flyteadmin/pkg/async/notifications/implementations/event_publisher.go +++ b/flyteadmin/pkg/async/notifications/implementations/event_publisher.go @@ -3,17 +3,15 @@ package implementations import ( "context" + "github.com/NYTimes/gizmo/pubsub" + "github.com/golang/protobuf/proto" + "github.com/prometheus/client_golang/prometheus" "k8s.io/apimachinery/pkg/util/sets" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" - "github.com/flyteorg/flyte/flyteadmin/pkg/async/notifications/interfaces" - - "github.com/NYTimes/gizmo/pubsub" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" "github.com/flyteorg/flyte/flytestdlib/logger" "github.com/flyteorg/flyte/flytestdlib/promutils" - "github.com/golang/protobuf/proto" - "github.com/prometheus/client_golang/prometheus" ) type EventPublisherSystemMetrics struct { diff --git a/flyteadmin/pkg/async/notifications/implementations/event_publisher_test.go b/flyteadmin/pkg/async/notifications/implementations/event_publisher_test.go index c6223bbf61..804e2fadae 100644 --- a/flyteadmin/pkg/async/notifications/implementations/event_publisher_test.go +++ b/flyteadmin/pkg/async/notifications/implementations/event_publisher_test.go @@ -6,16 +6,16 @@ import ( "testing" "time" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/event" - "github.com/golang/protobuf/ptypes" - "github.com/NYTimes/gizmo/pubsub" "github.com/NYTimes/gizmo/pubsub/pubsubtest" - "github.com/flyteorg/flyte/flytestdlib/promutils" "github.com/golang/protobuf/proto" + "github.com/golang/protobuf/ptypes" "github.com/stretchr/testify/assert" + + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/event" + "github.com/flyteorg/flyte/flytestdlib/promutils" ) var testEventPublisher pubsubtest.TestPublisher diff --git a/flyteadmin/pkg/async/notifications/implementations/gcp_processor.go b/flyteadmin/pkg/async/notifications/implementations/gcp_processor.go index 2127f02cf1..54e4f4a592 100644 --- a/flyteadmin/pkg/async/notifications/implementations/gcp_processor.go +++ b/flyteadmin/pkg/async/notifications/implementations/gcp_processor.go @@ -5,12 +5,13 @@ import ( "time" "github.com/NYTimes/gizmo/pubsub" + "github.com/golang/protobuf/proto" + "github.com/flyteorg/flyte/flyteadmin/pkg/async" "github.com/flyteorg/flyte/flyteadmin/pkg/async/notifications/interfaces" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" "github.com/flyteorg/flyte/flytestdlib/logger" "github.com/flyteorg/flyte/flytestdlib/promutils" - "github.com/golang/protobuf/proto" ) // TODO: Add a counter that encompasses the publisher stats grouped by project and domain. diff --git a/flyteadmin/pkg/async/notifications/implementations/gcp_processor_test.go b/flyteadmin/pkg/async/notifications/implementations/gcp_processor_test.go index 35ab94c093..e83cf7b1d3 100644 --- a/flyteadmin/pkg/async/notifications/implementations/gcp_processor_test.go +++ b/flyteadmin/pkg/async/notifications/implementations/gcp_processor_test.go @@ -5,12 +5,13 @@ import ( "testing" "github.com/NYTimes/gizmo/pubsub/pubsubtest" - "github.com/flyteorg/flyte/flyteadmin/pkg/async/notifications/mocks" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" - "github.com/flyteorg/flyte/flytestdlib/promutils" "github.com/pkg/errors" dto "github.com/prometheus/client_model/go" "github.com/stretchr/testify/assert" + + "github.com/flyteorg/flyte/flyteadmin/pkg/async/notifications/mocks" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" + "github.com/flyteorg/flyte/flytestdlib/promutils" ) var ( diff --git a/flyteadmin/pkg/async/notifications/implementations/noop_notifications.go b/flyteadmin/pkg/async/notifications/implementations/noop_notifications.go index ca716113ae..4da316f6b2 100644 --- a/flyteadmin/pkg/async/notifications/implementations/noop_notifications.go +++ b/flyteadmin/pkg/async/notifications/implementations/noop_notifications.go @@ -2,15 +2,13 @@ package implementations import ( "context" + "strings" - "github.com/flyteorg/flyte/flyteadmin/pkg/async/notifications/interfaces" + "github.com/golang/protobuf/proto" + "github.com/flyteorg/flyte/flyteadmin/pkg/async/notifications/interfaces" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" "github.com/flyteorg/flyte/flytestdlib/logger" - - "strings" - - "github.com/golang/protobuf/proto" ) // Email to use when there is no email configuration. diff --git a/flyteadmin/pkg/async/notifications/implementations/processor_metrics.go b/flyteadmin/pkg/async/notifications/implementations/processor_metrics.go index 938ce2b325..de62632fe4 100644 --- a/flyteadmin/pkg/async/notifications/implementations/processor_metrics.go +++ b/flyteadmin/pkg/async/notifications/implementations/processor_metrics.go @@ -1,8 +1,9 @@ package implementations import ( - "github.com/flyteorg/flyte/flytestdlib/promutils" "github.com/prometheus/client_golang/prometheus" + + "github.com/flyteorg/flyte/flytestdlib/promutils" ) type processorSystemMetrics struct { diff --git a/flyteadmin/pkg/async/notifications/implementations/publisher.go b/flyteadmin/pkg/async/notifications/implementations/publisher.go index d168e51083..8d0d99411b 100644 --- a/flyteadmin/pkg/async/notifications/implementations/publisher.go +++ b/flyteadmin/pkg/async/notifications/implementations/publisher.go @@ -3,13 +3,13 @@ package implementations import ( "context" - "github.com/flyteorg/flyte/flyteadmin/pkg/async/notifications/interfaces" - "github.com/NYTimes/gizmo/pubsub" - "github.com/flyteorg/flyte/flytestdlib/logger" - "github.com/flyteorg/flyte/flytestdlib/promutils" "github.com/golang/protobuf/proto" "github.com/prometheus/client_golang/prometheus" + + "github.com/flyteorg/flyte/flyteadmin/pkg/async/notifications/interfaces" + "github.com/flyteorg/flyte/flytestdlib/logger" + "github.com/flyteorg/flyte/flytestdlib/promutils" ) type publisherSystemMetrics struct { diff --git a/flyteadmin/pkg/async/notifications/implementations/publisher_test.go b/flyteadmin/pkg/async/notifications/implementations/publisher_test.go index e55df967fb..bde4aae325 100644 --- a/flyteadmin/pkg/async/notifications/implementations/publisher_test.go +++ b/flyteadmin/pkg/async/notifications/implementations/publisher_test.go @@ -9,11 +9,12 @@ import ( "github.com/NYTimes/gizmo/pubsub" "github.com/NYTimes/gizmo/pubsub/pubsubtest" "github.com/aws/aws-sdk-go/aws" + "github.com/golang/protobuf/proto" + "github.com/stretchr/testify/assert" + "github.com/flyteorg/flyte/flyteadmin/pkg/async/notifications/mocks" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" "github.com/flyteorg/flyte/flytestdlib/promutils" - "github.com/golang/protobuf/proto" - "github.com/stretchr/testify/assert" ) var ( diff --git a/flyteadmin/pkg/async/notifications/implementations/sandbox_processor.go b/flyteadmin/pkg/async/notifications/implementations/sandbox_processor.go index 128b865e84..2cb83da406 100644 --- a/flyteadmin/pkg/async/notifications/implementations/sandbox_processor.go +++ b/flyteadmin/pkg/async/notifications/implementations/sandbox_processor.go @@ -4,11 +4,12 @@ import ( "context" "time" + "github.com/golang/protobuf/proto" + "github.com/flyteorg/flyte/flyteadmin/pkg/async" "github.com/flyteorg/flyte/flyteadmin/pkg/async/notifications/interfaces" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" "github.com/flyteorg/flyte/flytestdlib/logger" - "github.com/golang/protobuf/proto" ) type SandboxProcessor struct { diff --git a/flyteadmin/pkg/async/notifications/implementations/sandbox_processor_test.go b/flyteadmin/pkg/async/notifications/implementations/sandbox_processor_test.go index 1a703faf70..d0ee9ee31b 100644 --- a/flyteadmin/pkg/async/notifications/implementations/sandbox_processor_test.go +++ b/flyteadmin/pkg/async/notifications/implementations/sandbox_processor_test.go @@ -5,10 +5,11 @@ import ( "testing" "time" - "github.com/flyteorg/flyte/flyteadmin/pkg/async/notifications/mocks" - "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" "github.com/pkg/errors" "github.com/stretchr/testify/assert" + + "github.com/flyteorg/flyte/flyteadmin/pkg/async/notifications/mocks" + "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" ) var mockSandboxEmailer mocks.MockEmailer diff --git a/flyteadmin/pkg/async/notifications/implementations/sandbox_publisher.go b/flyteadmin/pkg/async/notifications/implementations/sandbox_publisher.go index c023d429bb..a0114a95eb 100644 --- a/flyteadmin/pkg/async/notifications/implementations/sandbox_publisher.go +++ b/flyteadmin/pkg/async/notifications/implementations/sandbox_publisher.go @@ -3,8 +3,9 @@ package implementations import ( "context" - "github.com/flyteorg/flyte/flytestdlib/logger" "github.com/golang/protobuf/proto" + + "github.com/flyteorg/flyte/flytestdlib/logger" ) type SandboxPublisher struct { diff --git a/flyteadmin/pkg/async/notifications/implementations/sendgrid_emailer_test.go b/flyteadmin/pkg/async/notifications/implementations/sendgrid_emailer_test.go index fd16c9cf15..bfedb152d0 100644 --- a/flyteadmin/pkg/async/notifications/implementations/sendgrid_emailer_test.go +++ b/flyteadmin/pkg/async/notifications/implementations/sendgrid_emailer_test.go @@ -6,10 +6,11 @@ import ( "path" "testing" + "github.com/stretchr/testify/assert" + runtimeInterfaces "github.com/flyteorg/flyte/flyteadmin/pkg/runtime/interfaces" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" "github.com/flyteorg/flyte/flytestdlib/promutils" - "github.com/stretchr/testify/assert" ) func TestAddresses(t *testing.T) { diff --git a/flyteadmin/pkg/async/schedule/aws/cloud_watch_scheduler.go b/flyteadmin/pkg/async/schedule/aws/cloud_watch_scheduler.go index 26bfec0631..768d195766 100644 --- a/flyteadmin/pkg/async/schedule/aws/cloud_watch_scheduler.go +++ b/flyteadmin/pkg/async/schedule/aws/cloud_watch_scheduler.go @@ -5,6 +5,13 @@ import ( "fmt" "strings" + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/session" + "github.com/aws/aws-sdk-go/service/cloudwatchevents" + "github.com/prometheus/client_golang/prometheus" + "google.golang.org/grpc/codes" + "github.com/flyteorg/flyte/flyteadmin/pkg/async/schedule/aws/interfaces" scheduleInterfaces "github.com/flyteorg/flyte/flyteadmin/pkg/async/schedule/interfaces" "github.com/flyteorg/flyte/flyteadmin/pkg/errors" @@ -13,13 +20,6 @@ import ( "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core" "github.com/flyteorg/flyte/flytestdlib/logger" "github.com/flyteorg/flyte/flytestdlib/promutils" - - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/awserr" - "github.com/aws/aws-sdk-go/aws/session" - "github.com/aws/aws-sdk-go/service/cloudwatchevents" - "github.com/prometheus/client_golang/prometheus" - "google.golang.org/grpc/codes" ) // To indicate that a schedule rule is enabled. diff --git a/flyteadmin/pkg/async/schedule/aws/cloud_watch_scheduler_test.go b/flyteadmin/pkg/async/schedule/aws/cloud_watch_scheduler_test.go index 86b08df5b0..bb32163d1f 100644 --- a/flyteadmin/pkg/async/schedule/aws/cloud_watch_scheduler_test.go +++ b/flyteadmin/pkg/async/schedule/aws/cloud_watch_scheduler_test.go @@ -5,6 +5,11 @@ import ( "fmt" "testing" + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/service/cloudwatchevents" + "github.com/stretchr/testify/assert" + "google.golang.org/grpc/codes" + "github.com/flyteorg/flyte/flyteadmin/pkg/async/schedule/aws/interfaces" "github.com/flyteorg/flyte/flyteadmin/pkg/async/schedule/aws/mocks" scheduleInterfaces "github.com/flyteorg/flyte/flyteadmin/pkg/async/schedule/interfaces" @@ -12,11 +17,6 @@ import ( "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/core" "github.com/flyteorg/flyte/flytestdlib/promutils" - - "github.com/aws/aws-sdk-go/aws/awserr" - "github.com/aws/aws-sdk-go/service/cloudwatchevents" - "github.com/stretchr/testify/assert" - "google.golang.org/grpc/codes" ) const testScheduleName = "flyte_16301494360130577061" diff --git a/flyteadmin/pkg/async/schedule/aws/mocks/mock_cloud_watch_event_client.go b/flyteadmin/pkg/async/schedule/aws/mocks/mock_cloud_watch_event_client.go index c7bdb4c0fc..91bda97bbe 100644 --- a/flyteadmin/pkg/async/schedule/aws/mocks/mock_cloud_watch_event_client.go +++ b/flyteadmin/pkg/async/schedule/aws/mocks/mock_cloud_watch_event_client.go @@ -2,6 +2,7 @@ package mocks import ( "github.com/aws/aws-sdk-go/service/cloudwatchevents" + "github.com/flyteorg/flyte/flyteadmin/pkg/async/schedule/aws/interfaces" ) diff --git a/flyteadmin/pkg/async/schedule/aws/serialization.go b/flyteadmin/pkg/async/schedule/aws/serialization.go index e10f3f89d8..833235f4fc 100644 --- a/flyteadmin/pkg/async/schedule/aws/serialization.go +++ b/flyteadmin/pkg/async/schedule/aws/serialization.go @@ -8,12 +8,12 @@ import ( "fmt" "time" - "github.com/flyteorg/flyte/flytestdlib/logger" + "github.com/golang/protobuf/proto" + "google.golang.org/grpc/codes" "github.com/flyteorg/flyte/flyteadmin/pkg/errors" "github.com/flyteorg/flyte/flyteidl/gen/pb-go/flyteidl/admin" - "github.com/golang/protobuf/proto" - "google.golang.org/grpc/codes" + "github.com/flyteorg/flyte/flytestdlib/logger" ) const awsTimestampPlaceholder = "