Skip to content

Commit 6d66802

Browse files
Tidy import order (#4440)
* Sort linters * Add gci * Add exclusions for generated code * Update imports for core operator * Update imports for asoctl * Add lint for mangle-test-json * Update imports for generator * Fix tests sensitive to line numbers * Add test utility to taskfile * Update new tests * Remove aliases group * Update controller * Update generator * Update asoctl * Update line numbers in test
1 parent dcb4e6c commit 6d66802

File tree

258 files changed

+423
-267
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

258 files changed

+423
-267
lines changed

.golangci.yml

+28-8
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,51 @@ run:
44

55
linters:
66
enable:
7+
- gci
78
- gofmt
8-
- staticcheck
99
- gosimple
10-
- unused
11-
- tparallel
1210
- paralleltest
1311
- prealloc
14-
- unparam # This was added while we used go1.18 which means it's always been disabled. It may eventually be re-enabled and we'll need to fix what it finds
12+
- staticcheck
13+
- tparallel
14+
- unparam
15+
- unused
1516
presets:
1617
- bugs
1718
- unused
1819
disable:
1920
# The below rules are disabled due to bug with go1.18 and generics: https://github.com/golangci/golangci-lint/issues/2859
2021
- stylecheck
2122
- musttag # Extremely slow, at least on CI machines
23+
2224
linters-settings:
23-
govet:
24-
check-shadowing: true
25-
unused:
26-
generated-is-used: true
2725
exhaustive:
2826
default-signifies-exhaustive: true
27+
gci:
28+
custom-order: true
29+
sections:
30+
- standard
31+
- dot
32+
- default
33+
- prefix(github.com/Azure/azure-service-operator/)
34+
govet:
35+
check-shadowing: true
2936
gosimple:
3037
# See https://golangci-lint.run/usage/linters#gosimple for a breakdown of what's checked by this linter
3138
checks:
3239
- "all"
3340
- "-S1002" # Comparison to bool explicitly can sometimes add clarity
3441
- "-S1016" # Uncommon language feature, encourages coupling when it may not be appropriate
42+
unused:
43+
generated-is-used: true
44+
45+
issues:
46+
exclude-rules:
47+
# Exclude some linters from being run on generated files
48+
- path: "_gen.go"
49+
linters:
50+
- gci
51+
# Exclude some linters from being run on generated test files
52+
- path: "_gen_test.go"
53+
linters:
54+
- gci

Taskfile.yml

+17
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ vars:
1717
CONTROLLER_OUTPUT:
1818
sh: 'realpath v2/config'
1919

20+
MANGLE_ROOT: v2/tools/mangle-test-json
21+
2022
TEST_RESOURCE_PREFIX: asotest
2123
TEST_LIVE_RESOURCE_PREFIX: asolivetest
2224
SCRIPTS_ROOT:
@@ -70,6 +72,7 @@ tasks:
7072
- controller:quick-checks
7173
- asoctl:quick-checks
7274
- crossplane:quick-checks
75+
- mangle-test:quick-checks
7376
cmds:
7477
- task: format-code # Run after the deps to avoid racing with generated file creation
7578

@@ -261,6 +264,7 @@ tasks:
261264
- task: doc:render-diagrams
262265

263266
############### Controller targets ###############
267+
264268
controller:quick-checks:
265269
cmds:
266270
- task: controller:test
@@ -1105,7 +1109,20 @@ tasks:
11051109
cmds:
11061110
- task: doc:crd-api
11071111

1112+
############### Utility targets ###############
1113+
1114+
mangle-test:quick-checks:
1115+
cmds:
1116+
- task: mangle-test:lint
1117+
1118+
mangle-test:lint:
1119+
desc: Run mangle-test fast lint checks.
1120+
dir: '{{.MANGLE_ROOT}}'
1121+
cmds:
1122+
- golangci-lint run --verbose --fast=false --timeout 5m ./...
1123+
11081124
############### Crossplane targets ###############
1125+
11091126
crossplane:quick-checks:
11101127
cmds:
11111128
- task: basic-checks

v2/api/apimanagement/customizations/subscription_extensions.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ package customizations
88
import (
99
"context"
1010

11+
. "github.com/Azure/azure-service-operator/v2/internal/logging"
12+
1113
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement"
1214
"github.com/go-logr/logr"
1315
"github.com/pkg/errors"
@@ -16,7 +18,6 @@ import (
1618

1719
apimanagement "github.com/Azure/azure-service-operator/v2/api/apimanagement/v1api20220801/storage"
1820
"github.com/Azure/azure-service-operator/v2/internal/genericarmclient"
19-
. "github.com/Azure/azure-service-operator/v2/internal/logging"
2021
"github.com/Azure/azure-service-operator/v2/internal/set"
2122
"github.com/Azure/azure-service-operator/v2/internal/util/to"
2223
"github.com/Azure/azure-service-operator/v2/pkg/genruntime"

v2/api/appconfiguration/customizations/configuration_store_extensions.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ package customizations
88
import (
99
"context"
1010

11+
. "github.com/Azure/azure-service-operator/v2/internal/logging"
12+
1113
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
1214
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/appconfiguration/armappconfiguration"
1315
"github.com/go-logr/logr"
@@ -17,7 +19,6 @@ import (
1719

1820
storage "github.com/Azure/azure-service-operator/v2/api/appconfiguration/v1api20220501/storage"
1921
"github.com/Azure/azure-service-operator/v2/internal/genericarmclient"
20-
. "github.com/Azure/azure-service-operator/v2/internal/logging"
2122
"github.com/Azure/azure-service-operator/v2/internal/set"
2223
"github.com/Azure/azure-service-operator/v2/internal/util/to"
2324
"github.com/Azure/azure-service-operator/v2/pkg/genruntime"

v2/api/authorization/customizations/role_assignment_extensions.go

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"strings"
1111

1212
api "github.com/Azure/azure-service-operator/v2/api/authorization/v1api20220401"
13-
1413
"github.com/Azure/azure-service-operator/v2/pkg/genruntime"
1514
"github.com/Azure/azure-service-operator/v2/pkg/genruntime/extensions"
1615
)

v2/api/authorization/customizations/role_definition_extensions.go

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
"strings"
1111

1212
api "github.com/Azure/azure-service-operator/v2/api/authorization/v1api20220401"
13-
1413
"github.com/Azure/azure-service-operator/v2/pkg/genruntime"
1514
"github.com/Azure/azure-service-operator/v2/pkg/genruntime/extensions"
1615
)

v2/api/cache/customizations/redis_extensions.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"context"
1010
"strconv"
1111

12+
. "github.com/Azure/azure-service-operator/v2/internal/logging"
13+
1214
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/redis/armredis"
1315
"github.com/go-logr/logr"
1416
"github.com/pkg/errors"
@@ -17,7 +19,6 @@ import (
1719

1820
redis "github.com/Azure/azure-service-operator/v2/api/cache/v1api20230801/storage"
1921
"github.com/Azure/azure-service-operator/v2/internal/genericarmclient"
20-
. "github.com/Azure/azure-service-operator/v2/internal/logging"
2122
"github.com/Azure/azure-service-operator/v2/internal/set"
2223
"github.com/Azure/azure-service-operator/v2/internal/util/to"
2324
"github.com/Azure/azure-service-operator/v2/pkg/genruntime"

v2/api/compute/customizations/vmss_extensions.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ import (
1111
"net/http"
1212
"reflect"
1313

14+
. "github.com/Azure/azure-service-operator/v2/internal/logging"
15+
1416
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
1517
"github.com/go-logr/logr"
1618
"github.com/pkg/errors"
1719
"sigs.k8s.io/controller-runtime/pkg/conversion"
1820

1921
compute "github.com/Azure/azure-service-operator/v2/api/compute/v1api20220301/storage"
2022
"github.com/Azure/azure-service-operator/v2/internal/genericarmclient"
21-
. "github.com/Azure/azure-service-operator/v2/internal/logging"
2223
"github.com/Azure/azure-service-operator/v2/internal/resolver"
2324
"github.com/Azure/azure-service-operator/v2/internal/util/kubeclient"
2425
"github.com/Azure/azure-service-operator/v2/pkg/genruntime"

v2/api/containerservice/customizations/managed_cluster_extensions.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
"fmt"
1111
"strings"
1212

13+
. "github.com/Azure/azure-service-operator/v2/internal/logging"
14+
1315
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice"
1416
"github.com/go-logr/logr"
1517
"github.com/pkg/errors"
@@ -18,7 +20,6 @@ import (
1820

1921
containerservice "github.com/Azure/azure-service-operator/v2/api/containerservice/v1api20240901/storage"
2022
"github.com/Azure/azure-service-operator/v2/internal/genericarmclient"
21-
. "github.com/Azure/azure-service-operator/v2/internal/logging"
2223
"github.com/Azure/azure-service-operator/v2/internal/resolver"
2324
"github.com/Azure/azure-service-operator/v2/internal/set"
2425
"github.com/Azure/azure-service-operator/v2/pkg/genruntime"

v2/api/dataprotection/customizations/backup_vaults_backup_instance_extensions.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ import (
1010
"fmt"
1111
"strings"
1212

13+
. "github.com/Azure/azure-service-operator/v2/internal/logging"
14+
1315
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v3"
1416
"github.com/go-logr/logr"
1517
"github.com/pkg/errors"
1618
"sigs.k8s.io/controller-runtime/pkg/conversion"
1719

1820
dataprotection "github.com/Azure/azure-service-operator/v2/api/dataprotection/v1api20231101/storage"
1921
"github.com/Azure/azure-service-operator/v2/internal/genericarmclient"
20-
. "github.com/Azure/azure-service-operator/v2/internal/logging"
2122
"github.com/Azure/azure-service-operator/v2/internal/resolver"
2223
"github.com/Azure/azure-service-operator/v2/internal/set"
2324
"github.com/Azure/azure-service-operator/v2/internal/util/to"

v2/api/dbformariadb/customizations/server_extensions.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ package customizations
88
import (
99
"context"
1010

11+
. "github.com/Azure/azure-service-operator/v2/internal/logging"
12+
1113
"github.com/go-logr/logr"
1214
"github.com/pkg/errors"
1315
v1 "k8s.io/api/core/v1"
1416
"sigs.k8s.io/controller-runtime/pkg/conversion"
1517

1618
mariadb "github.com/Azure/azure-service-operator/v2/api/dbformariadb/v1api20180601/storage"
1719
"github.com/Azure/azure-service-operator/v2/internal/genericarmclient"
18-
. "github.com/Azure/azure-service-operator/v2/internal/logging"
1920
"github.com/Azure/azure-service-operator/v2/internal/set"
2021
"github.com/Azure/azure-service-operator/v2/internal/util/to"
2122
"github.com/Azure/azure-service-operator/v2/pkg/genruntime"

v2/api/dbformysql/customizations/flexible_server_extensions.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ package customizations
88
import (
99
"context"
1010

11+
. "github.com/Azure/azure-service-operator/v2/internal/logging"
12+
1113
"github.com/go-logr/logr"
1214
"github.com/pkg/errors"
1315
v1 "k8s.io/api/core/v1"
1416
"sigs.k8s.io/controller-runtime/pkg/conversion"
1517

1618
mysql "github.com/Azure/azure-service-operator/v2/api/dbformysql/v1api20230630/storage"
1719
"github.com/Azure/azure-service-operator/v2/internal/genericarmclient"
18-
. "github.com/Azure/azure-service-operator/v2/internal/logging"
1920
"github.com/Azure/azure-service-operator/v2/internal/set"
2021
"github.com/Azure/azure-service-operator/v2/internal/util/to"
2122
"github.com/Azure/azure-service-operator/v2/pkg/genruntime"

v2/api/dbforpostgresql/customizations/flexible_server_extensions.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@ import (
1010
"fmt"
1111
"strings"
1212

13+
. "github.com/Azure/azure-service-operator/v2/internal/logging"
14+
1315
"github.com/go-logr/logr"
1416
"github.com/pkg/errors"
1517
v1 "k8s.io/api/core/v1"
1618
"sigs.k8s.io/controller-runtime/pkg/conversion"
1719

1820
postgresql "github.com/Azure/azure-service-operator/v2/api/dbforpostgresql/v1api20221201/storage"
1921
"github.com/Azure/azure-service-operator/v2/internal/genericarmclient"
20-
. "github.com/Azure/azure-service-operator/v2/internal/logging"
2122
"github.com/Azure/azure-service-operator/v2/internal/resolver"
2223
"github.com/Azure/azure-service-operator/v2/internal/set"
2324
"github.com/Azure/azure-service-operator/v2/internal/util/to"

v2/api/dbforpostgresql/customizations/flexible_servers_database_extensions.go

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313

1414
api "github.com/Azure/azure-service-operator/v2/api/dbforpostgresql/v1api20221201"
1515
hub "github.com/Azure/azure-service-operator/v2/api/dbforpostgresql/v1api20221201/storage"
16-
1716
"github.com/Azure/azure-service-operator/v2/internal/genericarmclient"
1817
"github.com/Azure/azure-service-operator/v2/internal/resolver"
1918
"github.com/Azure/azure-service-operator/v2/pkg/genruntime"

v2/api/dbforpostgresql/customizations/flexible_servers_firewall_rule_extensions.go

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"github.com/go-logr/logr"
1313

1414
postgresql "github.com/Azure/azure-service-operator/v2/api/dbforpostgresql/v1api20210601/storage"
15-
1615
"github.com/Azure/azure-service-operator/v2/internal/genericarmclient"
1716
"github.com/Azure/azure-service-operator/v2/internal/resolver"
1817
"github.com/Azure/azure-service-operator/v2/pkg/genruntime"

v2/api/devices/customizations/iot_hub_extensions.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ package customizations
88
import (
99
"context"
1010

11+
. "github.com/Azure/azure-service-operator/v2/internal/logging"
12+
1113
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
1214
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/iothub/armiothub"
1315
"github.com/go-logr/logr"
@@ -17,7 +19,6 @@ import (
1719

1820
devices "github.com/Azure/azure-service-operator/v2/api/devices/v1api20210702/storage"
1921
"github.com/Azure/azure-service-operator/v2/internal/genericarmclient"
20-
. "github.com/Azure/azure-service-operator/v2/internal/logging"
2122
"github.com/Azure/azure-service-operator/v2/internal/set"
2223
"github.com/Azure/azure-service-operator/v2/internal/util/to"
2324
"github.com/Azure/azure-service-operator/v2/pkg/genruntime"

v2/api/documentdb/customizations/database_account_extensions.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"context"
1010
"strings"
1111

12+
. "github.com/Azure/azure-service-operator/v2/internal/logging"
13+
1214
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/cosmos/armcosmos"
1315
"github.com/go-logr/logr"
1416
"github.com/pkg/errors"
@@ -17,7 +19,6 @@ import (
1719

1820
documentdb "github.com/Azure/azure-service-operator/v2/api/documentdb/v1api20231115/storage"
1921
"github.com/Azure/azure-service-operator/v2/internal/genericarmclient"
20-
. "github.com/Azure/azure-service-operator/v2/internal/logging"
2122
"github.com/Azure/azure-service-operator/v2/internal/resolver"
2223
"github.com/Azure/azure-service-operator/v2/internal/set"
2324
"github.com/Azure/azure-service-operator/v2/internal/util/to"

v2/api/eventgrid/customizations/topic_extension.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ package customizations
77
import (
88
"context"
99

10+
. "github.com/Azure/azure-service-operator/v2/internal/logging"
11+
1012
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/eventgrid/armeventgrid"
1113
"github.com/go-logr/logr"
1214
"github.com/pkg/errors"
@@ -15,7 +17,6 @@ import (
1517

1618
"github.com/Azure/azure-service-operator/v2/api/eventgrid/v1api20200601/storage"
1719
"github.com/Azure/azure-service-operator/v2/internal/genericarmclient"
18-
. "github.com/Azure/azure-service-operator/v2/internal/logging"
1920
"github.com/Azure/azure-service-operator/v2/internal/set"
2021
"github.com/Azure/azure-service-operator/v2/internal/util/to"
2122
"github.com/Azure/azure-service-operator/v2/pkg/genruntime"

v2/api/eventhub/customizations/namespace_extension.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ package customizations
88
import (
99
"context"
1010

11+
. "github.com/Azure/azure-service-operator/v2/internal/logging"
12+
1113
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/eventhub/armeventhub"
1214
"github.com/go-logr/logr"
1315
"github.com/pkg/errors"
@@ -16,7 +18,6 @@ import (
1618

1719
"github.com/Azure/azure-service-operator/v2/api/eventhub/v1api20211101/storage"
1820
"github.com/Azure/azure-service-operator/v2/internal/genericarmclient"
19-
. "github.com/Azure/azure-service-operator/v2/internal/logging"
2021
"github.com/Azure/azure-service-operator/v2/internal/set"
2122
"github.com/Azure/azure-service-operator/v2/internal/util/to"
2223
"github.com/Azure/azure-service-operator/v2/pkg/genruntime"

v2/api/eventhub/customizations/namespaces_authorization_rule_extension.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ package customizations
88
import (
99
"context"
1010

11+
. "github.com/Azure/azure-service-operator/v2/internal/logging"
12+
1113
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/eventhub/armeventhub"
1214
"github.com/go-logr/logr"
1315
"github.com/pkg/errors"
@@ -16,7 +18,6 @@ import (
1618

1719
"github.com/Azure/azure-service-operator/v2/api/eventhub/v1api20211101/storage"
1820
"github.com/Azure/azure-service-operator/v2/internal/genericarmclient"
19-
. "github.com/Azure/azure-service-operator/v2/internal/logging"
2021
"github.com/Azure/azure-service-operator/v2/internal/set"
2122
"github.com/Azure/azure-service-operator/v2/internal/util/to"
2223
"github.com/Azure/azure-service-operator/v2/pkg/genruntime"

v2/api/eventhub/customizations/namespaces_eventhubs_authorization_rule_extension.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ package customizations
88
import (
99
"context"
1010

11+
. "github.com/Azure/azure-service-operator/v2/internal/logging"
12+
1113
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/eventhub/armeventhub"
1214
"github.com/go-logr/logr"
1315
"github.com/pkg/errors"
@@ -16,7 +18,6 @@ import (
1618

1719
"github.com/Azure/azure-service-operator/v2/api/eventhub/v1api20211101/storage"
1820
"github.com/Azure/azure-service-operator/v2/internal/genericarmclient"
19-
. "github.com/Azure/azure-service-operator/v2/internal/logging"
2021
"github.com/Azure/azure-service-operator/v2/internal/set"
2122
"github.com/Azure/azure-service-operator/v2/internal/util/to"
2223
"github.com/Azure/azure-service-operator/v2/pkg/genruntime"

0 commit comments

Comments
 (0)