Skip to content

Commit 207a2d3

Browse files
committed
do not check cert if not used
1 parent c0653ee commit 207a2d3

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

main.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,22 +83,22 @@ func main() {
8383
}
8484

8585
func checkArgs(event *corev2.Event) (int, error) {
86+
if len(plugin.CertFile) > 0 || len(plugin.KeyFile) > 0 || len(plugin.TrustedCAFile) > 0{
87+
if _, err := os.Stat(plugin.CertFile); errors.Is(err, os.ErrNotExist) {
88+
fmt.Printf("could not load certificate(%s): %v", plugin.CertFile, err)
89+
return sensu.CheckStateCritical, nil
90+
}
8691

87-
if _, err := os.Stat(plugin.CertFile); errors.Is(err, os.ErrNotExist) {
88-
fmt.Printf("could not load certificate(%s): %v", plugin.CertFile, err)
89-
return sensu.CheckStateCritical, nil
90-
}
91-
92-
if _, err := os.Stat(plugin.KeyFile); errors.Is(err, os.ErrNotExist) {
93-
fmt.Printf("could not load certificate key(%s): %v", plugin.KeyFile, err)
94-
return sensu.CheckStateCritical, nil
95-
}
92+
if _, err := os.Stat(plugin.KeyFile); errors.Is(err, os.ErrNotExist) {
93+
fmt.Printf("could not load certificate key(%s): %v", plugin.KeyFile, err)
94+
return sensu.CheckStateCritical, nil
95+
}
9696

97-
if _, err := os.Stat(plugin.TrustedCAFile); errors.Is(err, os.ErrNotExist) {
98-
fmt.Printf("could not load CA(%s): %v", plugin.TrustedCAFile, err)
99-
return sensu.CheckStateCritical, nil
97+
if _, err := os.Stat(plugin.TrustedCAFile); errors.Is(err, os.ErrNotExist) {
98+
fmt.Printf("could not load CA(%s): %v", plugin.TrustedCAFile, err)
99+
return sensu.CheckStateCritical, nil
100+
}
100101
}
101-
102102
return sensu.CheckStateOK, nil
103103
}
104104

0 commit comments

Comments
 (0)