Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
Signed-off-by: rickbrouwer <[email protected]>
  • Loading branch information
rickbrouwer authored Oct 22, 2024
1 parent 58365d8 commit fe41f5a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/scalers/mongo_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ type mongoDBMetadata struct {
TriggerIndex int
}

const (
mongoDBSRVScheme = "mongodb+srv"
)

func (m *mongoDBMetadata) Validate() error {
if m.ConnectionString == "" {
if m.Host == "" {
return fmt.Errorf("no host given")
}
if m.Port == "" && m.Scheme != "mongodb+srv" {
if m.Port == "" && m.Scheme != mongoDBSRVScheme {
return fmt.Errorf("no port given")
}
if m.Username == "" {
Expand Down Expand Up @@ -104,7 +108,7 @@ func createMongoDBClient(ctx context.Context, meta mongoDBMetadata) (*mongo.Clie
if meta.ConnectionString != "" {
connString = meta.ConnectionString
} else {
if meta.Scheme == "mongodb+srv" {
if meta.Scheme == mongoDBSRVScheme {
u := &url.URL{
Scheme: meta.Scheme,
User: url.UserPassword(meta.Username, meta.Password),
Expand Down

0 comments on commit fe41f5a

Please sign in to comment.