Skip to content

Commit

Permalink
chore(linter): in switch case default signifies exhaustive match and …
Browse files Browse the repository at this point in the history
…fix forbidigo (#850)
  • Loading branch information
programmer04 committed Oct 25, 2023
1 parent 2a827a3 commit 331bf79
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ linters:
- wastedassign

linters-settings:
exhaustive:
default-signifies-exhaustive: true
gci:
sections:
- standard
Expand Down Expand Up @@ -82,7 +84,7 @@ linters-settings:
- pkg: sigs.k8s.io/gateway-api/apis/(v[\w\d]+)
alias: gateway${1}
forbidigo:
exclude_godoc_examples: false
exclude-godoc-examples: false
forbid:
- 'CoreV1\(\)\.Endpoints(# use DiscoveryV1 EndpointSlices API instead)?'
- 'corev1\.Endpoint(# use DiscoveryV1 EndpointSlices API instead)?'
Expand Down
2 changes: 1 addition & 1 deletion pkg/clusters/addons/kong/addon.go
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ func urlForService(ctx context.Context, cluster clusters.Cluster, nsn types.Name
return nil, err
}

switch service.Spec.Type { //nolint:exhaustive
switch service.Spec.Type {
case corev1.ServiceTypeLoadBalancer:
if len(service.Status.LoadBalancer.Ingress) == 1 {
return url.Parse(fmt.Sprintf("http://%s:%d", service.Status.LoadBalancer.Ingress[0].IP, port))
Expand Down
3 changes: 2 additions & 1 deletion pkg/clusters/addons/kong/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,15 @@ func (b *Builder) Build() *Addon {
}

// LoadBalancer is used by default for historical and convenience reasons.
switch b.proxyServiceType { //nolint:exhaustive
switch b.proxyServiceType {
case "":
b.proxyServiceType = corev1.ServiceTypeLoadBalancer
case corev1.ServiceTypeNodePort:
// If the proxy service type is NodePort, then set the default proxy NodePort.
if b.httpNodePort == 0 {
b.httpNodePort = DefaultProxyNodePort
}
default:
}

return &Addon{
Expand Down

0 comments on commit 331bf79

Please sign in to comment.