Fix extra quotes in unmarshaling of the NamespacedName object
This commit is contained in:
		
							parent
							
								
									144c08695b
								
							
						
					
					
						commit
						4bf9cb9fd9
					
				|  | @ -2,6 +2,7 @@ package spec | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"database/sql" | 	"database/sql" | ||||||
|  | 	"encoding/json" | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io/ioutil" | 	"io/ioutil" | ||||||
| 	"log" | 	"log" | ||||||
|  | @ -15,7 +16,6 @@ import ( | ||||||
| 	"k8s.io/client-go/pkg/apis/apps/v1beta1" | 	"k8s.io/client-go/pkg/apis/apps/v1beta1" | ||||||
| 	policyv1beta1 "k8s.io/client-go/pkg/apis/policy/v1beta1" | 	policyv1beta1 "k8s.io/client-go/pkg/apis/policy/v1beta1" | ||||||
| 	"k8s.io/client-go/rest" | 	"k8s.io/client-go/rest" | ||||||
| 	"encoding/json" |  | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // EventType contains type of the events for the TPRs and Pods received from Kubernetes
 | // EventType contains type of the events for the TPRs and Pods received from Kubernetes
 | ||||||
|  | @ -190,7 +190,11 @@ func (n *NamespacedName) Decode(value string) error { | ||||||
| 
 | 
 | ||||||
| func (n *NamespacedName) UnmarshalJSON(data []byte) error { | func (n *NamespacedName) UnmarshalJSON(data []byte) error { | ||||||
| 	result := NamespacedName{} | 	result := NamespacedName{} | ||||||
| 	if err := result.Decode(string(data)); err != nil { | 	var tmp string | ||||||
|  | 	if err := json.Unmarshal(data, &tmp); err != nil { | ||||||
|  | 		return err | ||||||
|  | 	} | ||||||
|  | 	if err := result.Decode(tmp); err != nil { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
| 	*n = result | 	*n = result | ||||||
|  | @ -260,7 +264,7 @@ func (d *Duration) UnmarshalJSON(b []byte) error { | ||||||
| 	} | 	} | ||||||
| 	switch val := v.(type) { | 	switch val := v.(type) { | ||||||
| 	case string: | 	case string: | ||||||
| 		t, err := time.ParseDuration(val); | 		t, err := time.ParseDuration(val) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return err | 			return err | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue