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
1 change: 0 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
target: ["verify", "lint", "test"]

Expand Down
51 changes: 31 additions & 20 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ linters:
- asciicheck
- bodyclose
- cyclop
- deadcode
#- depguard
- dogsled
- dupl
Expand All @@ -27,17 +26,15 @@ linters:
- gocyclo
- godot
# - godox
- goerr113
- err113
- gofmt
- gofumpt
- goheader
- goimports
- gomnd
- gomodguard
- goprintffuncname
- gosec
- gosimple
- ifshort
- importas
- ineffassign
# - interfacer
Expand All @@ -59,7 +56,6 @@ linters:
# - scopelint
- sqlclosecheck
- staticcheck
- structcheck
- stylecheck
- testpackage
- thelper
Expand All @@ -68,7 +64,6 @@ linters:
- unconvert
- unparam
- unused
- varcheck
- wastedassign
- whitespace
- wrapcheck
Expand All @@ -90,6 +85,9 @@ issues:
- linters:
- lll
path: "controllers/(.+)_test.go"
exclude-files:
- "zz_generated.*\\.go$"
- ".*conversion.*\\.go$"

linters-settings:
importas:
Expand All @@ -110,13 +108,15 @@ linters-settings:
- pkg: sigs.k8s.io/controller-runtime
alias: ctrl
gosimple:
go: "1.21"
checks: ["all"]
staticcheck:
go: "1.21"
checks: ["all"]
stylecheck:
go: "1.21"
checks: ["all"]
unused:
go: "1.21"
# Mark all struct fields that have been written to as used.
# Default: true
field-writes-are-uses: true
tagliatelle:
case:
# use-field-name: true
Expand All @@ -133,10 +133,26 @@ linters-settings:
# Forbid the use of the `exclude` directives. Default is false.
exclude-forbidden: false
gci:
# put imports beginning with prefix after 3rd-party packages;
# only support one prefix
# if not set, use goimports.local-prefixes
local-prefixes: github.com/tinkerbell/cluster-api-provider-tinkerbell
# Section configuration to compare against.
# Section names are case-insensitive and may contain parameters in ().
# The default order of sections is `standard > default > custom > blank > dot > alias > localmodule`,
# If `custom-order` is `true`, it follows the order of `sections` option.
# Default: ["standard", "default"]
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(github.com/tinkerbell/cluster-api-provider-tinkerbell) # Custom section: groups all imports with the specified Prefix.
- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
- dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled.
- alias # Alias section: contains all alias imports. This section is not present unless explicitly enabled.
- localmodule # Local module section: contains all local packages. This section is not present unless explicitly enabled.
# Skip generated files.
# Default: true
skip-generated: false
# Enable custom order of sections.
# If `true`, make the section order the same as the order of `sections`.
# Default: false
custom-order: true
goimports:
# put imports beginning with prefix after 3rd-party packages;
# it's a comma-separated list of prefixes
Expand All @@ -157,9 +173,4 @@ linters-settings:

run:
timeout: 10m
skip-files:
- "zz_generated.*\\.go$"
- ".*conversion.*\\.go$"
allow-parallel-runners: true
skip-dirs:
- tink/ # TODO: remove this line after #160 is merged. The /tink dir is going away
allow-parallel-runners: true
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ GO_INSTALL = ./scripts/go_install.sh
# Binaries.
CONTROLLER_GEN := go run sigs.k8s.io/controller-tools/cmd/[email protected]

GOLANGCI_LINT_VER := v1.54.2
GOLANGCI_LINT_VER := v1.59.1
GOLANGCI_LINT_BIN := golangci-lint
GOLANGCI_LINT := $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER)

Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/tinkerbellmachine_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package v1beta1_test
import (
"testing"

. "github.com/onsi/gomega"
. "github.com/onsi/gomega" //nolint:revive // one day we will remove gomega
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/tinkerbell/cluster-api-provider-tinkerbell/api/v1beta1"
Expand Down
3 changes: 2 additions & 1 deletion controllers/machine_reconcile_scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,8 @@ func (scope *machineReconcileScope) releaseHardware(hardware *tinkv1.Hardware) e
// setting the AllowPXE=true indicates to Smee that this hardware should be allowed
// to netboot. FYI, this is not authoritative.
// Other hardware values can be set to prohibit netbooting of a machine.
// See this Boots function for the logic around this: https://github.com/tinkerbell/smee/blob/main/internal/ipxe/script/ipxe.go#L112
// See this Boots function for the logic around this:
// https://github.com/tinkerbell/smee/blob/main/internal/ipxe/script/ipxe.go#L112
for _, ifc := range hardware.Spec.Interfaces {
if ifc.Netboot != nil {
ifc.Netboot.AllowPXE = ptr.To(true)
Expand Down
4 changes: 2 additions & 2 deletions controllers/machine_reconcile_scope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package controllers //nolint:testpackage
import (
"testing"

. "github.com/onsi/gomega"
. "github.com/onsi/gomega" //nolint:revive // one day we will remove gomega
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

Expand Down Expand Up @@ -48,7 +48,7 @@ func Test_Machine(t *testing.T) {
ready bool
}{
"is_not_ready_when_it_is_nil": {
mutateF: func(m *clusterv1.Machine) *clusterv1.Machine {
mutateF: func(_ *clusterv1.Machine) *clusterv1.Machine {
return nil
},
},
Expand Down
2 changes: 1 addition & 1 deletion controllers/tinkerbellcluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"testing"

"github.com/google/uuid"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega" //nolint:revive // one day we will remove gomega
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
Expand Down
4 changes: 3 additions & 1 deletion controllers/tinkerbellmachine_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/google/uuid"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega" //nolint:revive // one day we will remove gomega
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -431,6 +431,7 @@ func Test_Machine_reconciliation_with_available_hardware(t *testing.T) {

updatedHardware := &tinkv1.Hardware{}
g.Expect(client.Get(ctx, hardwareNamespacedName, updatedHardware)).To(Succeed())

if diff := cmp.Diff(updatedHardware.Spec.Interfaces[0].Netboot.AllowPXE, ptr.To(true)); diff != "" {
t.Errorf(diff)
}
Expand Down Expand Up @@ -565,6 +566,7 @@ func Test_Machine_reconciliation_workflow_complete(t *testing.T) {

updatedHardware := &tinkv1.Hardware{}
g.Expect(client.Get(ctx, hardwareNamespacedName, updatedHardware)).To(Succeed())

if diff := cmp.Diff(updatedHardware.Spec.Interfaces[0].Netboot.AllowPXE, ptr.To(false)); diff != "" {
t.Errorf(diff)
}
Expand Down
6 changes: 3 additions & 3 deletions internal/templates/templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package templates_test
import (
"testing"

. "github.com/onsi/gomega"
. "github.com/onsi/gomega" //nolint:revive // one day we will remove gomega
"sigs.k8s.io/yaml"

"github.com/tinkerbell/cluster-api-provider-tinkerbell/internal/templates"
Expand Down Expand Up @@ -62,11 +62,11 @@ func Test_Cloud_config_template(t *testing.T) {
},

"renders_with_valid_config": {
mutateF: func(wt *templates.WorkflowTemplate) {},
mutateF: func(_ *templates.WorkflowTemplate) {},
},

"rendered_output_should_be_valid_YAML": {
validateF: func(t *testing.T, wt *templates.WorkflowTemplate, renderResult string) { //nolint:thelper
validateF: func(t *testing.T, _ *templates.WorkflowTemplate, renderResult string) { //nolint:thelper
g := NewWithT(t)
x := &map[string]interface{}{}

Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,13 @@ func main() { //nolint:funlen
HealthProbeBindAddress: healthAddr,
EventBroadcaster: broadcaster,
}

if watchNamespace != "" {
opts.Cache = cache.Options{
DefaultNamespaces: map[string]cache.Config{watchNamespace: {}},
}
}

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), opts)
if err != nil {
setupLog.Error(err, "unable to start manager")
Expand Down