2024-05-10 04:56:16 +02:00
|
|
|
package ssh
|
2024-04-09 03:00:40 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
// ErrEndpointWithoutSSHUsername is the error with which Gatus will panic if an endpoint with SSH monitoring is configured without a user.
|
|
|
|
ErrEndpointWithoutSSHUsername = errors.New("you must specify a username for each SSH endpoint")
|
|
|
|
|
|
|
|
// ErrEndpointWithoutSSHPassword is the error with which Gatus will panic if an endpoint with SSH monitoring is configured without a password.
|
|
|
|
ErrEndpointWithoutSSHPassword = errors.New("you must specify a password for each SSH endpoint")
|
|
|
|
)
|
|
|
|
|
2024-05-10 04:56:16 +02:00
|
|
|
type Config struct {
|
2024-04-09 03:00:40 +02:00
|
|
|
Username string `yaml:"username,omitempty"`
|
|
|
|
Password string `yaml:"password,omitempty"`
|
|
|
|
}
|
|
|
|
|
2024-05-10 04:56:16 +02:00
|
|
|
// Validate the SSH configuration
|
|
|
|
func (cfg *Config) Validate() error {
|
|
|
|
if len(cfg.Username) == 0 {
|
2024-04-09 03:00:40 +02:00
|
|
|
return ErrEndpointWithoutSSHUsername
|
|
|
|
}
|
2024-05-10 04:56:16 +02:00
|
|
|
if len(cfg.Password) == 0 {
|
2024-04-09 03:00:40 +02:00
|
|
|
return ErrEndpointWithoutSSHPassword
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|