mirror of https://github.com/k3s-io/k3s
fed: Factor annotation mutation out of the crudtester for reuse
parent
b4b5bfdb46
commit
cf71a8ef11
|
@ -61,3 +61,12 @@ type FederatedTypeAdapter interface {
|
|||
// be registered with RegisterAdapterFactory to ensure the type
|
||||
// adapter is discoverable.
|
||||
type AdapterFactory func(client federationclientset.Interface) FederatedTypeAdapter
|
||||
|
||||
// SetAnnotation sets the given key and value in the given object's ObjectMeta.Annotations map
|
||||
func SetAnnotation(adapter FederatedTypeAdapter, obj pkgruntime.Object, key, value string) {
|
||||
meta := adapter.ObjectMeta(obj)
|
||||
if meta.Annotations == nil {
|
||||
meta.Annotations = make(map[string]string)
|
||||
}
|
||||
meta.Annotations[key] = value
|
||||
}
|
||||
|
|
|
@ -193,11 +193,7 @@ func (c *FederatedTypeCRUDTester) waitForResource(client clientset.Interface, ob
|
|||
func (c *FederatedTypeCRUDTester) updateFedObject(obj pkgruntime.Object) (pkgruntime.Object, error) {
|
||||
err := wait.PollImmediate(c.waitInterval, wait.ForeverTestTimeout, func() (bool, error) {
|
||||
// Target the metadata for simplicity (it's type-agnostic)
|
||||
meta := c.adapter.ObjectMeta(obj)
|
||||
if meta.Annotations == nil {
|
||||
meta.Annotations = make(map[string]string)
|
||||
}
|
||||
meta.Annotations[AnnotationTestFederationCRUDUpdate] = "updated"
|
||||
federatedtypes.SetAnnotation(c.adapter, obj, AnnotationTestFederationCRUDUpdate, "updated")
|
||||
|
||||
_, err := c.adapter.FedUpdate(obj)
|
||||
if errors.IsConflict(err) {
|
||||
|
|
Loading…
Reference in New Issue