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
2 changes: 2 additions & 0 deletions go/nautobotop/api/v1alpha1/nautobot_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (

// NautobotSpec defines the desired state of Nautobot.
type NautobotSpec struct {
// +kubebuilder:default=true
IsEnabled bool `json:"isEnabled,omitempty"`
// +kubebuilder:default=600
RequeueAfter int `json:"requeueAfter,omitempty"`
// +kubebuilder:default=172800
Expand Down
3 changes: 3 additions & 0 deletions go/nautobotop/config/crd/bases/sync.rax.io_nautobots.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ spec:
- name
type: object
type: array
isEnabled:
default: true
type: boolean
locationRef:
items:
description: ConfigMapRef defines a reference to a specific ConfigMap
Expand Down
32 changes: 32 additions & 0 deletions go/nautobotop/helm/crds/clients.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ spec:
- name
type: object
type: array
isEnabled:
default: true
type: boolean
locationRef:
items:
description: ConfigMapRef defines a reference to a specific ConfigMap
Expand Down Expand Up @@ -243,6 +246,35 @@ spec:
syncIntervalSeconds:
default: 172800
type: integer
vlanGroupRef:
items:
description: ConfigMapRef defines a reference to a specific ConfigMap
properties:
configMapSelector:
description: The name of the ConfigMap resource being referred
to
properties:
key:
description: The key in the ConfigMap data
type: string
name:
description: The name of the ConfigMap
minLength: 1
type: string
namespace:
description: The namespace where the ConfigMap resides
type: string
required:
- name
type: object
name:
description: Name of this config set (logical name)
type: string
required:
- configMapSelector
- name
type: object
type: array
type: object
status:
description: NautobotStatus defines the observed state of Nautobot.
Expand Down
8 changes: 7 additions & 1 deletion go/nautobotop/internal/controller/nautobot_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,15 @@ func (r *NautobotReconciler) Reconcile(ctx context.Context, req ctrl.Request) (c
return ctrl.Result{}, client.IgnoreNotFound(err)
}

syncInterval := time.Duration(nautobotCR.Spec.SyncIntervalSeconds) * time.Second
requeueAfter := time.Duration(nautobotCR.Spec.RequeueAfter) * time.Second

if !nautobotCR.Spec.IsEnabled {
log.Info("reconciliation is disabled for this resource", "name", req.NamespacedName)
return ctrl.Result{RequeueAfter: requeueAfter}, nil
}

syncInterval := time.Duration(nautobotCR.Spec.SyncIntervalSeconds) * time.Second

// Define all resources to sync
// Add more resources here: {name: "location", configRefs: nautobotCR.Spec.LocationsRef, syncFunc: r.syncLocations}
resources := []resourceConfig{
Expand Down
Loading