Skip to content
4 changes: 4 additions & 0 deletions internal/controller/ipaddressclaim_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ func (r *IpAddressClaimReconciler) Reconcile(ctx context.Context, req ctrl.Reque
ipAddress.Spec.Comments = updatedIpAddressSpec.Comments
ipAddress.Spec.Description = updatedIpAddressSpec.Description
ipAddress.Spec.PreserveInNetbox = updatedIpAddressSpec.PreserveInNetbox
err = controllerutil.SetControllerReference(o, ipAddress, r.Scheme)
if err != nil {
return err
}
return nil
})
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions internal/controller/iprangeclaim_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ func (r *IpRangeClaimReconciler) Reconcile(ctx context.Context, req ctrl.Request
// update spec of IpRange object
logger.V(4).Info("update iprange resource")
ipRange.Spec = generateIpRangeSpec(o, ipRange.Spec.StartAddress, ipRange.Spec.EndAddress, logger)
err = controllerutil.SetControllerReference(o, ipRange, r.Scheme)
if err != nil {
return ctrl.Result{}, err
}

err = r.Client.Update(ctx, ipRange)
if err != nil {
return ctrl.Result{}, err
Expand Down
4 changes: 4 additions & 0 deletions internal/controller/prefixclaim_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,10 @@ func (r *PrefixClaimReconciler) Reconcile(ctx context.Context, req ctrl.Request)
prefix.Spec.Description = updatedPrefixSpec.Description
prefix.Spec.Comments = updatedPrefixSpec.Comments
prefix.Spec.PreserveInNetbox = updatedPrefixSpec.PreserveInNetbox
err = controllerutil.SetControllerReference(prefixClaim, prefix, r.Scheme)
if err != nil {
return err
}
return nil
}); err != nil {
return ctrl.Result{}, err
Expand Down
6 changes: 3 additions & 3 deletions kind/load-local-data-job/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ class Prefix:
),
Prefix(
prefix="3.0.5.0/24",
description="",
description="chainsaw test prefixclaim-ipv4-update-ownerreference",
site=None,
tenant={
"name": "MY_TENANT",
Expand Down Expand Up @@ -525,7 +525,7 @@ class Prefix:
),
Prefix(
prefix="3.1.3.0/24",
description="",
description="chainsaw test ipaddressclaim-ipv4-update-ownerreference",
site=None,
tenant={
"name": "MY_TENANT",
Expand Down Expand Up @@ -766,7 +766,7 @@ class Prefix:
),
Prefix(
prefix="3.2.4.0/24",
description="",
description="chainsaw test iprangeclaim-ipv4-update-ownerreference",
site=None,
tenant={
"name": "MY_TENANT",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
Expand Down Expand Up @@ -54,4 +53,4 @@ spec:
cleanup:
- script:
content: |
kubectl delete events --field-selector involvedObject.name=prefixclaim-ipv4-invalid-parentprefixselector -n $NAMESPACE
kubectl delete events --field-selector involvedObject.name=prefixclaim-ipv4-invalid-parentprefixselector -n $NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: netbox.dev/v1
kind: PrefixClaim
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
Expand Down Expand Up @@ -84,4 +83,4 @@ spec:
cleanup:
- script:
content: |
kubectl delete events --field-selector involvedObject.name=prefixclaim-ipv4-parentprefix-apply-update -n $NAMESPACE
kubectl delete events --field-selector involvedObject.name=prefixclaim-ipv4-parentprefix-apply-update -n $NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: netbox.dev/v1
kind: PrefixClaim
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: netbox.dev/v1
kind: PrefixClaim
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
Expand Down Expand Up @@ -133,46 +132,46 @@ spec:
- name: Set preserveInNetbox to false
description: Set preserveInNetbox to false to clean up the NetBox test instance
try:
- patch:
resource:
apiVersion: netbox.dev/v1
kind: PrefixClaim
metadata:
name: prefixclaim-ipv4-parentprefix-restore-1
spec:
preserveInNetbox: false
- patch:
resource:
apiVersion: netbox.dev/v1
kind: PrefixClaim
metadata:
name: prefixclaim-ipv4-parentprefix-restore-2
spec:
preserveInNetbox: false
- assert:
resource:
apiVersion: netbox.dev/v1
kind: Prefix
metadata:
name: prefixclaim-ipv4-parentprefix-restore-1
status:
(conditions[?type == 'Ready']):
- observedGeneration: 2
status: 'True'
- assert:
resource:
apiVersion: netbox.dev/v1
kind: Prefix
metadata:
name: prefixclaim-ipv4-parentprefix-restore-2
status:
(conditions[?type == 'Ready']):
- observedGeneration: 2
status: 'True'
- patch:
resource:
apiVersion: netbox.dev/v1
kind: PrefixClaim
metadata:
name: prefixclaim-ipv4-parentprefix-restore-1
spec:
preserveInNetbox: false
- patch:
resource:
apiVersion: netbox.dev/v1
kind: PrefixClaim
metadata:
name: prefixclaim-ipv4-parentprefix-restore-2
spec:
preserveInNetbox: false
- assert:
resource:
apiVersion: netbox.dev/v1
kind: Prefix
metadata:
name: prefixclaim-ipv4-parentprefix-restore-1
status:
(conditions[?type == 'Ready']):
- observedGeneration: 2
status: 'True'
- assert:
resource:
apiVersion: netbox.dev/v1
kind: Prefix
metadata:
name: prefixclaim-ipv4-parentprefix-restore-2
status:
(conditions[?type == 'Ready']):
- observedGeneration: 2
status: 'True'
- name: Cleanup events
description: Events cleanup required to fix issues with failing tests that assert the wrong Error resource
cleanup:
- script:
content: |
kubectl delete events --field-selector involvedObject.name=prefixclaim-ipv4-parentprefix-restore-1 -n $NAMESPACE
kubectl delete events --field-selector involvedObject.name=prefixclaim-ipv4-parentprefix-restore-2 -n $NAMESPACE
kubectl delete events --field-selector involvedObject.name=prefixclaim-ipv4-parentprefix-restore-1 -n $NAMESPACE
kubectl delete events --field-selector involvedObject.name=prefixclaim-ipv4-parentprefix-restore-2 -n $NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: netbox.dev/v1
kind: PrefixClaim
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: netbox.dev/v1
kind: PrefixClaim
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
Expand Down Expand Up @@ -63,4 +62,4 @@ spec:
cleanup:
- script:
content: |
kubectl delete events --field-selector involvedObject.name=prefixclaim-ipv4-parentprefixselector-nonexisingcustomfield -n $NAMESPACE
kubectl delete events --field-selector involvedObject.name=prefixclaim-ipv4-parentprefixselector-nonexisingcustomfield -n $NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: netbox.dev/v1
kind: PrefixClaim
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
Expand Down Expand Up @@ -146,28 +145,28 @@ spec:
- name: Set preserveInNetbox to false
description: Set preserveInNetbox to false to clean up the NetBox test instance
try:
- patch:
resource:
apiVersion: netbox.dev/v1
kind: PrefixClaim
metadata:
name: prefixclaim-ipv4-parentprefixselector-restore-1
spec:
preserveInNetbox: false
- assert:
resource:
apiVersion: netbox.dev/v1
kind: Prefix
metadata:
name: prefixclaim-ipv4-parentprefixselector-restore-1
status:
(conditions[?type == 'Ready']):
- observedGeneration: 2
status: 'True'
- patch:
resource:
apiVersion: netbox.dev/v1
kind: PrefixClaim
metadata:
name: prefixclaim-ipv4-parentprefixselector-restore-1
spec:
preserveInNetbox: false
- assert:
resource:
apiVersion: netbox.dev/v1
kind: Prefix
metadata:
name: prefixclaim-ipv4-parentprefixselector-restore-1
status:
(conditions[?type == 'Ready']):
- observedGeneration: 2
status: 'True'
- name: Cleanup events
description: Events cleanup required to fix issues with failing tests that assert the wrong Error resource
cleanup:
- script:
content: |
kubectl delete events --field-selector involvedObject.name=prefixclaim-ipv4-parentprefixselector-restore-1 -n $NAMESPACE
kubectl delete events --field-selector involvedObject.name=prefixclaim-ipv4-parentprefixselector-restore-2 -n $NAMESPACE
kubectl delete events --field-selector involvedObject.name=prefixclaim-ipv4-parentprefixselector-restore-1 -n $NAMESPACE
kubectl delete events --field-selector involvedObject.name=prefixclaim-ipv4-parentprefixselector-restore-2 -n $NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: netbox.dev/v1
kind: PrefixClaim
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: netbox.dev/v1
kind: PrefixClaim
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
Expand Down Expand Up @@ -53,27 +52,27 @@ spec:
- name: Set preserveInNetbox to false
description: Set preserveInNetbox to false to clean up the NetBox test instance
try:
- patch:
resource:
apiVersion: netbox.dev/v1
kind: PrefixClaim
metadata:
name: prefixclaim-ipv4-parentprefixselector-apply
spec:
preserveInNetbox: false
- assert:
resource:
apiVersion: netbox.dev/v1
kind: Prefix
metadata:
name: prefixclaim-ipv4-parentprefixselector-apply
status:
(conditions[?type == 'Ready']):
- observedGeneration: 2
status: 'True'
- patch:
resource:
apiVersion: netbox.dev/v1
kind: PrefixClaim
metadata:
name: prefixclaim-ipv4-parentprefixselector-apply
spec:
preserveInNetbox: false
- assert:
resource:
apiVersion: netbox.dev/v1
kind: Prefix
metadata:
name: prefixclaim-ipv4-parentprefixselector-apply
status:
(conditions[?type == 'Ready']):
- observedGeneration: 2
status: 'True'
- name: Cleanup events
description: Events cleanup required to fix issues with failing tests that assert the wrong Error resource
cleanup:
- script:
content: |
kubectl delete events --field-selector involvedObject.name=prefixclaim-ipv4-parentprefixselector-apply -n $NAMESPACE
kubectl delete events --field-selector involvedObject.name=prefixclaim-ipv4-parentprefixselector-apply -n $NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: netbox.dev/v1
kind: PrefixClaim
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
Expand Down Expand Up @@ -103,6 +102,6 @@ spec:
cleanup:
- script:
content: |
kubectl delete events --field-selector involvedObject.name=prefixclaim-ipv4-prefixexhausted-1 -n $NAMESPACE
kubectl delete events --field-selector involvedObject.name=prefixclaim-ipv4-prefixexhausted-2 -n $NAMESPACE
kubectl delete events --field-selector involvedObject.name=prefixclaim-ipv4-prefixexhausted-3 -n $NAMESPACE
kubectl delete events --field-selector involvedObject.name=prefixclaim-ipv4-prefixexhausted-1 -n $NAMESPACE
kubectl delete events --field-selector involvedObject.name=prefixclaim-ipv4-prefixexhausted-2 -n $NAMESPACE
kubectl delete events --field-selector involvedObject.name=prefixclaim-ipv4-prefixexhausted-3 -n $NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: netbox.dev/v1
kind: PrefixClaim
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: netbox.dev/v1
kind: PrefixClaim
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: netbox.dev/v1
kind: PrefixClaim
metadata:
Expand Down
Loading