notifications: fix expvar for Go 1.7
Remove EndpointConfig.Transport from the return value of the registry.notifications.endpoints expvar.Func. It results in an empty value for that expvar variable under Go 1.7 because it is a non-nil *http.Transport, which Go 1.7 can no longer encode as JSON. Signed-off-by: Noah Treuhaft <noah.treuhaft@docker.com>master
							parent
							
								
									62d8d910b5
								
							
						
					
					
						commit
						9a58c91051
					
				|  | @ -13,7 +13,7 @@ type EndpointConfig struct { | ||||||
| 	Threshold         int | 	Threshold         int | ||||||
| 	Backoff           time.Duration | 	Backoff           time.Duration | ||||||
| 	IgnoredMediaTypes []string | 	IgnoredMediaTypes []string | ||||||
| 	Transport         *http.Transport | 	Transport         *http.Transport `json:"-"` | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // defaults set any zero-valued fields to a reasonable default.
 | // defaults set any zero-valued fields to a reasonable default.
 | ||||||
|  |  | ||||||
|  | @ -0,0 +1,28 @@ | ||||||
|  | package notifications | ||||||
|  | 
 | ||||||
|  | import ( | ||||||
|  | 	"encoding/json" | ||||||
|  | 	"expvar" | ||||||
|  | 	"testing" | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | func TestMetricsExpvar(t *testing.T) { | ||||||
|  | 	endpointsVar := expvar.Get("registry").(*expvar.Map).Get("notifications").(*expvar.Map).Get("endpoints") | ||||||
|  | 
 | ||||||
|  | 	var v interface{} | ||||||
|  | 	if err := json.Unmarshal([]byte(endpointsVar.String()), &v); err != nil { | ||||||
|  | 		t.Fatalf("unexpected error unmarshaling endpoints: %v", err) | ||||||
|  | 	} | ||||||
|  | 	if v != nil { | ||||||
|  | 		t.Fatalf("expected nil, got %#v", v) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	NewEndpoint("x", "y", EndpointConfig{}) | ||||||
|  | 
 | ||||||
|  | 	if err := json.Unmarshal([]byte(endpointsVar.String()), &v); err != nil { | ||||||
|  | 		t.Fatalf("unexpected error unmarshaling endpoints: %v", err) | ||||||
|  | 	} | ||||||
|  | 	if slice, ok := v.([]interface{}); !ok || len(slice) != 1 { | ||||||
|  | 		t.Logf("expected one-element []interface{}, got %#v", v) | ||||||
|  | 	} | ||||||
|  | } | ||||||
		Loading…
	
		Reference in New Issue