Skip to content

Commit f6ffb2f

Browse files
committed
chore: fix linting issues and formatting
Signed-off-by: abasitt <abdul.basit@rakuten.com>
1 parent b90ef2a commit f6ffb2f

File tree

10 files changed

+19
-16
lines changed

10 files changed

+19
-16
lines changed

pkg/apis/kubeovn/v1/provider-network.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ type ProviderNetworkSpec struct {
4040
// Enable automatic detection and preservation of existing VLAN interfaces on the default interface
4141
PreserveVlanInterfaces bool `json:"preserveVlanInterfaces,omitempty"`
4242
// Explicit list of VLAN interface names to preserve (e.g., eth0.10, bond0.20)
43-
VlanInterfaces []string `json:"vlanInterfaces,omitempty"`
43+
VlanInterfaces []string `json:"vlanInterfaces,omitempty"`
4444
}
4545

4646
type ProviderNetworkCondition struct {

pkg/apis/kubeovn/v1/register_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ func TestAddResources(t *testing.T) {
8181
}
8282

8383
var hasTypeMeta, hasObjMeta, hasListMeta bool
84-
for i := range st.NumFields() {
85-
v := st.Field(i)
84+
for v := range st.Fields() {
85+
v := v
8686
if !v.Embedded() || !v.Exported() {
8787
continue
8888
}

pkg/controller/deployment.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ var (
1818
)
1919

2020
func init() {
21-
name := reflect.TypeOf(&appsv1.Deployment{}).Elem().Name()
21+
name := reflect.TypeFor[appsv1.Deployment]().Name()
2222
gvk := appsv1.SchemeGroupVersion.WithKind(name)
2323
deploymentGroupVersion = gvk.GroupVersion().String()
2424
deploymentKind = gvk.Kind
2525

26-
name = reflect.TypeOf(&kubeovnv1.VpcEgressGateway{}).Elem().Name()
26+
name = reflect.TypeFor[kubeovnv1.VpcEgressGateway]().Name()
2727
gvk = kubeovnv1.SchemeGroupVersion.WithKind(name)
2828
vpcEgressGatewayGroupVersion = gvk.GroupVersion().String()
2929
vpcEgressGatewayKind = gvk.Kind

pkg/daemon/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func InitMirror(config *Configuration) error {
9797
return configureEmptyMirror(config.MirrorNic, config.MTU)
9898
}
9999

100-
func (c *Controller) ovsInitProviderNetwork(provider, nic string, trunks []string, exchangeLinkName, macLearningFallback bool, vlanInterfaceMap map[string]int) (int, error) { // create and configure external bridge
100+
func (c *Controller) ovsInitProviderNetwork(provider, nic string, trunks []string, exchangeLinkName, macLearningFallback bool, vlanInterfaceMap map[string]int) (int, error) { // create and configure external bridge
101101
brName := util.ExternalBridgeName(provider)
102102
if exchangeLinkName {
103103
exchanged, err := c.changeProvideNicName(nic, brName)

pkg/daemon/ovs_linux.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,10 +1950,12 @@ func (c *Controller) configProviderVlanInterfaces(vlanInterfaceMap map[string]in
19501950
internalPortName := fmt.Sprintf("%s-vlan%d", brName, vlanID)
19511951

19521952
// Create OVS internal port
1953-
args := []string{ovs.MayExist, "add-port", brName, internalPortName,
1953+
args := []string{
1954+
ovs.MayExist, "add-port", brName, internalPortName,
19541955
"--", "set", "interface", internalPortName, "type=internal",
19551956
"--", "set", "port", internalPortName, fmt.Sprintf("tag=%d", vlanID),
1956-
"external_ids:vendor=" + util.CniTypeName}
1957+
"external_ids:vendor=" + util.CniTypeName,
1958+
}
19571959

19581960
if _, err := ovs.Exec(args...); err != nil {
19591961
klog.Errorf("failed to create OVS internal port %s: %v", internalPortName, err)
@@ -2163,4 +2165,4 @@ func (c *Controller) removeProviderVlanInterface(internalPortName, brName string
21632165
}
21642166

21652167
return nil
2166-
}
2168+
}

pkg/util/ippool.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,11 @@ func ipToCIDR(value string) (string, error) {
161161
// simplifyOVNAddress removes /32 and /128 suffixes for single IP addresses in OVN address sets.
162162
// OVN accepts both "10.0.0.1" and "10.0.0.1/32", but the former is simpler.
163163
func simplifyOVNAddress(cidr string) string {
164-
if strings.HasSuffix(cidr, "/32") {
165-
return strings.TrimSuffix(cidr, "/32")
164+
if before, ok := strings.CutSuffix(cidr, "/32"); ok {
165+
return before
166166
}
167-
if strings.HasSuffix(cidr, "/128") {
168-
return strings.TrimSuffix(cidr, "/128")
167+
if before, ok := strings.CutSuffix(cidr, "/128"); ok {
168+
return before
169169
}
170170
return cidr
171171
}

pkg/util/vlan_interfaces_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,4 @@ func TestExtractVlanIDFromInterface(t *testing.T) {
180180
}
181181
})
182182
}
183-
}
183+
}

test/e2e/framework/http/http.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//nolint:revive // existing package name conflict
12
package http
23

34
import (

test/e2e/framework/iproute/iproute.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ func RouteShow(table, device string, execFunc ExecFunc) ([]Route, error) {
182182
// ignore the following error:
183183
// Error: ipv4/ipv6: FIB table does not exist.
184184
// Dump terminated
185-
e.ignoredErrors = append(e.ignoredErrors, reflect.TypeOf(docker.ErrNonZeroExitCode{}))
185+
e.ignoredErrors = append(e.ignoredErrors, reflect.TypeFor[docker.ErrNonZeroExitCode]())
186186
args = " table " + table
187187
}
188188
args += devArg(device)

test/e2e/vpc-egress-gateway/e2e_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ func vegTest(f *framework.Framework, bfd bool, provider, nadName, vpcName, inter
511511
deploy := deployClient.Get(veg.Status.Workload.Name)
512512
framework.ExpectEqual(deploy.Status.Replicas, replicas)
513513
framework.ExpectEqual(deploy.Status.ReadyReplicas, replicas)
514-
gvk := appsv1.SchemeGroupVersion.WithKind(reflect.TypeOf(deploy).Elem().Name())
514+
gvk := appsv1.SchemeGroupVersion.WithKind(reflect.TypeFor[appsv1.Deployment]().Name())
515515
framework.ExpectEqual(veg.Status.Workload.APIVersion, gvk.GroupVersion().String())
516516
framework.ExpectEqual(veg.Status.Workload.Kind, gvk.Kind)
517517
framework.ExpectHaveLen(veg.Status.Workload.Nodes, int(replicas))

0 commit comments

Comments
 (0)