Merge remote-tracking branch 'origin/master' into release-1.12

Kubernetes-commit: 5f6008cadc6e03bf1c84cae2ef4c239d2a111006
This commit is contained in:
Kubernetes Publisher
2018-08-22 17:10:27 -07:00
8 changed files with 151 additions and 86 deletions
+11
View File
@@ -18,6 +18,7 @@ package intstr
import (
"encoding/json"
"errors"
"fmt"
"math"
"runtime/debug"
@@ -142,7 +143,17 @@ func (intstr *IntOrString) Fuzz(c fuzz.Continue) {
}
}
func ValueOrDefault(intOrPercent *IntOrString, defaultValue IntOrString) *IntOrString {
if intOrPercent == nil {
return &defaultValue
}
return intOrPercent
}
func GetValueFromIntOrPercent(intOrPercent *IntOrString, total int, roundUp bool) (int, error) {
if intOrPercent == nil {
return 0, errors.New("nil value for IntOrString")
}
value, isPercent, err := getIntOrPercentValue(intOrPercent)
if err != nil {
return 0, fmt.Errorf("invalid value for IntOrString: %v", err)