diff --git a/go/nautobotop/api/v1alpha1/nautobot_types.go b/go/nautobotop/api/v1alpha1/nautobot_types.go index c40d4ee6f..0741159d2 100644 --- a/go/nautobotop/api/v1alpha1/nautobot_types.go +++ b/go/nautobotop/api/v1alpha1/nautobot_types.go @@ -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 diff --git a/go/nautobotop/config/crd/bases/sync.rax.io_nautobots.yaml b/go/nautobotop/config/crd/bases/sync.rax.io_nautobots.yaml index 77dd5b4d7..109acaa74 100644 --- a/go/nautobotop/config/crd/bases/sync.rax.io_nautobots.yaml +++ b/go/nautobotop/config/crd/bases/sync.rax.io_nautobots.yaml @@ -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 diff --git a/go/nautobotop/helm/crds/clients.yaml b/go/nautobotop/helm/crds/clients.yaml index 8ca00d5a9..109acaa74 100644 --- a/go/nautobotop/helm/crds/clients.yaml +++ b/go/nautobotop/helm/crds/clients.yaml @@ -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 @@ -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. diff --git a/go/nautobotop/internal/controller/nautobot_controller.go b/go/nautobotop/internal/controller/nautobot_controller.go index 4c24f6707..4480cbad1 100644 --- a/go/nautobotop/internal/controller/nautobot_controller.go +++ b/go/nautobotop/internal/controller/nautobot_controller.go @@ -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{