mirror of
https://github.com/fluxcd/flux2.git
synced 2025-10-28 05:04:48 +08:00
fix: wait for Source objects observed generation
This ensures the command will wait for the object to report a Ready Condition with an ObservedGeneration matching the Generation of the resource. Ensuring that when a "create" is actually a mutation, it waits instead of prematurely assuming the Source to be Ready. Signed-off-by: Hidde Beydals <hello@hidde.co>
This commit is contained in:
@ -106,10 +106,11 @@ func TestCreateSourceGit(t *testing.T) {
|
||||
assertGoldenFile("testdata/create_source_git/success.golden"),
|
||||
func(repo *sourcev1.GitRepository) {
|
||||
newCondition := metav1.Condition{
|
||||
Type: meta.ReadyCondition,
|
||||
Status: metav1.ConditionTrue,
|
||||
Reason: sourcev1.GitOperationSucceedReason,
|
||||
Message: "succeeded message",
|
||||
Type: meta.ReadyCondition,
|
||||
Status: metav1.ConditionTrue,
|
||||
Reason: sourcev1.GitOperationSucceedReason,
|
||||
Message: "succeeded message",
|
||||
ObservedGeneration: repo.GetGeneration(),
|
||||
}
|
||||
apimeta.SetStatusCondition(&repo.Status.Conditions, newCondition)
|
||||
repo.Status.Artifact = &sourcev1.Artifact{
|
||||
@ -123,10 +124,11 @@ func TestCreateSourceGit(t *testing.T) {
|
||||
assertError("failed message"),
|
||||
func(repo *sourcev1.GitRepository) {
|
||||
newCondition := metav1.Condition{
|
||||
Type: meta.ReadyCondition,
|
||||
Status: metav1.ConditionFalse,
|
||||
Reason: sourcev1.URLInvalidReason,
|
||||
Message: "failed message",
|
||||
Type: meta.ReadyCondition,
|
||||
Status: metav1.ConditionFalse,
|
||||
Reason: sourcev1.URLInvalidReason,
|
||||
Message: "failed message",
|
||||
ObservedGeneration: repo.GetGeneration(),
|
||||
}
|
||||
apimeta.SetStatusCondition(&repo.Status.Conditions, newCondition)
|
||||
},
|
||||
@ -137,10 +139,11 @@ func TestCreateSourceGit(t *testing.T) {
|
||||
func(repo *sourcev1.GitRepository) {
|
||||
// Updated with no artifact
|
||||
newCondition := metav1.Condition{
|
||||
Type: meta.ReadyCondition,
|
||||
Status: metav1.ConditionTrue,
|
||||
Reason: sourcev1.GitOperationSucceedReason,
|
||||
Message: "succeeded message",
|
||||
Type: meta.ReadyCondition,
|
||||
Status: metav1.ConditionTrue,
|
||||
Reason: sourcev1.GitOperationSucceedReason,
|
||||
Message: "succeeded message",
|
||||
ObservedGeneration: repo.GetGeneration(),
|
||||
}
|
||||
apimeta.SetStatusCondition(&repo.Status.Conditions, newCondition)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user