Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add linter to integration build tag #1102

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
run:
timeout: 10m
build-tags:
- integration
linters:
enable:
- asciicheck
Expand Down Expand Up @@ -36,6 +38,10 @@ issues:
- gosec
text: "weak cryptographic primitive"
path: "state/indexers/md5Indexer.*"
- linters:
- gosec
text: "TLS MinVersion too low"
path: "tests/integration/"
- linters:
- gosec
text: "weak random number generator"
Expand Down Expand Up @@ -72,6 +78,10 @@ issues:
path: cmd/root.go

linters-settings:
gci:
sections:
- standard
- default
goconst:
min-occurrences: 10
gomodguard:
Expand Down
120 changes: 10 additions & 110 deletions tests/integration/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/kong/go-kong/kong"

deckDump "github.com/kong/deck/dump"
"github.com/kong/deck/utils"
"github.com/kong/go-kong/kong"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

var (
Expand Down Expand Up @@ -161,7 +159,7 @@ var (
}

// has run-on set to 'first'
plugin_143_151 = []*kong.Plugin{
plugin_143_151 = []*kong.Plugin{ //nolint:revive,stylecheck
{
Name: kong.String("basic-auth"),
Protocols: []*string{
Expand Down Expand Up @@ -197,7 +195,7 @@ var (
},
}

plugin_on_entities = []*kong.Plugin{
plugin_on_entities = []*kong.Plugin{ //nolint:revive,stylecheck
{
Name: kong.String("prometheus"),
Protocols: []*string{
Expand Down Expand Up @@ -248,7 +246,7 @@ var (
},
}

plugin_on_entities3x = []*kong.Plugin{
plugin_on_entities3x = []*kong.Plugin{ //nolint:revive,stylecheck
{
Name: kong.String("prometheus"),
Protocols: []*string{
Expand Down Expand Up @@ -311,7 +309,7 @@ var (
},
}

upstream_pre31 = []*kong.Upstream{
upstream_pre31 = []*kong.Upstream{ //nolint:revive,stylecheck
{
Name: kong.String("upstream1"),
Algorithm: kong.String("round-robin"),
Expand Down Expand Up @@ -647,59 +645,6 @@ var (
},
}

consumerGroupsWithRLAKonnect = []*kong.ConsumerGroupObject{
{
ConsumerGroup: &kong.ConsumerGroup{
Name: kong.String("silver"),
Tags: kong.StringSlice("tag1", "tag3"),
},
Consumers: []*kong.Consumer{
{
Username: kong.String("bar"),
},
},
Plugins: []*kong.ConsumerGroupPlugin{
{
Name: kong.String("rate-limiting-advanced"),
Config: kong.Configuration{
"limit": []any{float64(7)},
"retry_after_jitter_max": float64(1),
"window_size": []any{float64(60)},
"window_type": "sliding",
},
ConsumerGroup: &kong.ConsumerGroup{
ID: kong.String("521a90ad-36cb-4e31-a5db-1d979aee40d1"),
},
},
},
},
{
ConsumerGroup: &kong.ConsumerGroup{
Name: kong.String("gold"),
Tags: kong.StringSlice("tag1", "tag2"),
},
Consumers: []*kong.Consumer{
{
Username: kong.String("foo"),
},
},
Plugins: []*kong.ConsumerGroupPlugin{
{
Name: kong.String("rate-limiting-advanced"),
Config: kong.Configuration{
"limit": []any{float64(10)},
"retry_after_jitter_max": float64(1),
"window_size": []any{float64(60)},
"window_type": "sliding",
},
ConsumerGroup: &kong.ConsumerGroup{
ID: kong.String("92177268-b134-42f9-909a-36f9d2d3d5e7"),
},
},
},
},
}

consumerGroupsWithRLAApp = []*kong.ConsumerGroupObject{
{
ConsumerGroup: &kong.ConsumerGroup{
Expand Down Expand Up @@ -751,52 +696,6 @@ var (
},
}

rlaPlugin = []*kong.Plugin{
{
Name: kong.String("rate-limiting-advanced"),
Config: kong.Configuration{
"consumer_groups": []any{string("silver"), string("gold")},
"dictionary_name": string("kong_rate_limiting_counters"),
"enforce_consumer_groups": bool(true),
"header_name": nil,
"hide_client_headers": bool(false),
"identifier": string("consumer"),
"limit": []any{float64(10)},
"namespace": string("dNRC6xKsRL8Koc1uVYA4Nki6DLW7XIdx"),
"path": nil,
"redis": map[string]any{
"cluster_addresses": nil,
"connect_timeout": nil,
"database": float64(0),
"host": nil,
"keepalive_backlog": nil,
"keepalive_pool_size": float64(30),
"password": nil,
"port": nil,
"read_timeout": nil,
"send_timeout": nil,
"sentinel_addresses": nil,
"sentinel_master": nil,
"sentinel_password": nil,
"sentinel_role": nil,
"sentinel_username": nil,
"server_name": nil,
"ssl": false,
"ssl_verify": false,
"timeout": float64(2000),
"username": nil,
},
"retry_after_jitter_max": float64(0),
"strategy": string("local"),
"sync_rate": float64(-1),
"window_size": []any{float64(60)},
"window_type": string("sliding"),
},
Enabled: kong.Bool(true),
Protocols: []*string{kong.String("grpc"), kong.String("grpcs"), kong.String("http"), kong.String("https")},
},
}

consumerGroupAppPlugins = []*kong.Plugin{
{
Name: kong.String("rate-limiting-advanced"),
Expand Down Expand Up @@ -3872,7 +3771,8 @@ func Test_Sync_SkipConsumers_Konnect(t *testing.T) {
}
}

// In the tests we're concerned only with the IDs and names of the entities we'll ignore other fields when comparing states.
// In the tests we're concerned only with the IDs and names of the entities
// we'll ignore other fields when comparing states.
var ignoreFieldsIrrelevantForIDsTests = []cmp.Option{
cmpopts.IgnoreFields(
kong.Plugin{},
Expand Down Expand Up @@ -4524,7 +4424,7 @@ func Test_Sync_ConsumerGroupsScopedPlugins_Post340(t *testing.T) {
{
name: "attempt to create deprecated consumer groups configuration with Kong version >= 3.4.0 fails",
kongFile: "testdata/sync/017-consumer-groups-rla-application/kong3x.yaml",
expectedError: fmt.Errorf("building state: %v", utils.ErrorConsumerGroupUpgrade),
expectedError: fmt.Errorf("building state: %w", utils.ErrorConsumerGroupUpgrade),
},
{
name: "empty deprecated consumer groups configuration fields do not fail with Kong version >= 3.4.0",
Expand Down
Loading