-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from dharmjit/add_events
Registered Events to k8s Event API for ByoMachine, ByoHost
- Loading branch information
Showing
8 changed files
with
161 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2021 VMware, Inc. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package common | ||
|
||
// CollectEvents returns a slice of string consisting | ||
// all the events from the record.FakeRecorder.Events Chan | ||
func CollectEvents(source <-chan string) []string { | ||
done := false | ||
events := make([]string, 0) | ||
for !done { | ||
select { | ||
case event := <-source: | ||
events = append(events, event) | ||
default: | ||
done = true | ||
} | ||
} | ||
return events | ||
} | ||
|
||
// DrainEvents clears all the events in the chan recorder.Events | ||
// This is a hack as the current byomachine reconciler is global to test | ||
// and the record.FakeRecorder could have events from different tests | ||
// It could also introduce data races in parallel tests run | ||
func DrainEvents(events chan string) { | ||
for { | ||
select { | ||
case <-events: | ||
default: | ||
return | ||
} | ||
} | ||
} |
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
Oops, something went wrong.