Wire resource.Quantity into api

This commit is contained in:
Daniel Smith
2015-01-02 19:10:03 -08:00
parent 3b5c3ec786
commit 894a3e6d3f
8 changed files with 214 additions and 21 deletions

View File

@@ -113,6 +113,14 @@ func (intstr *IntOrString) UnmarshalJSON(value []byte) error {
return json.Unmarshal(value, &intstr.IntVal)
}
// String returns the string value, or Itoa's the int value.
func (intstr *IntOrString) String() string {
if intstr.Kind == IntstrString {
return intstr.StrVal
}
return strconv.Itoa(intstr.IntVal)
}
// MarshalJSON implements the json.Marshaller interface.
func (intstr IntOrString) MarshalJSON() ([]byte, error) {
switch intstr.Kind {