pull/31564/merge
Manoj Kommineni 5 days ago committed by GitHub
commit c1b4a75ad0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -45,7 +45,10 @@ func requireAdoption(resources kube.ResourceList) (kube.ResourceList, error) {
if err != nil {
return err
}
// Using generatedName
if info.Name == "" {
return nil
}
helper := resource.NewHelper(info.Client, info.Mapping)
_, err = helper.Get(info.Namespace, info.Name)
if err != nil {
@ -70,7 +73,10 @@ func existingResourceConflict(resources kube.ResourceList, releaseName, releaseN
if err != nil {
return err
}
// Using generatedName
if info.Name == "" {
return nil
}
helper := resource.NewHelper(info.Client, info.Mapping)
existing, err := helper.Get(info.Namespace, info.Name)
if err != nil {

@ -122,9 +122,10 @@ func fakeClientWith(code int, gv schema.GroupVersion, body string) *fake.RESTCli
func TestRequireAdoption(t *testing.T) {
var (
missing = newMissingDeployment("missing", "ns-a")
existing = newDeploymentWithOwner("existing", "ns-a", nil, nil)
resources = kube.ResourceList{missing, existing}
missing = newMissingDeployment("missing", "ns-a")
existing = newDeploymentWithOwner("existing", "ns-a", nil, nil)
existingWithGeneratedName = newDeploymentWithOwner("", "ns-a", nil, nil)
resources = kube.ResourceList{missing, existing, existingWithGeneratedName}
)
// Verify that a resource that lacks labels/annotations can be adopted
@ -146,10 +147,11 @@ func TestExistingResourceConflict(t *testing.T) {
helmReleaseNameAnnotation: releaseName,
helmReleaseNamespaceAnnotation: releaseNamespace,
}
missing = newMissingDeployment("missing", "ns-a")
existing = newDeploymentWithOwner("existing", "ns-a", labels, annotations)
conflict = newDeploymentWithOwner("conflict", "ns-a", nil, nil)
resources = kube.ResourceList{missing, existing}
missing = newMissingDeployment("missing", "ns-a")
existing = newDeploymentWithOwner("existing", "ns-a", labels, annotations)
existingWithGeneratedName = newDeploymentWithOwner("", "ns-a", nil, nil)
conflict = newDeploymentWithOwner("conflict", "ns-a", nil, nil)
resources = kube.ResourceList{missing, existing, existingWithGeneratedName}
)
// Verify only existing resources are returned

Loading…
Cancel
Save