Skip to content

Commit

Permalink
GCI: Add special rules for integrations (#40466)
Browse files Browse the repository at this point in the history
This PR adds a special group (last one) to match the `terraform` and
`event-handler` integrations.

These two integrations aren't imported by teleport codebase but they
import teleport packages. The issue arrises from the fact that they have
their own module namespace. In order to distinguish their module
namespace, this PR proposes moving them into a new (last) import group
and keep Teleport into a separate group. Unfortunately, at the time of
writing `gci` doesn't support skip directories which causes problems for
our `lint` CI step as it will fail.

This results in the following structure for files within the two
integrations:

- standard
- default
- teleport
- specific integration

Signed-off-by: Tiago Silva <[email protected]>
  • Loading branch information
tigrato authored Apr 12, 2024
1 parent 8a8b312 commit 3e57dde
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ linters-settings:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(github.com/gravitational/teleport) # Custom section: groups all imports with the specified Prefix.
- prefix(github.com/gravitational/teleport/integrations/terraform,github.com/gravitational/teleport/integrations/event-handler)
skip-generated: true # Skip generated files.
custom-order: true # Required for "sections" to take effect.
misspell:
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1023,9 +1023,8 @@ fix-imports/host:
echo 'gci is not installed or is missing from PATH, consider installing it ("go install github.com/daixiang0/gci@latest") or use "make -C build.assets/ fix-imports"';\
exit 1;\
fi
gci write -s standard -s default -s 'prefix(github.com/gravitational/teleport)' --skip-generated .
gci write -s standard -s default -s 'prefix(github.com/gravitational/teleport)' -s 'prefix(github.com/gravitational/teleport/integrations/terraform,github.com/gravitational/teleport/integrations/event-handler)' --skip-generated .

.PHONY: lint-build-tooling
lint-build-tooling: GO_LINT_FLAGS ?=
lint-build-tooling:
cd build.assets/tooling && golangci-lint run -c ../../.golangci.yml $(GO_LINT_FLAGS)
Expand Down
3 changes: 2 additions & 1 deletion integrations/event-handler/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ import (
"github.com/alecthomas/kong"
"github.com/gravitational/trace"

"github.com/gravitational/teleport/integrations/event-handler/lib"
"github.com/gravitational/teleport/integrations/lib/logger"
"github.com/gravitational/teleport/integrations/lib/stringset"

"github.com/gravitational/teleport/integrations/event-handler/lib"
)

// FluentdConfig represents fluentd instance configuration
Expand Down
3 changes: 2 additions & 1 deletion integrations/event-handler/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ import (
"github.com/gravitational/trace"
"github.com/peterbourgon/diskv/v3"

"github.com/gravitational/teleport/integrations/event-handler/lib"
"github.com/gravitational/teleport/integrations/lib/logger"

"github.com/gravitational/teleport/integrations/event-handler/lib"
)

const (
Expand Down
1 change: 1 addition & 0 deletions integrations/event-handler/teleport_event_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (

auditlogpb "github.com/gravitational/teleport/api/gen/proto/go/teleport/auditlog/v1"
"github.com/gravitational/teleport/api/types/events"

"github.com/gravitational/teleport/integrations/event-handler/lib"
)

Expand Down
1 change: 1 addition & 0 deletions integrations/terraform/provider/resource_teleport_bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
headerv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/header/v1"
machineidv1 "github.com/gravitational/teleport/api/gen/proto/go/teleport/machineid/v1"
"github.com/gravitational/teleport/api/utils"

"github.com/gravitational/teleport/integrations/terraform/tfschema"
)

Expand Down
3 changes: 2 additions & 1 deletion integrations/terraform/test/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ import (
"github.com/gravitational/teleport/api/utils"
"github.com/gravitational/teleport/integrations/lib"
"github.com/gravitational/teleport/integrations/lib/testing/integration"
"github.com/gravitational/teleport/integrations/terraform/provider"
"github.com/gravitational/teleport/lib/auth"
libclient "github.com/gravitational/teleport/lib/client"
"github.com/gravitational/teleport/lib/client/identityfile"

"github.com/gravitational/teleport/integrations/terraform/provider"
)

//go:embed fixtures/*
Expand Down

0 comments on commit 3e57dde

Please sign in to comment.