Skip to content
Draft
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
2 changes: 1 addition & 1 deletion apis/acl/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 47 additions & 0 deletions apis/event/v1/action.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
Copyright 2026 The Flux authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1

// These constants define common event actions used throughout Flux controllers.
const (
// ActionReconciling indicates a reconciliation is in progress.
ActionReconciling string = "Reconciling"
// ActionReconciled indicates a successful reconciliation.
ActionReconciled string = "Reconciled"
// ActionFetching indicates fetching of a resource or artifact.
ActionFetching string = "Fetching"
// ActionFetched indicates successful fetch of a resource or artifact.
ActionFetched string = "Fetched"
// ActionApplying indicates applying changes to the cluster.
ActionApplying string = "Applying"
// ActionApplied indicates successful application of changes.
ActionApplied string = "Applied"
// ActionDeleting indicates deletion is in progress.
ActionDeleting string = "Deleting"
// ActionDeleted indicates successful deletion.
ActionDeleted string = "Deleted"
// ActionValidating indicates validation is in progress.
ActionValidating string = "Validating"
// ActionValidated indicates successful validation.
ActionValidated string = "Validated"
// ActionWaiting indicates waiting for a condition.
ActionWaiting string = "Waiting"
// ActionProgressing indicates progression through a workflow.
ActionProgressing string = "Progressing"
// ActionFailed indicates a failed operation.
ActionFailed string = "Failed"
)
19 changes: 19 additions & 0 deletions apis/event/v1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
Copyright 2026 The Flux authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// package v1 contains the API Schema definitions for the Flux eventing API.
// +kubebuilder:object:generate=true
package v1
118 changes: 118 additions & 0 deletions apis/event/v1/event.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*
Copyright 2026 The Flux authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// Group is the API Group for the Event API.
const Group = "event.toolkit.fluxcd.io"

// These constants define valid event severity values.
const (
// EventSeverityTrace represents a trace event, usually
// informing about actions taken during reconciliation.
EventSeverityTrace string = "trace"
// EventSeverityInfo represents an informational event, usually
// informing about changes.
EventSeverityInfo string = "info"
// EventSeverityError represent an error event, usually a warning
// that something goes wrong.
EventSeverityError string = "error"
)

// EventTypeTrace represents a trace event.
const EventTypeTrace string = "Trace"

// Event is a report of an event issued by a controller.
type Event struct {
// The object that this event is about.
// +required
InvolvedObject corev1.ObjectReference `json:"involvedObject"`

// RelatedObject is an optional secondary object for more complex actions.
// For simple events, this field may be left empty.
// +optional
RelatedObject corev1.ObjectReference `json:"relatedObject,omitempty"`

// Severity type of this event (trace, info, error)
// +kubebuilder:validation:Enum=trace;info;error
// +required
Severity string `json:"severity"`

// The time at which this event was recorded.
// +required
Timestamp metav1.Time `json:"timestamp"`

// A human-readable description of this event.
// Maximum length 39,000 characters.
// +kubebuilder:validation:MaxLength=39000
// +required
Message string `json:"message"`

// A machine understandable string that gives the reason
// for the transition into the object's current status.
// +required
Reason string `json:"reason"`

// Action describes what action was taken/failed regarding the object.
// Examples: "Starting", "Syncing", "Deleting".
// +required
Action string `json:"action"`

// Metadata of this event, e.g. apply change set.
// +optional
Metadata map[string]string `json:"metadata,omitempty"`

// Name of the controller that emitted this event, e.g. `source-controller`.
// +required
ReportingController string `json:"reportingController"`

// ID of the controller instance, e.g. `source-controller-xyzf`.
// +optional
ReportingInstance string `json:"reportingInstance,omitempty"`
}

// HasReason returns true if the Reason equals the given value.
func (in *Event) HasReason(reason string) bool {
return in.Reason == reason
}

// HasMetadata returns true if the given key/value pair is found in Metadata.
func (in *Event) HasMetadata(key string, val string) bool {
if v, ok := in.Metadata[key]; ok && v == val {
return true
}
return false
}

// 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
}
if r, ok := in.Metadata[MetaRevisionKey]; ok {
return r, true
}
return "", false
}
46 changes: 46 additions & 0 deletions apis/event/v1/metadata.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
Copyright 2026 The Flux authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1

// These constants define the Event metadata keys used throughout Flux controllers.
const (
// MetaRevisionKey is the key used to hold the source artifact revision.
MetaRevisionKey string = "revision"
// MetaOriginRevisionKey is the key used to hold the source artifact origin revision.
MetaOriginRevisionKey string = "originRevision"
// MetaChecksumKey is the key used to hold the source artifact checksum.
// Deprecated: in favor of MetaDigestKey.
MetaChecksumKey string = "checksum"
// MetaDigestKey is the key used to hold the source artifact digest.
MetaDigestKey string = "digest"
// MetaTokenKey is the key used to hold an arbitrary token whose contents
// are defined on a per-event-emitter basis for uniquely identifying the
// contents of the event payload. For example, it could be the generation
// of an object, or the hash of a set of configurations, or even a
// 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
// used to signal a Git commit status update.
MetaCommitStatusUpdateValue string = "update"
// MetaChangeRequestKey is the key used to hold the identifier of a change request.
MetaChangeRequestKey string = "change_request"
)
48 changes: 48 additions & 0 deletions apis/event/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apis/event/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apis/kustomize/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apis/meta/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion hack/boilerplate.go.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2025 The Flux authors
Copyright 2026 The Flux authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Loading
Loading