From 2968dd23dd941e74ff75563bce65ec152ac0439e Mon Sep 17 00:00:00 2001 From: Stefan Prodan Date: Fri, 21 Jun 2024 11:15:57 +0300 Subject: [PATCH] Update report after entitlement verification Signed-off-by: Stefan Prodan --- api/v1/fluxreport_types.go | 2 ++ config/crd/bases/fluxcd.controlplane.io_fluxreports.yaml | 7 +++++++ internal/controller/entitlement_controller.go | 8 ++++++++ 3 files changed, 17 insertions(+) diff --git a/api/v1/fluxreport_types.go b/api/v1/fluxreport_types.go index 5563487..46ab93a 100644 --- a/api/v1/fluxreport_types.go +++ b/api/v1/fluxreport_types.go @@ -136,9 +136,11 @@ type FluxReportStatus struct { // +kubebuilder:storageversion // +kubebuilder:object:root=true // +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="Entitlement",type="string",JSONPath=".spec.distribution.entitlement",description="",priority=10 // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="" // +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",description="" // +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message",description="" +// +kubebuilder:printcolumn:name="LastUpdated",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].lastTransitionTime",description="" // FluxReport is the Schema for the fluxreports API. type FluxReport struct { diff --git a/config/crd/bases/fluxcd.controlplane.io_fluxreports.yaml b/config/crd/bases/fluxcd.controlplane.io_fluxreports.yaml index 767b8eb..883f7e8 100644 --- a/config/crd/bases/fluxcd.controlplane.io_fluxreports.yaml +++ b/config/crd/bases/fluxcd.controlplane.io_fluxreports.yaml @@ -15,6 +15,10 @@ spec: scope: Namespaced versions: - additionalPrinterColumns: + - jsonPath: .spec.distribution.entitlement + name: Entitlement + priority: 10 + type: string - jsonPath: .metadata.creationTimestamp name: Age type: date @@ -24,6 +28,9 @@ spec: - jsonPath: .status.conditions[?(@.type=="Ready")].message name: Status type: string + - jsonPath: .status.conditions[?(@.type=="Ready")].lastTransitionTime + name: LastUpdated + type: string name: v1 schema: openAPIV3Schema: diff --git a/internal/controller/entitlement_controller.go b/internal/controller/entitlement_controller.go index 578ae31..078a2db 100644 --- a/internal/controller/entitlement_controller.go +++ b/internal/controller/entitlement_controller.go @@ -21,7 +21,9 @@ import ( "sigs.k8s.io/controller-runtime/pkg/predicate" "sigs.k8s.io/controller-runtime/pkg/ratelimiter" + fluxcdv1 "github.com/controlplaneio-fluxcd/flux-operator/api/v1" "github.com/controlplaneio-fluxcd/flux-operator/internal/entitlement" + "github.com/controlplaneio-fluxcd/flux-operator/internal/reporter" ) // EntitlementReconciler reconciles entitlements. @@ -76,6 +78,12 @@ func (r *EntitlementReconciler) Reconcile(ctx context.Context, req ctrl.Request) log.Info("Entitlement registered", "vendor", r.EntitlementClient.GetVendor()) + if err := reporter.RequestReportUpdate(ctx, + r.Client, fluxcdv1.DefaultInstanceName, + r.StatusManager, r.WatchNamespace); err != nil { + log.Error(err, "failed to request report update") + } + // Requeue to verify the token. return ctrl.Result{Requeue: true}, nil }