-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(vm): Add Events about power state changes
- Also duplicate these events in log. Signed-off-by: Ivan Mikheykin <[email protected]>
- Loading branch information
Showing
9 changed files
with
218 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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,49 @@ | ||
package eventrecord | ||
|
||
import ( | ||
corev1 "k8s.io/api/core/v1" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
type Event struct { | ||
// The object that this event is about. | ||
InvolvedObject client.Object | ||
|
||
// The top object that this event is related to. E.g. VirtualMachine for VirtualMachineOperation. | ||
// Only for logging, will not be reflected in the Event resource. | ||
RelatedObject client.Object | ||
|
||
// Type of this event (Normal, Warning), new types could be added in the future | ||
Type string | ||
|
||
// This should be a short, machine understandable string that gives the reason | ||
// for the transition into the object's current status. | ||
Reason string | ||
|
||
// A human-readable description of the status of this operation. | ||
Message string | ||
} | ||
|
||
func NewNormalEvent(involvedObject client.Object, reason, message string) *Event { | ||
return &Event{ | ||
InvolvedObject: involvedObject, | ||
Type: corev1.EventTypeNormal, | ||
Reason: reason, | ||
Message: message, | ||
} | ||
} | ||
|
||
func NewWarningEvent(involvedObject client.Object, reason, message string) *Event { | ||
return &Event{ | ||
InvolvedObject: involvedObject, | ||
Type: corev1.EventTypeWarning, | ||
Reason: reason, | ||
Message: message, | ||
} | ||
} | ||
|
||
func NewNormalEventWithRelated(involvedObject client.Object, relatedObject client.Object, reason, message string) *Event { | ||
ev := NewNormalEvent(involvedObject, reason, message) | ||
ev.RelatedObject = relatedObject | ||
return ev | ||
} |
Oops, something went wrong.