Skip to content

Commit 5c9b970

Browse files
authored
Add last commit information in status (#99)
1 parent 30b6921 commit 5c9b970

6 files changed

Lines changed: 23 additions & 14 deletions

File tree

api/v1alpha1/function_types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ type FunctionStatusGit struct {
9999
type FunctionStatusDeployment struct {
100100
Image string `json:"image,omitempty"`
101101
ImageBuilt metav1.Time `json:"imageBuilt,omitempty"`
102+
Revision string `json:"revision,omitempty"`
102103
Deployer string `json:"deployer,omitempty"`
103104
Runtime string `json:"runtime,omitempty"`
104105
}

config/crd/bases/functions.dev_functions.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ spec:
184184
imageBuilt:
185185
format: date-time
186186
type: string
187+
revision:
188+
type: string
187189
runtime:
188190
type: string
189191
type: object

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,4 @@ require (
155155
sigs.k8s.io/yaml v1.6.0 // indirect
156156
)
157157

158-
replace knative.dev/func => knative.dev/func v0.47.1-0.20260421122411-87ce20dd94e4
158+
replace knative.dev/func => knative.dev/func v0.48.1-0.20260427113619-77707d1de8b6

go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c h1:udKWzYgxTojEK
1212
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
1313
github.com/BurntSushi/toml v1.6.0 h1:dRaEfpa2VI55EwlIW72hMRHdWouJeRF7TPYhI+AUQjk=
1414
github.com/BurntSushi/toml v1.6.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
15-
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
16-
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
1715
github.com/Masterminds/semver/v3 v3.4.0 h1:Zog+i5UMtVoCU8oKka5P7i9q9HgrJeGzI9SA1Xbatp0=
1816
github.com/Masterminds/semver/v3 v3.4.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
1917
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
@@ -503,8 +501,8 @@ knative.dev/client/pkg v0.0.0-20260414023335-1977a50c04df h1:lVwgz0nFbAiYQUhAVdU
503501
knative.dev/client/pkg v0.0.0-20260414023335-1977a50c04df/go.mod h1:aAFzTzKkLSK6I6W4g/+QUMpv5ty2UcOngcXxzn+a1FE=
504502
knative.dev/eventing v0.48.1-0.20260414191034-3b3ea1d037e6 h1:maXR76gTo6zpNjZOir4npylXw5wQX2BcXisq8fcaf4c=
505503
knative.dev/eventing v0.48.1-0.20260414191034-3b3ea1d037e6/go.mod h1:Y3FYNf5gNCIuqv+NzUAmqfbHJ8n+TxXSsZoV/20jfV0=
506-
knative.dev/func v0.47.1-0.20260421122411-87ce20dd94e4 h1:IjCmEXwcA19aomt7mznmz3wk8qlVesUj2EigI0LPT/I=
507-
knative.dev/func v0.47.1-0.20260421122411-87ce20dd94e4/go.mod h1:R8TiTtGRnIvWSr4EJG6NvEYeB6Fjuj/wBrR7Gw6Ka24=
504+
knative.dev/func v0.48.1-0.20260427113619-77707d1de8b6 h1:TLTpkrxoiZ1gbVA/xBQWFgSBbFmTiu7QID5Olrf8O74=
505+
knative.dev/func v0.48.1-0.20260427113619-77707d1de8b6/go.mod h1:R8TiTtGRnIvWSr4EJG6NvEYeB6Fjuj/wBrR7Gw6Ka24=
508506
knative.dev/networking v0.0.0-20260407015926-cc2f0572b3c2 h1:8QlbccV/8/YO2zIoCAOvjU/0t5HxMiWyo480cwohrlQ=
509507
knative.dev/networking v0.0.0-20260407015926-cc2f0572b3c2/go.mod h1:a3XBEpYEpWTSz6DdKNXA6+hcny6SSs5J9FChfPxUJMM=
510508
knative.dev/pkg v0.0.0-20260414003832-e65cbe95a718 h1:/8xILwHO82gYQXgqQgP9jbSpxg8rmsl/mk1YrYtY/hs=

internal/controller/function_controller.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -251,16 +251,18 @@ type middlewareCheck interface {
251251
}
252252

253253
type middlewareUpToDate struct {
254-
currentImage string
255-
serviceReady string
256-
currentVersion string
257-
autoUpdate autoUpdateStatus
254+
currentImage string
255+
currentRevision string
256+
serviceReady string
257+
currentVersion string
258+
autoUpdate autoUpdateStatus
258259
}
259260

260261
func (middlewareUpToDate) middlewareCheck() {}
261262

262263
type middlewareOutdated struct {
263264
currentImage string
265+
currentRevision string
264266
serviceReady string
265267
currentVersion string
266268
availableVersion string
@@ -292,15 +294,17 @@ func (r *FunctionReconciler) checkMiddlewareState(ctx context.Context, function
292294

293295
if latestVersion == desc.Middleware.Version {
294296
return middlewareUpToDate{
295-
currentImage: desc.Image,
296-
serviceReady: desc.Ready,
297-
currentVersion: desc.Middleware.Version,
298-
autoUpdate: autoUpdate,
297+
currentImage: desc.Image,
298+
currentRevision: desc.Revision,
299+
serviceReady: desc.Ready,
300+
currentVersion: desc.Middleware.Version,
301+
autoUpdate: autoUpdate,
299302
}, nil
300303
}
301304

302305
return middlewareOutdated{
303306
currentImage: desc.Image,
307+
currentRevision: desc.Revision,
304308
serviceReady: desc.Ready,
305309
currentVersion: desc.Middleware.Version,
306310
availableVersion: latestVersion,
@@ -330,6 +334,7 @@ func (r *FunctionReconciler) handleMiddlewareUpdate(ctx context.Context, functio
330334
case middlewareUpToDate:
331335
logger.Info("Function is on latest middleware. No redeploy needed", "version", check.currentVersion)
332336
function.Status.Deployment.Image = check.currentImage
337+
function.Status.Deployment.Revision = check.currentRevision
333338
function.Status.Middleware.Current = check.currentVersion
334339
function.Status.Middleware.AutoUpdate.Enabled = check.autoUpdate.enabled
335340
function.Status.Middleware.AutoUpdate.Source = check.autoUpdate.source
@@ -339,6 +344,7 @@ func (r *FunctionReconciler) handleMiddlewareUpdate(ctx context.Context, functio
339344

340345
case middlewareOutdated:
341346
function.Status.Deployment.Image = check.currentImage
347+
function.Status.Deployment.Revision = check.currentRevision
342348
function.Status.Middleware.Current = check.currentVersion
343349
function.Status.Middleware.AutoUpdate.Enabled = check.autoUpdate.enabled
344350
function.Status.Middleware.AutoUpdate.Source = check.autoUpdate.source

internal/controller/function_controller_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ var _ = Describe("Function Controller", func() {
228228
Middleware: functions.Middleware{
229229
Version: "v1.0.0",
230230
},
231-
Image: "my-image:v1.2.3",
231+
Image: "my-image:v1.2.3",
232+
Revision: "my-revision",
232233
}, nil)
233234
funcMock.EXPECT().GetLatestMiddlewareVersion(mock.Anything, mock.Anything, mock.Anything).Return("v1.0.0", nil)
234235

@@ -241,6 +242,7 @@ var _ = Describe("Function Controller", func() {
241242
},
242243
statusChecks: func(status *functionsdevv1alpha1.FunctionStatus) {
243244
Expect(status.Deployment.Image).Should(Equal("my-image:v1.2.3"))
245+
Expect(status.Deployment.Revision).Should(Equal("my-revision"))
244246
Expect(status.Deployment.Deployer).Should(Equal("keda"))
245247
Expect(status.Deployment.Runtime).Should(Equal("node"))
246248
},

0 commit comments

Comments
 (0)