diff --git a/apis/event/v1beta1/event.go b/apis/event/v1beta1/event.go index 350c5427..ced17b16 100644 --- a/apis/event/v1beta1/event.go +++ b/apis/event/v1beta1/event.go @@ -92,9 +92,12 @@ func (in *Event) HasMetadata(key string, val string) bool { return false } -// GetRevision looks up for the MetaOriginRevisionKey and MetaRevisionKey -// keys in the Metadata and returns the first it finds. +// GetRevision looks up for the keys in Metadata that may contain +// the revision of the object that this event is about. func (in *Event) GetRevision() (string, bool) { + if r, ok := in.Metadata[MetaCommitKey]; ok { + return r, true + } if r, ok := in.Metadata[MetaOriginRevisionKey]; ok { return r, true } diff --git a/apis/event/v1beta1/metadata.go b/apis/event/v1beta1/metadata.go index 434b0136..98282fd5 100644 --- a/apis/event/v1beta1/metadata.go +++ b/apis/event/v1beta1/metadata.go @@ -34,6 +34,8 @@ const ( // base64-encoded set of configurations. This is useful for example for // rate limiting the events. MetaTokenKey string = "token" + // MetaCommitKey is the key used to hold the Git commit hash. + MetaCommitKey string = "commit" // MetaCommitStatusKey is the key used to signal a Git commit status event. MetaCommitStatusKey string = "commit_status" // MetaCommitStatusUpdateValue is the value of MetaCommitStatusKey diff --git a/runtime/go.mod b/runtime/go.mod index d80667ab..09757f7f 100644 --- a/runtime/go.mod +++ b/runtime/go.mod @@ -13,7 +13,7 @@ require ( github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6 github.com/fluxcd/cli-utils v0.37.1-flux.1 github.com/fluxcd/pkg/apis/acl v0.9.0 - github.com/fluxcd/pkg/apis/event v0.23.0 + github.com/fluxcd/pkg/apis/event v0.24.0 github.com/fluxcd/pkg/apis/kustomize v1.15.0 github.com/fluxcd/pkg/apis/meta v1.25.0 github.com/go-logr/logr v1.4.3 diff --git a/tests/integration/go.mod b/tests/integration/go.mod index c1a4bf0f..26ab059e 100644 --- a/tests/integration/go.mod +++ b/tests/integration/go.mod @@ -20,7 +20,7 @@ require ( github.com/fluxcd/pkg/auth v0.36.0 github.com/fluxcd/pkg/cache v0.13.0 github.com/fluxcd/pkg/git v0.42.0 - github.com/fluxcd/pkg/runtime v0.98.0 + github.com/fluxcd/pkg/runtime v0.99.0 github.com/fluxcd/test-infra/tftestenv v0.0.0-20250626232827-e0ca9c3f8d7b github.com/go-git/go-git/v5 v5.16.4 github.com/google/go-containerregistry v0.20.7