find and replace
Kubernetes-commit: e405ae9ec8592bf028e351bab44de420908bac0d
This commit is contained in:
parent
97b274d46f
commit
cbbb5800c3
|
@ -267,7 +267,7 @@ func TestApplyStripsFields(t *testing.T) {
|
||||||
newObj.SetName("b")
|
newObj.SetName("b")
|
||||||
newObj.SetNamespace("b")
|
newObj.SetNamespace("b")
|
||||||
newObj.SetUID("b")
|
newObj.SetUID("b")
|
||||||
newObj.SetClusterName("b")
|
newObj.SetZZZ_DeprecatedClusterName("b")
|
||||||
newObj.SetGeneration(0)
|
newObj.SetGeneration(0)
|
||||||
newObj.SetResourceVersion("b")
|
newObj.SetResourceVersion("b")
|
||||||
newObj.SetCreationTimestamp(metav1.NewTime(time.Now()))
|
newObj.SetCreationTimestamp(metav1.NewTime(time.Now()))
|
||||||
|
|
|
@ -123,9 +123,9 @@ func BeforeCreate(strategy RESTCreateStrategy, ctx context.Context, obj runtime.
|
||||||
objectMeta.SetManagedFields(nil)
|
objectMeta.SetManagedFields(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClusterName is ignored and should not be saved
|
// ZZZ_DeprecatedClusterName is ignored and should not be saved
|
||||||
if len(objectMeta.GetClusterName()) > 0 {
|
if len(objectMeta.GetZZZ_DeprecatedClusterName()) > 0 {
|
||||||
objectMeta.SetClusterName("")
|
objectMeta.SetZZZ_DeprecatedClusterName("")
|
||||||
}
|
}
|
||||||
|
|
||||||
if errs := strategy.Validate(ctx, obj); len(errs) > 0 {
|
if errs := strategy.Validate(ctx, obj); len(errs) > 0 {
|
||||||
|
|
|
@ -168,8 +168,8 @@ func (t *Tester) TestCreate(valid runtime.Object, createFn CreateFunc, getFn Get
|
||||||
t.testCreateInvokesValidation(opts, invalid...)
|
t.testCreateInvokesValidation(opts, invalid...)
|
||||||
t.testCreateValidatesNames(valid.DeepCopyObject(), dryRunOpts)
|
t.testCreateValidatesNames(valid.DeepCopyObject(), dryRunOpts)
|
||||||
t.testCreateValidatesNames(valid.DeepCopyObject(), opts)
|
t.testCreateValidatesNames(valid.DeepCopyObject(), opts)
|
||||||
t.testCreateIgnoreClusterName(valid.DeepCopyObject(), dryRunOpts)
|
t.testCreateIgnoreZZZ_DeprecatedClusterName(valid.DeepCopyObject(), dryRunOpts)
|
||||||
t.testCreateIgnoreClusterName(valid.DeepCopyObject(), opts)
|
t.testCreateIgnoreZZZ_DeprecatedClusterName(valid.DeepCopyObject(), opts)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test updating an object.
|
// Test updating an object.
|
||||||
|
@ -190,7 +190,7 @@ func (t *Tester) TestUpdate(valid runtime.Object, createFn CreateFunc, getFn Get
|
||||||
t.testUpdatePropagatesUpdatedObjectError(valid.DeepCopyObject(), createFn, getFn, dryRunOpts)
|
t.testUpdatePropagatesUpdatedObjectError(valid.DeepCopyObject(), createFn, getFn, dryRunOpts)
|
||||||
t.testUpdatePropagatesUpdatedObjectError(valid.DeepCopyObject(), createFn, getFn, opts)
|
t.testUpdatePropagatesUpdatedObjectError(valid.DeepCopyObject(), createFn, getFn, opts)
|
||||||
t.testUpdateIgnoreGenerationUpdates(valid.DeepCopyObject(), createFn, getFn)
|
t.testUpdateIgnoreGenerationUpdates(valid.DeepCopyObject(), createFn, getFn)
|
||||||
t.testUpdateIgnoreClusterName(valid.DeepCopyObject(), createFn, getFn)
|
t.testUpdateIgnoreZZZ_DeprecatedClusterName(valid.DeepCopyObject(), createFn, getFn)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test deleting an object.
|
// Test deleting an object.
|
||||||
|
@ -506,10 +506,10 @@ func (t *Tester) testCreateResetsUserData(valid runtime.Object, opts metav1.Crea
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Tester) testCreateIgnoreClusterName(valid runtime.Object, opts metav1.CreateOptions) {
|
func (t *Tester) testCreateIgnoreZZZ_DeprecatedClusterName(valid runtime.Object, opts metav1.CreateOptions) {
|
||||||
objectMeta := t.getObjectMetaOrFail(valid)
|
objectMeta := t.getObjectMetaOrFail(valid)
|
||||||
objectMeta.SetName(t.namer(3))
|
objectMeta.SetName(t.namer(3))
|
||||||
objectMeta.SetClusterName("clustername-to-ignore")
|
objectMeta.SetZZZ_DeprecatedClusterName("clustername-to-ignore")
|
||||||
|
|
||||||
obj, err := t.storage.(rest.Creater).Create(t.TestContext(), valid.DeepCopyObject(), rest.ValidateAllObjectFunc, &opts)
|
obj, err := t.storage.(rest.Creater).Create(t.TestContext(), valid.DeepCopyObject(), rest.ValidateAllObjectFunc, &opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -517,8 +517,8 @@ func (t *Tester) testCreateIgnoreClusterName(valid runtime.Object, opts metav1.C
|
||||||
}
|
}
|
||||||
defer t.delete(t.TestContext(), obj)
|
defer t.delete(t.TestContext(), obj)
|
||||||
createdObjectMeta := t.getObjectMetaOrFail(obj)
|
createdObjectMeta := t.getObjectMetaOrFail(obj)
|
||||||
if len(createdObjectMeta.GetClusterName()) != 0 {
|
if len(createdObjectMeta.GetZZZ_DeprecatedClusterName()) != 0 {
|
||||||
t.Errorf("Expected empty clusterName on created object, got '%v'", createdObjectMeta.GetClusterName())
|
t.Errorf("Expected empty clusterName on created object, got '%v'", createdObjectMeta.GetZZZ_DeprecatedClusterName())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -790,7 +790,7 @@ func (t *Tester) testUpdateRejectsMismatchedNamespace(obj runtime.Object, create
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Tester) testUpdateIgnoreClusterName(obj runtime.Object, createFn CreateFunc, getFn GetFunc) {
|
func (t *Tester) testUpdateIgnoreZZZ_DeprecatedClusterName(obj runtime.Object, createFn CreateFunc, getFn GetFunc) {
|
||||||
ctx := t.TestContext()
|
ctx := t.TestContext()
|
||||||
|
|
||||||
foo := obj.DeepCopyObject()
|
foo := obj.DeepCopyObject()
|
||||||
|
@ -808,7 +808,7 @@ func (t *Tester) testUpdateIgnoreClusterName(obj runtime.Object, createFn Create
|
||||||
|
|
||||||
older := storedFoo.DeepCopyObject()
|
older := storedFoo.DeepCopyObject()
|
||||||
olderMeta := t.getObjectMetaOrFail(older)
|
olderMeta := t.getObjectMetaOrFail(older)
|
||||||
olderMeta.SetClusterName("clustername-to-ignore")
|
olderMeta.SetZZZ_DeprecatedClusterName("clustername-to-ignore")
|
||||||
|
|
||||||
_, _, err = t.storage.(rest.Updater).Update(t.TestContext(), olderMeta.GetName(), rest.DefaultUpdatedObjectInfo(older), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc, false, &metav1.UpdateOptions{})
|
_, _, err = t.storage.(rest.Updater).Update(t.TestContext(), olderMeta.GetName(), rest.DefaultUpdatedObjectInfo(older), rest.ValidateAllObjectFunc, rest.ValidateAllObjectUpdateFunc, false, &metav1.UpdateOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -819,7 +819,7 @@ func (t *Tester) testUpdateIgnoreClusterName(obj runtime.Object, createFn Create
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
}
|
}
|
||||||
if clusterName := t.getObjectMetaOrFail(updatedFoo).GetClusterName(); len(clusterName) != 0 {
|
if clusterName := t.getObjectMetaOrFail(updatedFoo).GetZZZ_DeprecatedClusterName(); len(clusterName) != 0 {
|
||||||
t.Errorf("Unexpected clusterName update: expected empty, got %v", clusterName)
|
t.Errorf("Unexpected clusterName update: expected empty, got %v", clusterName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -136,9 +136,9 @@ func BeforeUpdate(strategy RESTUpdateStrategy, ctx context.Context, obj, old run
|
||||||
|
|
||||||
strategy.PrepareForUpdate(ctx, obj, old)
|
strategy.PrepareForUpdate(ctx, obj, old)
|
||||||
|
|
||||||
// ClusterName is ignored and should not be saved
|
// ZZZ_DeprecatedClusterName is ignored and should not be saved
|
||||||
if len(objectMeta.GetClusterName()) > 0 {
|
if len(objectMeta.GetZZZ_DeprecatedClusterName()) > 0 {
|
||||||
objectMeta.SetClusterName("")
|
objectMeta.SetZZZ_DeprecatedClusterName("")
|
||||||
}
|
}
|
||||||
// Use the existing UID if none is provided
|
// Use the existing UID if none is provided
|
||||||
if len(objectMeta.GetUID()) == 0 {
|
if len(objectMeta.GetUID()) == 0 {
|
||||||
|
|
|
@ -395,15 +395,15 @@ func (o *cachingObject) SetOwnerReferences(references []metav1.OwnerReference) {
|
||||||
func() { o.object.SetOwnerReferences(references) },
|
func() { o.object.SetOwnerReferences(references) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
func (o *cachingObject) GetClusterName() string {
|
func (o *cachingObject) GetZZZ_DeprecatedClusterName() string {
|
||||||
o.lock.RLock()
|
o.lock.RLock()
|
||||||
defer o.lock.RUnlock()
|
defer o.lock.RUnlock()
|
||||||
return o.object.GetClusterName()
|
return o.object.GetZZZ_DeprecatedClusterName()
|
||||||
}
|
}
|
||||||
func (o *cachingObject) SetClusterName(clusterName string) {
|
func (o *cachingObject) SetZZZ_DeprecatedClusterName(clusterName string) {
|
||||||
o.conditionalSet(
|
o.conditionalSet(
|
||||||
func() bool { return o.object.GetClusterName() == clusterName },
|
func() bool { return o.object.GetZZZ_DeprecatedClusterName() == clusterName },
|
||||||
func() { o.object.SetClusterName(clusterName) },
|
func() { o.object.SetZZZ_DeprecatedClusterName(clusterName) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
func (o *cachingObject) GetManagedFields() []metav1.ManagedFieldsEntry {
|
func (o *cachingObject) GetManagedFields() []metav1.ManagedFieldsEntry {
|
||||||
|
|
Loading…
Reference in New Issue