Skip to content

Commit 88fe92f

Browse files
authored
chore(linter): in switch case default signifies exhaustive match (#4920)
1 parent 4f7dc01 commit 88fe92f

File tree

6 files changed

+9
-7
lines changed

6 files changed

+9
-7
lines changed

.golangci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ linters:
4747
- unused
4848
- wastedassign
4949
linters-settings:
50+
exhaustive:
51+
default-signifies-exhaustive: true
5052
gci:
5153
sections:
5254
- standard

internal/admission/handler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func (h RequestHandler) handleKongConsumer(
140140
return nil, err
141141
}
142142

143-
switch request.Operation { //nolint:exhaustive
143+
switch request.Operation {
144144
case admissionv1.Create:
145145
ok, msg, err := h.Validator.ValidateConsumer(ctx, consumer)
146146
if err != nil {
@@ -241,7 +241,7 @@ func (h RequestHandler) handleSecret(
241241
return responseBuilder.Allowed(true).Build(), nil
242242
}
243243

244-
switch request.Operation { //nolint:exhaustive
244+
switch request.Operation {
245245
case admissionv1.Update, admissionv1.Create:
246246
ok, message, err := h.Validator.ValidateCredential(ctx, secret)
247247
if err != nil {

internal/controllers/gateway/gateway_utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ func getListenerStatus(
466466
if len(conflictReason) > 0 {
467467
for _, cond := range statuses[listener.Name].Conditions {
468468
// shut up linter, there's a default
469-
switch gatewayapi.ListenerConditionType(cond.Type) { //nolint:exhaustive
469+
switch gatewayapi.ListenerConditionType(cond.Type) {
470470
case gatewayapi.ListenerConditionProgrammed, gatewayapi.ListenerConditionConflicted:
471471
continue
472472
default:

internal/manager/setup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ func generateAddressFinderGetter(mgrc client.Client, publishServiceNn k8stypes.N
246246
}
247247

248248
var addrs []string
249-
switch svc.Spec.Type { //nolint:exhaustive
249+
switch svc.Spec.Type {
250250
case corev1.ServiceTypeLoadBalancer:
251251
for _, lbaddr := range svc.Status.LoadBalancer.Ingress {
252252
if lbaddr.IP != "" {

test/e2e/utils_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ func getKongProxyIP(ctx context.Context, t *testing.T, env environments.Environm
221221
svc := refreshService()
222222
require.NotEqual(t, svc.Spec.Type, corev1.ServiceTypeClusterIP, "ClusterIP service is not supported")
223223

224-
switch svc.Spec.Type { //nolint:exhaustive
224+
switch svc.Spec.Type {
225225
case corev1.ServiceTypeLoadBalancer:
226226
return getKongProxyLoadBalancerIP(t, refreshService)
227227
case corev1.ServiceTypeNodePort:

test/integration/helpers_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ func gatewayLinkStatusMatches(
262262
namespace, name string,
263263
) bool {
264264
// gather a fresh copy of the route, given the specific protocol type
265-
switch protocolType { //nolint:exhaustive
265+
switch protocolType {
266266
case gatewayapi.HTTPProtocolType:
267267
route, err := c.GatewayV1().HTTPRoutes(namespace).Get(ctx, name, metav1.GetOptions{})
268268
groute, gerr := c.GatewayV1alpha2().GRPCRoutes(namespace).Get(ctx, name, metav1.GetOptions{})
@@ -346,7 +346,7 @@ func verifyProgrammedConditionStatus(t *testing.T,
346346
ctx := context.Background()
347347

348348
// gather a fresh copy of the route, given the specific protocol type
349-
switch protocolType { //nolint:exhaustive
349+
switch protocolType {
350350
case gatewayapi.HTTPProtocolType:
351351
route, err := c.GatewayV1().HTTPRoutes(namespace).Get(ctx, name, metav1.GetOptions{})
352352
groute, gerr := c.GatewayV1alpha2().GRPCRoutes(namespace).Get(ctx, name, metav1.GetOptions{})

0 commit comments

Comments
 (0)