Skip to content
Snippets Groups Projects
Commit 4bf9cb9f authored by Oleksii Kliukin's avatar Oleksii Kliukin
Browse files

Fix extra quotes in unmarshaling of the NamespacedName object

parent 144c0869
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ package spec ...@@ -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 ( ...@@ -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 { ...@@ -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 { ...@@ -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
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment