-
Notifications
You must be signed in to change notification settings - Fork 143
runtime: Migrate to new Kubernentes event API #1144
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
Open
adri1197
wants to merge
1
commit into
fluxcd:main
Choose a base branch
from
adri1197:event-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.