File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -225,13 +225,16 @@ func (service *StatusCakeMonitorService) Setup(p config.Provider) {
225225// GetByName function will Get a monitor by it's name
226226func (service * StatusCakeMonitorService ) GetByName (name string ) (* models.Monitor , error ) {
227227 monitors := service .GetAll ()
228- for _ , monitor := range monitors {
229- if monitor .Name == name {
230- return & monitor , nil
228+ if len (monitors ) != 0 {
229+ for _ , monitor := range monitors {
230+ if monitor .Name == name {
231+ return & monitor , nil
232+ }
231233 }
232234 }
233235 errorString := "GetByName Request failed for name: " + name
234236 return nil , errors .New (errorString )
237+
235238}
236239
237240// GetByID function will Get a monitor by it's ID
@@ -304,6 +307,7 @@ func (service *StatusCakeMonitorService) GetAll() []models.Monitor {
304307 bodyBytes , err := io .ReadAll (resp .Body )
305308 if err != nil {
306309 log .Error (err , "Unable to read response body" )
310+ return nil
307311 }
308312
309313 if resp .StatusCode == http .StatusOK {
You can’t perform that action at this time.
0 commit comments