Skip to content

Commit

Permalink
Only validate if url is set
Browse files Browse the repository at this point in the history
  • Loading branch information
jrauh01 committed Jan 17, 2025
1 parent 031e0f8 commit be15d30
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/metrics/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ type PrometheusConfig struct {

// Validate checks constraints in the supplied Prometheus configuration and returns an error if they are violated.
func (c *PrometheusConfig) Validate() error {
if (c.Username == "") != (c.Password == "") {
if c.Url != "" && (c.Username == "") != (c.Password == "") {
return errors.New("both username and password must be provided")
}

return nil
}

0 comments on commit be15d30

Please sign in to comment.