mirror of
https://github.com/TwiN/gatus.git
synced 2026-02-04 13:31:46 +00:00
fix: Don't panic on if there's 0 endpoints and >1 suite + update documentation (#1266)
This commit is contained in:
@@ -43,8 +43,8 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrNoEndpointInConfig is an error returned when a configuration file or directory has no endpoints configured
|
||||
ErrNoEndpointInConfig = errors.New("configuration should contain at least 1 endpoint")
|
||||
// ErrNoEndpointOrSuiteInConfig is an error returned when a configuration file or directory has no endpoints configured
|
||||
ErrNoEndpointOrSuiteInConfig = errors.New("configuration should contain at least one endpoint or suite")
|
||||
|
||||
// ErrConfigFileNotFound is an error returned when a configuration file could not be found
|
||||
ErrConfigFileNotFound = errors.New("configuration file not found")
|
||||
@@ -286,8 +286,8 @@ func parseAndValidateConfigBytes(yamlBytes []byte) (config *Config, err error) {
|
||||
return
|
||||
}
|
||||
// Check if the configuration file at least has endpoints configured
|
||||
if config == nil || config.Endpoints == nil || len(config.Endpoints) == 0 {
|
||||
err = ErrNoEndpointInConfig
|
||||
if config == nil || (len(config.Endpoints) == 0 && len(config.Suites) == 0) {
|
||||
err = ErrNoEndpointOrSuiteInConfig
|
||||
} else {
|
||||
// XXX: Remove this in v6.0.0
|
||||
if config.Debug {
|
||||
|
||||
@@ -135,7 +135,7 @@ endpoints:
|
||||
pathAndFiles: map[string]string{
|
||||
"config.yaml": "",
|
||||
},
|
||||
expectedError: ErrNoEndpointInConfig,
|
||||
expectedError: ErrNoEndpointOrSuiteInConfig,
|
||||
},
|
||||
{
|
||||
name: "dir-with-two-config-files",
|
||||
@@ -737,8 +737,8 @@ badconfig:
|
||||
if err == nil {
|
||||
t.Error("An error should've been returned")
|
||||
}
|
||||
if err != ErrNoEndpointInConfig {
|
||||
t.Error("The error returned should have been of type ErrNoEndpointInConfig")
|
||||
if err != ErrNoEndpointOrSuiteInConfig {
|
||||
t.Error("The error returned should have been of type ErrNoEndpointOrSuiteInConfig")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1893,8 +1893,8 @@ endpoints:
|
||||
|
||||
func TestParseAndValidateConfigBytesWithNoEndpoints(t *testing.T) {
|
||||
_, err := parseAndValidateConfigBytes([]byte(``))
|
||||
if !errors.Is(err, ErrNoEndpointInConfig) {
|
||||
t.Error("The error returned should have been of type ErrNoEndpointInConfig")
|
||||
if !errors.Is(err, ErrNoEndpointOrSuiteInConfig) {
|
||||
t.Error("The error returned should have been of type ErrNoEndpointOrSuiteInConfig")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user