Skip to content

Commit

Permalink
Update report after entitlement verification
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Prodan <[email protected]>
  • Loading branch information
stefanprodan committed Jun 21, 2024
1 parent 1e032f5 commit 2968dd2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api/v1/fluxreport_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions config/crd/bases/fluxcd.controlplane.io_fluxreports.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions internal/controller/entitlement_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 2968dd2

Please sign in to comment.