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
10 changes: 9 additions & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
pull_request:
permissions: read-all
jobs:
run:
go-and-crds:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
Expand Down Expand Up @@ -58,3 +58,11 @@ jobs:
echo "Please run make generate manifests and commit the changes."
exit 1
fi
codespell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Run codespell
uses: codespell-project/actions-codespell@v2
with:
skip: '*.svg'
2 changes: 1 addition & 1 deletion docs/examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This folder shows some examples how the NetBox Operator can be used.

Each example folder contains a README.md which explains how you can set up your local enviroment to step through the examples.
Each example folder contains a README.md which explains how you can set up your local environment to step through the examples.

Prerequisites:
- go version v1.24.0+
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/example2-load-balancer-ip/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ kubectl get pxc,ipaddresspool -A
```bash
cat sample-deployment.yaml
```
5. Apply the manifests to createa deployment with a service that gets a ip assigned from the metalLB pool created in the prevoius step
5. Apply the manifests to create deployment with a service that gets a ip assigned from the metalLB pool created in the previous step
```bash
kubectl apply -f sample-deployment.yaml
```
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/example5-multicluster/zurich-pools.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ spec:
prefixLength: "/30"
parentPrefixSelector:
environment: prod
familiy: IPv4
family: IPv4
---
apiVersion: netbox.dev/v1
kind: PrefixClaim
Expand Down
8 changes: 4 additions & 4 deletions internal/controller/expected_netboxmock_calls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func mockIpAddressListWithIpAddressFilterEmptyResult(ipamMock *mock_interfaces.M
catchUnexpectedParams <- err
return &ipam.IpamIPAddressesListOK{Payload: nil}, err
}
fmt.Printf("NETBOXMOCK\t ipam.IpamIPAddressesList (empty reslut) was called with expected input,\n")
fmt.Printf("NETBOXMOCK\t ipam.IpamIPAddressesList (empty result) was called with expected input,\n")
return &ipam.IpamIPAddressesListOK{Payload: mockedResponseEmptyIPAddressList()}, nil
}).MinTimes(1)
}
Expand All @@ -71,7 +71,7 @@ func mockIpAddressListWithHashFilterEmptyResult(ipamMock *mock_interfaces.MockIp
catchUnexpectedParams <- err
return &ipam.IpamIPAddressesListOK{Payload: nil}, err
}
fmt.Printf("NETBOXMOCK\t ipam.IpamIPAddressesList (empty reslut) was called with expected input,\n")
fmt.Printf("NETBOXMOCK\t ipam.IpamIPAddressesList (empty result) was called with expected input,\n")
return &ipam.IpamIPAddressesListOK{Payload: mockedResponseEmptyIPAddressList()}, nil
}).MinTimes(1)
}
Expand All @@ -87,7 +87,7 @@ func mockIpAddressListWithHashFilter(ipamMock *mock_interfaces.MockIpamInterface
catchUnexpectedParams <- err
return &ipam.IpamIPAddressesListOK{Payload: nil}, err
}
fmt.Printf("NETBOXMOCK\t ipam.IpamIPAddressesList (empty reslut) was called with expected input,\n")
fmt.Printf("NETBOXMOCK\t ipam.IpamIPAddressesList (empty result) was called with expected input,\n")
return &ipam.IpamIPAddressesListOK{Payload: mockedResponseIPAddressList()}, nil
}).MinTimes(1)
}
Expand All @@ -103,7 +103,7 @@ func mockIpAddressListWithHashFilterMismatch(ipamMock *mock_interfaces.MockIpamI
catchUnexpectedParams <- err
return &ipam.IpamIPAddressesListOK{Payload: nil}, err
}
fmt.Printf("NETBOXMOCK\t ipam.IpamIPAddressesList (empty reslut) was called with expected input,\n")
fmt.Printf("NETBOXMOCK\t ipam.IpamIPAddressesList (empty result) was called with expected input,\n")
return &ipam.IpamIPAddressesListOK{Payload: mockedResponseIPAddressListWithHash(customFieldsWithHashMismatch)}, nil
}).MinTimes(1)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/prefixclaim_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (r *PrefixClaimReconciler) Reconcile(ctx context.Context, req ctrl.Request)
return ctrl.Result{Requeue: true}, nil
}
if len(parentPrefixCandidates) == 0 {
message := "no parent prefix found matching the parenPrefixSelector"
message := "no parent prefix found matching the parentPrefixSelector"
r.EventStatusRecorder.Recorder().Event(prefixClaim, corev1.EventTypeWarning, netboxv1.ConditionPrefixAssignedFalse.Reason, netboxv1.ConditionPrefixAssignedFalse.Message+": "+message)
if err := r.EventStatusRecorder.Report(ctx, prefixClaim, netboxv1.ConditionPrefixAssignedFalse, corev1.EventTypeWarning, errors.New(message)); err != nil {
return ctrl.Result{}, err
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/prefixclaim_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func testPrefixClaimHash(t *testing.T, prefixClaim *netboxv1.PrefixClaim, expect
generatedHash := generatePrefixRestorationHash(prefixClaim)

if generatedHash != expectedHash {
t.Errorf("hash mistatch: expected %#v, got %#v from %#v", expectedHash, generatedHash, prefixClaim)
t.Errorf("hash mismatch: expected %#v, got %#v from %#v", expectedHash, generatedHash, prefixClaim)
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/netbox/api/ip_address_claim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ func TestIPAddressClaim_GetNoAvailableIPAddressWithTenancyChecks(t *testing.T) {
mockTenancy := mock_interfaces.NewMockTenancyInterface(ctrl)

parentPrefix := "10.112.140.0/24"
t.Run("No IP address asigned with an error when getting the tenant list", func(t *testing.T) {
t.Run("No IP address assigned with an error when getting the tenant list", func(t *testing.T) {

tenantName := "Tenant1"

Expand Down Expand Up @@ -388,7 +388,7 @@ func TestIPAddressClaim_GetNoAvailableIPAddressWithTenancyChecks(t *testing.T) {
assert.Equal(t, actual, (*models.IPAddress)(nil))
})

t.Run("No IP address asigned with non-existing tenant", func(t *testing.T) {
t.Run("No IP address assigned with non-existing tenant", func(t *testing.T) {

// non existing tenant
nonExistingTenant := "non-existing-tenant"
Expand Down
2 changes: 1 addition & 1 deletion pkg/netbox/api/ip_address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func TestIPAddress(t *testing.T) {

t.Run("Reserve Static IP Address.", func(t *testing.T) {

// ip address mock inout
// ip address mock input
input := ipam.NewIpamIPAddressesCreateParams().WithDefaults().WithData(writeableAddress())
// ip address mock output
output := &ipam.IpamIPAddressesCreateCreated{
Expand Down
2 changes: 1 addition & 1 deletion pkg/netbox/api/ip_range_claim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestIPRangeClaim(t *testing.T) {
expectedIpDot5 := "10.112.140.5/32"
expectedIpDot7 := "10.112.140.7/32"

// example of available IPv4 ip adress
// example of available IPv4 ip address
availableIpAdressesIPv4 := func() []*netboxModels.AvailableIP {
return []*netboxModels.AvailableIP{
{
Expand Down
4 changes: 2 additions & 2 deletions pkg/netbox/api/prefix_claim.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (

var (
// TODO(henrybear327): centralize errors
ErrNoPrefixMatchsSizeCriteria = errors.New("no available prefix matches size criterias")
ErrNoPrefixMatchsSizeCriteria = errors.New("no available prefix matches size criteria")
)

func (r *NetboxClient) RestoreExistingPrefixByHash(hash string) (*models.Prefix, error) {
Expand Down Expand Up @@ -313,7 +313,7 @@ func (r *NetboxClient) GetAvailablePrefixesByParentPrefix(parentPrefixId int64)
}

func getSmallestMatchingPrefix(prefixList *ipam.IpamPrefixesAvailablePrefixesListOK, prefixClaimLengthString string) (string, bool, error) {
// input valiation
// input validation
if len(prefixClaimLengthString) == 0 {
return "", false, errors.New("invalid prefixClaimLengthString: empty string")
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/netbox/api/prefix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ func TestPrefix_ReserveOrUpdate(t *testing.T) {
}

_, err := netboxClient.ReserveOrUpdatePrefix(&prefixModel)
// skip assertion on retured values as the payload of IpamPrefixesCreate() is returened
// skip assertion on returned values as the payload of IpamPrefixesCreate() is returned
// without manipulation by the code
assert.Nil(t, err)
})
Expand Down Expand Up @@ -477,7 +477,7 @@ func TestPrefix_ReserveOrUpdate(t *testing.T) {
}

_, err := netboxClient.ReserveOrUpdatePrefix(&prefixModel)
// skip assertion on retured values as the payload of IpamPrefixesUpdate() is returened
// skip assertion on returned values as the payload of IpamPrefixesUpdate() is returned
// without manipulation by the code
assert.Nil(t, err)
})
Expand Down Expand Up @@ -519,7 +519,7 @@ func TestPrefix_ReserveOrUpdate(t *testing.T) {
}

_, err := netboxClient.ReserveOrUpdatePrefix(&prefixModel)
// skip assertion on retured values as the payload of IpamPrefixesCreate() is returened
// skip assertion on returned values as the payload of IpamPrefixesCreate() is returned
// without manipulation by the code
AssertError(t, err, "restoration hash mismatch, assigned prefix 10.112.140.0/24")
})
Expand Down
2 changes: 1 addition & 1 deletion pkg/netbox/api/site_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func TestSite_GetError(t *testing.T) {

siteListRequestInput := dcim.NewDcimSitesListParams().WithName(&site)

expectedErr := "error geting sites list"
expectedErr := "error getting sites list"

mockDcim.EXPECT().DcimSitesList(siteListRequestInput, nil).Return(nil, errors.New(expectedErr))
netboxClient := &NetboxClient{Dcim: mockDcim}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ kind: Test
metadata:
name: prefixclaim-ipv4-parentprefixselector-nonexisingcustomfield
annotations:
description: Tests if creation fails for parentPrefixSelector with non exising custom field
description: Tests if creation fails for parentPrefixSelector with non existing custom field
spec:
steps:
- name: Apply CR
Expand Down