@@ -36,16 +36,19 @@ func generateUserAgent() string {
36
36
return fmt .Sprintf ("kubent (%s/%s)" , version , gitSha )
37
37
}
38
38
39
- func getCollectors (collectors []collector.Collector ) []map [string ]interface {} {
39
+ func getCollectors (collectors []collector.Collector , exitIfError bool ) []map [string ]interface {} {
40
40
var inputs []map [string ]interface {}
41
41
for _ , c := range collectors {
42
42
rs , err := c .Get ()
43
43
if err != nil {
44
44
log .Error ().Err (err ).Str ("name" , c .Name ()).Msg ("Failed to retrieve data from collector" )
45
- } else {
46
- inputs = append (inputs , rs ... )
47
- log .Info ().Str ("name" , c .Name ()).Msgf ("Retrieved %d resources from collector" , len (rs ))
45
+ if exitIfError {
46
+ os .Exit (EXIT_CODE_FAIL_GENERIC )
47
+ }
48
+ continue
48
49
}
50
+ inputs = append (inputs , rs ... )
51
+ log .Info ().Str ("name" , c .Name ()).Msgf ("Retrieved %d resources from collector" , len (rs ))
49
52
}
50
53
return inputs
51
54
}
@@ -123,7 +126,7 @@ func main() {
123
126
log .Info ().Msgf ("Target K8s version is %s" , config .TargetVersion .String ())
124
127
}
125
128
126
- collectors := getCollectors (initCollectors )
129
+ collectors := getCollectors (initCollectors , config . ExitError )
127
130
128
131
// this could probably use some error checking in future, but
129
132
// schema.ParseKindArg does not return any error
0 commit comments