@@ -22,6 +22,7 @@ import (
2222 "os"
2323 "strconv"
2424 "strings"
25+ "time"
2526
2627 "github.com/functions-dev/func-operator/internal/funccli"
2728 fn "github.com/functions-dev/func-operator/internal/function"
@@ -52,6 +53,9 @@ import (
5253const (
5354 deployFunctionRoleName = "func-operator-deploy-function"
5455 controllerConfigName = "func-operator-controller-config"
56+
57+ funcAnnotationPrefix = "functions.knative.dev/"
58+ funcAnnotationLastDeployed = funcAnnotationPrefix + "last-deployed"
5559)
5660
5761// FunctionReconciler reconciles a Function object
@@ -161,6 +165,16 @@ func (r *FunctionReconciler) reconcile(ctx context.Context, function *v1alpha1.F
161165
162166 function .Status .Name = metadata .Name
163167
168+ if val , ok := function .Annotations [funcAnnotationLastDeployed ]; ok {
169+ t , err := time .Parse (time .RFC3339 , val )
170+ if err != nil {
171+ // log a warning, but don't return error, as this can't resolve on its own
172+ log .FromContext (ctx ).Info ("could not parse " + funcAnnotationLastDeployed + " annotation" , "error" , err )
173+ } else {
174+ function .Status .Deployment .ImageBuilt = metav1 .NewTime (t )
175+ }
176+ }
177+
164178 if err := r .ensureDeployment (ctx , function , repo , metadata ); err != nil {
165179 return fmt .Errorf ("deploying function failed: %w" , err )
166180 }
@@ -295,6 +309,7 @@ func (r *FunctionReconciler) handleMiddlewareUpdate(ctx context.Context, functio
295309
296310 function .Status .Middleware .PendingRebuild = false
297311 function .Status .Middleware .LastRebuild = metav1 .Now ()
312+ function .Status .Deployment .ImageBuilt = metav1 .Now ()
298313
299314 function .RecordHistoryEvent (fmt .Sprintf ("Middleware updated from %q to %q" , functionDescribe .Middleware .Version , latestMiddleware ))
300315
0 commit comments