|
|
|
@ -6,6 +6,8 @@ package api
|
|
|
|
|
import ( |
|
|
|
|
"encoding/json" |
|
|
|
|
"time" |
|
|
|
|
|
|
|
|
|
"github.com/hashicorp/go-multierror" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
type ServiceRouterConfigEntry struct { |
|
|
|
@ -189,14 +191,19 @@ func (e *ServiceResolverConfigEntry) MarshalJSON() ([]byte, error) {
|
|
|
|
|
type Alias ServiceResolverConfigEntry |
|
|
|
|
exported := &struct { |
|
|
|
|
ConnectTimeout string `json:",omitempty"` |
|
|
|
|
RequestTimeout string `json:",omitempty"` |
|
|
|
|
*Alias |
|
|
|
|
}{ |
|
|
|
|
ConnectTimeout: e.ConnectTimeout.String(), |
|
|
|
|
RequestTimeout: e.RequestTimeout.String(), |
|
|
|
|
Alias: (*Alias)(e), |
|
|
|
|
} |
|
|
|
|
if e.ConnectTimeout == 0 { |
|
|
|
|
exported.ConnectTimeout = "" |
|
|
|
|
} |
|
|
|
|
if e.RequestTimeout == 0 { |
|
|
|
|
exported.RequestTimeout = "" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return json.Marshal(exported) |
|
|
|
|
} |
|
|
|
@ -205,20 +212,27 @@ func (e *ServiceResolverConfigEntry) UnmarshalJSON(data []byte) error {
|
|
|
|
|
type Alias ServiceResolverConfigEntry |
|
|
|
|
aux := &struct { |
|
|
|
|
ConnectTimeout string |
|
|
|
|
RequestTimeout string |
|
|
|
|
*Alias |
|
|
|
|
}{ |
|
|
|
|
Alias: (*Alias)(e), |
|
|
|
|
} |
|
|
|
|
if err := json.Unmarshal(data, &aux); err != nil { |
|
|
|
|
var err error |
|
|
|
|
if err = json.Unmarshal(data, &aux); err != nil { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
var err error |
|
|
|
|
var merr *multierror.Error |
|
|
|
|
if aux.ConnectTimeout != "" { |
|
|
|
|
if e.ConnectTimeout, err = time.ParseDuration(aux.ConnectTimeout); err != nil { |
|
|
|
|
return err |
|
|
|
|
merr = multierror.Append(merr, err) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return nil |
|
|
|
|
if aux.RequestTimeout != "" { |
|
|
|
|
if e.RequestTimeout, err = time.ParseDuration(aux.RequestTimeout); err != nil { |
|
|
|
|
merr = multierror.Append(merr, err) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return merr.ErrorOrNil() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (e *ServiceResolverConfigEntry) GetKind() string { return e.Kind } |
|
|
|
|