Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ jobs:
with:
go-version-file: 'go.mod'
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v7
with:
version: v1.64
version: v2.0
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- run: make test
- run: make test-only
58 changes: 36 additions & 22 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,40 @@
run:
timeout: 10m

version: "2"
linters:
enable:
- revive
- ineffassign
- misspell
- goimports
- importas

- misspell
- revive
settings:
misspell:
ignore-rules:
- strat
revive:
severity: error
rules:
- name: exported
arguments:
- disableStutteringCheck
- name: if-return
disabled: true
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
severity:
default-severity: error

linters-settings:
misspell:
ignore-words:
- strat
revive:
severity: error
rules:
- name: exported
arguments:
- disableStutteringCheck
- name: if-return
disabled: true
default: error
formatters:
enable:
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ CONTROLLER_TOOLS_VERSION ?= v0.16.0
GEN_CRD_API_REFERENCE_DOCS_VERSION ?= v0.3.0
ADDLICENSE_VERSION ?= v1.1.1
GOIMPORTS_VERSION ?= v0.25.0
GOLANGCI_LINT_VERSION ?= v1.64
GOLANGCI_LINT_VERSION ?= v2.0
OPENAPI_EXTRACTOR_VERSION ?= v0.1.9

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
Expand Down Expand Up @@ -418,4 +418,4 @@ $(GOIMPORTS): $(LOCALBIN)
.PHONY: golangci-lint
golangci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
$(GOLANGCI_LINT): $(LOCALBIN)
test -s $(LOCALBIN)/golangci-lint || GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
test -s $(LOCALBIN)/golangci-lint || GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
12 changes: 6 additions & 6 deletions apimachinery/api/net/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (i IP) ToUnstructured() interface{} {
if i.IsZero() {
return nil
}
return i.Addr.String()
return i.String()
}

func (i *IP) IsValid() bool {
Expand All @@ -84,9 +84,9 @@ func (i IP) Family() v1.IPFamily {
}
}

func (_ IP) OpenAPISchemaType() []string { return []string{"string"} }
func (i IP) OpenAPISchemaType() []string { return []string{"string"} }

func (_ IP) OpenAPISchemaFormat() string { return "ip" }
func (i IP) OpenAPISchemaFormat() string { return "ip" }

func NewIP(ip netip.Addr) IP {
return IP{ip}
Expand Down Expand Up @@ -138,7 +138,7 @@ func (i IPPrefix) GomegaString() string {
}

func (i IPPrefix) IP() IP {
return IP{i.Prefix.Addr()}
return IP{i.Addr()}
}

func (i *IPPrefix) UnmarshalJSON(b []byte) error {
Expand Down Expand Up @@ -193,9 +193,9 @@ func (in *IPPrefix) IsZero() bool {
return in == nil || !in.Prefix.IsValid()
}

func (_ IPPrefix) OpenAPISchemaType() []string { return []string{"string"} }
func (in IPPrefix) OpenAPISchemaType() []string { return []string{"string"} }

func (_ IPPrefix) OpenAPISchemaFormat() string { return "ip-prefix" }
func (in IPPrefix) OpenAPISchemaFormat() string { return "ip-prefix" }

func NewIPPrefix(prefix netip.Prefix) *IPPrefix {
return &IPPrefix{Prefix: prefix}
Expand Down
6 changes: 3 additions & 3 deletions apinetlet/controllers/networkpolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,11 @@ func (r *NetworkPolicyReconciler) fetchIPsFromNetworkInterfaces(ctx context.Cont

for _, ip := range nic.Spec.IPs {
ipFamily := corev1.IPv4Protocol
if ip.Addr.Is6() {
if ip.Is6() {
ipFamily = corev1.IPv6Protocol
}
ips = append(ips, apinetv1alpha1.ObjectIP{
Prefix: net.IPPrefix{Prefix: netip.PrefixFrom(ip.Addr, ip.Addr.BitLen())},
Prefix: net.IPPrefix{Prefix: netip.PrefixFrom(ip.Addr, ip.BitLen())},
IPFamily: ipFamily,
})
}
Expand Down Expand Up @@ -364,7 +364,7 @@ func (r *NetworkPolicyReconciler) fetchIPsFromLoadBalancers(ctx context.Context,
for _, ip := range lb.Spec.IPs {
// TODO: handle LoadBalancerIP when only IPFamily is specified to allocate a random IP.
ips = append(ips, apinetv1alpha1.ObjectIP{
Prefix: net.IPPrefix{Prefix: netip.PrefixFrom(ip.IP.Addr, ip.IP.Addr.BitLen())},
Prefix: net.IPPrefix{Prefix: netip.PrefixFrom(ip.IP.Addr, ip.IP.BitLen())},
IPFamily: ip.IPFamily,
})
}
Expand Down
4 changes: 2 additions & 2 deletions internal/app/apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ func (o *IronCoreNetServerOptions) Run(ctx context.Context) error {
}

server.GenericAPIServer.AddPostStartHookOrDie("start-ironcore-net-server-informers", func(hookContext genericapiserver.PostStartHookContext) error {
config.GenericConfig.SharedInformerFactory.Start(hookContext.Context.Done())
o.SharedInformerFactory.Start(hookContext.Context.Done())
config.GenericConfig.SharedInformerFactory.Start(hookContext.Done())
o.SharedInformerFactory.Start(hookContext.Done())
return nil
})

Expand Down
2 changes: 1 addition & 1 deletion internal/controllers/certificateapproval_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (r *CertificateApprovalReconciler) authorize(ctx context.Context, csr *cert
ResourceAttributes: &attrs,
},
}
if err := r.Client.Create(ctx, sar); err != nil {
if err := r.Create(ctx, sar); err != nil {
return false, fmt.Errorf("error creating subject access review: %w", err)
}
return sar.Status.Allowed, nil
Expand Down
2 changes: 1 addition & 1 deletion internal/controllers/scheduler_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ func (r *SchedulerReconciler) reconcileExists(
return ctrl.Result{}, fmt.Errorf("error getting nodes for instance: %w", err)
}
if len(nodes) == 0 {
r.EventRecorder.Event(inst, corev1.EventTypeNormal, outOfCapacity, "No nodes available to schedule instance on")
r.Event(inst, corev1.EventTypeNormal, outOfCapacity, "No nodes available to schedule instance on")
return ctrl.Result{}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion internal/controllers/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func ReplaceDaemonSetInstanceNodeNameNodeAffinity(affinity *v1alpha1.Affinity, n
// avoid bad words.
func ComputeHash(template *v1alpha1.InstanceTemplate, collisionCount *int32) string {
podTemplateSpecHasher := fnv.New32a()
_, _ = podTemplateSpecHasher.Write([]byte(fmt.Sprintf("%#+v", *template)))
_, _ = fmt.Fprintf(podTemplateSpecHasher, "%#+v", *template)

// Add collisionCount in the hash if it exists.
if collisionCount != nil {
Expand Down
Loading