Use IntOrString for HTTP health check ports

Clean up code to be more testable.  Add test cases for named and numeric
ports in HTTP health checks.  Improve tests.
This commit is contained in:
Tim Hockin
2014-08-10 23:26:42 -07:00
parent e35dfedd79
commit 7201227cb1
8 changed files with 153 additions and 48 deletions

View File

@@ -83,6 +83,16 @@ const (
IntstrString // The IntOrString holds a string.
)
// MakeIntOrStringFromInt creates an IntOrString object with an int value.
func MakeIntOrStringFromInt(val int) IntOrString {
return IntOrString{Kind: IntstrInt, IntVal: val}
}
// MakeIntOrStringFromInt creates an IntOrString object with a string value.
func MakeIntOrStringFromString(val string) IntOrString {
return IntOrString{Kind: IntstrString, StrVal: val}
}
// SetYAML implements the yaml.Setter interface.
func (intstr *IntOrString) SetYAML(tag string, value interface{}) bool {
switch v := value.(type) {