Allow describe ns to pass if server does not support resource quotas and limit ranges
This commit is contained in:
		| @@ -173,13 +173,24 @@ func (d *NamespaceDescriber) Describe(namespace, name string, describerSettings | |||||||
| 	} | 	} | ||||||
| 	resourceQuotaList, err := d.Core().ResourceQuotas(name).List(api.ListOptions{}) | 	resourceQuotaList, err := d.Core().ResourceQuotas(name).List(api.ListOptions{}) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return "", err | 		if errors.IsNotFound(err) { | ||||||
|  | 			// Server does not support resource quotas. | ||||||
|  | 			// Not an error, will not show resource quotas information. | ||||||
|  | 			resourceQuotaList = nil | ||||||
|  | 		} else { | ||||||
|  | 			return "", err | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
| 	limitRangeList, err := d.Core().LimitRanges(name).List(api.ListOptions{}) | 	limitRangeList, err := d.Core().LimitRanges(name).List(api.ListOptions{}) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return "", err | 		if errors.IsNotFound(err) { | ||||||
|  | 			// Server does not support limit ranges. | ||||||
|  | 			// Not an error, will not show limit ranges information. | ||||||
|  | 			limitRangeList = nil | ||||||
|  | 		} else { | ||||||
|  | 			return "", err | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	return describeNamespace(ns, resourceQuotaList, limitRangeList) | 	return describeNamespace(ns, resourceQuotaList, limitRangeList) | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -86,6 +86,23 @@ func TestDescribePodTolerations(t *testing.T) { | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | func TestDescribeNamespace(t *testing.T) { | ||||||
|  | 	fake := fake.NewSimpleClientset(&api.Namespace{ | ||||||
|  | 		ObjectMeta: api.ObjectMeta{ | ||||||
|  | 			Name: "myns", | ||||||
|  | 		}, | ||||||
|  | 	}) | ||||||
|  | 	c := &describeClient{T: t, Namespace: "", Interface: fake} | ||||||
|  | 	d := NamespaceDescriber{c} | ||||||
|  | 	out, err := d.Describe("", "myns", DescriberSettings{ShowEvents: true}) | ||||||
|  | 	if err != nil { | ||||||
|  | 		t.Errorf("unexpected error: %v", err) | ||||||
|  | 	} | ||||||
|  | 	if !strings.Contains(out, "myns") { | ||||||
|  | 		t.Errorf("unexpected out: %s", out) | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  |  | ||||||
| func TestDescribeService(t *testing.T) { | func TestDescribeService(t *testing.T) { | ||||||
| 	fake := fake.NewSimpleClientset(&api.Service{ | 	fake := fake.NewSimpleClientset(&api.Service{ | ||||||
| 		ObjectMeta: api.ObjectMeta{ | 		ObjectMeta: api.ObjectMeta{ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 nikhiljindal
					nikhiljindal