When merging CredentialIssuer updates, don't overwrite LastUpdated.
If the only thing that has changed about a strategy is the LastUpdated timestamp, then we should not update the object. Signed-off-by: Margo Crawford <margaretc@vmware.com>
This commit is contained in:
parent
af2af567be
commit
ab750f48aa
@ -42,7 +42,9 @@ func mergeStrategy(configToUpdate *v1alpha1.CredentialIssuerStatus, strategy v1a
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if existing != nil {
|
if existing != nil {
|
||||||
strategy.DeepCopyInto(existing)
|
if !equalExceptLastUpdated(existing, &strategy) {
|
||||||
|
strategy.DeepCopyInto(existing)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
configToUpdate.Strategies = append(configToUpdate.Strategies, strategy)
|
configToUpdate.Strategies = append(configToUpdate.Strategies, strategy)
|
||||||
}
|
}
|
||||||
@ -75,3 +77,11 @@ func (s sortableStrategies) Less(i, j int) bool {
|
|||||||
return s[i].Type < s[j].Type
|
return s[i].Type < s[j].Type
|
||||||
}
|
}
|
||||||
func (s sortableStrategies) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
func (s sortableStrategies) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||||
|
|
||||||
|
func equalExceptLastUpdated(s1, s2 *v1alpha1.CredentialIssuerStrategy) bool {
|
||||||
|
s1 = s1.DeepCopy()
|
||||||
|
s2 = s2.DeepCopy()
|
||||||
|
s1.LastUpdateTime = metav1.Time{}
|
||||||
|
s2.LastUpdateTime = metav1.Time{}
|
||||||
|
return apiequality.Semantic.DeepEqual(s1, s2)
|
||||||
|
}
|
||||||
|
@ -125,6 +125,38 @@ func TestMergeStrategy(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "existing entry matches except for LastUpdated time",
|
||||||
|
configToUpdate: v1alpha1.CredentialIssuerStatus{
|
||||||
|
Strategies: []v1alpha1.CredentialIssuerStrategy{
|
||||||
|
{
|
||||||
|
Type: "Type1",
|
||||||
|
Status: v1alpha1.ErrorStrategyStatus,
|
||||||
|
Reason: "some starting reason",
|
||||||
|
Message: "some starting message",
|
||||||
|
LastUpdateTime: t1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
strategy: v1alpha1.CredentialIssuerStrategy{
|
||||||
|
Type: "Type1",
|
||||||
|
Status: v1alpha1.ErrorStrategyStatus,
|
||||||
|
Reason: "some starting reason",
|
||||||
|
Message: "some starting message",
|
||||||
|
LastUpdateTime: t2,
|
||||||
|
},
|
||||||
|
expected: v1alpha1.CredentialIssuerStatus{
|
||||||
|
Strategies: []v1alpha1.CredentialIssuerStrategy{
|
||||||
|
{
|
||||||
|
Type: "Type1",
|
||||||
|
Status: v1alpha1.ErrorStrategyStatus,
|
||||||
|
Reason: "some starting reason",
|
||||||
|
Message: "some starting message",
|
||||||
|
LastUpdateTime: t1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "new entry among others",
|
name: "new entry among others",
|
||||||
configToUpdate: v1alpha1.CredentialIssuerStatus{
|
configToUpdate: v1alpha1.CredentialIssuerStatus{
|
||||||
|
Loading…
Reference in New Issue
Block a user