-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add status.Conditions - ready with count of reflected clusters (#17)
* Add status.Conditions - ready with count of reflected clusters * Add default value for ObservedGeneration --------- Co-authored-by: Simon <simon@weave.works>
- Loading branch information
Showing
6 changed files
with
230 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"github.com/fluxcd/pkg/apis/meta" | ||
apimeta "k8s.io/apimachinery/pkg/api/meta" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
const ( | ||
// ReconciliationFailedReason represents the fact that | ||
// the reconciliation failed. | ||
ReconciliationFailedReason string = "ReconciliationFailed" | ||
|
||
// ReconciliationSucceededReason represents the fact that | ||
// the reconciliation succeeded. | ||
ReconciliationSucceededReason string = "ReconciliationSucceeded" | ||
) | ||
|
||
// SetAutomatedClusterDiscoveryReadiness sets the ready condition with the given status, reason and message. | ||
func SetAutomatedClusterDiscoveryReadiness(acd *AutomatedClusterDiscovery, inventory *ResourceInventory, status metav1.ConditionStatus, reason, message string) { | ||
if inventory != nil { | ||
acd.Status.Inventory = inventory | ||
|
||
if len(inventory.Entries) == 0 { | ||
acd.Status.Inventory = nil | ||
} | ||
} | ||
|
||
acd.Status.ObservedGeneration = acd.ObjectMeta.Generation | ||
newCondition := metav1.Condition{ | ||
Type: meta.ReadyCondition, | ||
Status: status, | ||
Reason: reason, | ||
Message: message, | ||
} | ||
apimeta.SetStatusCondition(&acd.Status.Conditions, newCondition) | ||
} | ||
|
||
// GetAutomatedClusterDiscoveryReadiness returns the readiness condition of the AutomatedClusterDiscovery. | ||
func GetAutomatedClusterDiscoveryReadiness(acd *AutomatedClusterDiscovery) metav1.ConditionStatus { | ||
return apimeta.FindStatusCondition(acd.Status.Conditions, meta.ReadyCondition).Status | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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