diff --git a/pkg/analyze/analyzer.go b/pkg/analyze/analyzer.go index f553296d..bff88187 100644 --- a/pkg/analyze/analyzer.go +++ b/pkg/analyze/analyzer.go @@ -28,6 +28,10 @@ func isExcluded(excludeVal multitype.BoolOrString) (bool, error) { return excludeVal.BoolVal, nil } + if excludeVal.StrVal == "" { + return false, nil + } + parsed, err := strconv.ParseBool(excludeVal.StrVal) if err != nil { return false, errors.Wrap(err, "failed to parse bool string") diff --git a/pkg/collect/collector.go b/pkg/collect/collector.go index 49d864a7..a007a257 100644 --- a/pkg/collect/collector.go +++ b/pkg/collect/collector.go @@ -32,6 +32,10 @@ func isExcluded(excludeVal multitype.BoolOrString) (bool, error) { return excludeVal.BoolVal, nil } + if excludeVal.StrVal == "" { + return false, nil + } + parsed, err := strconv.ParseBool(excludeVal.StrVal) if err != nil { return false, errors.Wrap(err, "failed to parse bool string") diff --git a/pkg/multitype/boolstring.go b/pkg/multitype/boolstring.go index 27ffb8ed..b81660ee 100644 --- a/pkg/multitype/boolstring.go +++ b/pkg/multitype/boolstring.go @@ -28,8 +28,8 @@ type BoolOrString struct { type BoolOrStringType int const ( - Bool BoolOrStringType = iota // The BoolOrString holds an bool. - String // The BoolOrString holds a string. + String BoolOrStringType = iota // The BoolOrString holds a string. + Bool // The BoolOrString holds an bool. ) // FromBool creates an BoolOrString object with a bool value. @@ -57,14 +57,14 @@ func (boolstr *BoolOrString) UnmarshalJSON(value []byte) error { return json.Unmarshal(value, &boolstr.BoolVal) } -// String returns the string value, '1' for true, or '' for false. +// String returns the string value, '1' for true, or '0' for false. func (boolstr *BoolOrString) String() string { if boolstr.Type == String { return boolstr.StrVal } else if boolstr.BoolVal { return "1" } else { - return "" + return "0" } }