Copy adopted resource info

Signed-off-by: George Jenkins <gvjenkins@gmail.com>
pull/31515/head
George Jenkins 2 months ago
parent 3e06a8a440
commit 855ebb6884

@ -55,7 +55,8 @@ func requireAdoption(resources kube.ResourceList) (kube.ResourceList, error) {
return fmt.Errorf("could not get information about the resource %s: %w", resourceString(info), err)
}
requireUpdate.Append(info)
infoCopy := *info
requireUpdate.Append(&infoCopy)
return nil
})
@ -84,7 +85,8 @@ func existingResourceConflict(resources kube.ResourceList, releaseName, releaseN
return fmt.Errorf("%s exists and cannot be imported into the current release: %s", resourceString(info), err)
}
requireUpdate.Append(info)
infoCopy := *info
requireUpdate.Append(&infoCopy)
return nil
})

@ -132,6 +132,7 @@ func TestRequireAdoption(t *testing.T) {
assert.NoError(t, err)
assert.Len(t, found, 1)
assert.Equal(t, found[0], existing)
assert.NotSame(t, found[0], existing)
}
func TestExistingResourceConflict(t *testing.T) {
@ -156,6 +157,7 @@ func TestExistingResourceConflict(t *testing.T) {
assert.NoError(t, err)
assert.Len(t, found, 1)
assert.Equal(t, found[0], existing)
assert.NotSame(t, found[0], existing)
// Verify that an existing resource that lacks labels/annotations results in an error
resources = append(resources, conflict)

Loading…
Cancel
Save