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