Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add revision to print columns #12

Merged
merged 1 commit into from
May 31, 2024
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
1 change: 1 addition & 0 deletions api/v1/fluxinstance_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ func (in *FluxInstance) GetTimeout() time.Duration {
// +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="Revision",type="string",JSONPath=".status.lastAttemptedRevision",description=""

// FluxInstance is the Schema for the fluxinstances API
type FluxInstance struct {
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/fluxcd.controlplane.io_fluxinstances.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ spec:
- jsonPath: .status.conditions[?(@.type=="Ready")].message
name: Status
type: string
- jsonPath: .status.lastAttemptedRevision
name: Revision
type: string
name: v1
schema:
openAPIV3Schema:
Expand Down
10 changes: 9 additions & 1 deletion internal/controller/fluxinstance_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (r *FluxInstanceReconciler) reconcile(ctx context.Context,

// Mark the object as ready.
obj.Status.LastAppliedRevision = obj.Status.LastAttemptedRevision
msg = fmt.Sprintf("Reconciliation finished in %s", time.Since(reconcileStart).String())
msg = fmt.Sprintf("Reconciliation finished in %s", fmtDuration(reconcileStart))
conditions.MarkTrue(obj,
meta.ReadyCondition,
meta.ReconciliationSucceededReason,
Expand Down Expand Up @@ -467,3 +467,11 @@ func requeueAfter(obj *fluxcdv1.FluxInstance) ctrl.Result {

return result
}

func fmtDuration(t time.Time) string {
if time.Since(t) < time.Second {
return time.Since(t).Round(time.Millisecond).String()
} else {
return time.Since(t).Round(time.Second).String()
}
}
2 changes: 1 addition & 1 deletion internal/controller/fluxinstance_uninstaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (r *FluxInstanceReconciler) uninstall(ctx context.Context,
}

controllerutil.RemoveFinalizer(obj, fluxcdv1.Finalizer)
msg := fmt.Sprintf("Uninstallation completed in %v", time.Since(reconcileStart).String())
msg := fmt.Sprintf("Uninstallation completed in %v", fmtDuration(reconcileStart))
log.Info(msg, "output", changeSet.ToMap())

// Stop reconciliation as the object is being deleted.
Expand Down