Skip to content

Commit

Permalink
feat: Allow specifying Selenium Grid URL as secret (kedacore#3752)
Browse files Browse the repository at this point in the history
* feat: Allow specifying Selenium Grid URL as secret

This allows specifying the GraphQL URL used by the Selenium Grid Scaler
to be specified in a TriggerAuthentication resource and thus pulled from
a secret store. We are using Selenium Grid's basic authentication and
needed to specify a username/password as part of the URL.

Signed-off-by: JD Harrington <jd@jdharrington.net>

* Add PR reference to CHANGELOG.md

Co-authored-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
Signed-off-by: JD Harrington <jd@jdharrington.net>

Signed-off-by: JD Harrington <jd@jdharrington.net>
Co-authored-by: Jorge Turrado Ferrero <Jorge_turrado@hotmail.es>
Signed-off-by: 26tanishabanik <26tanishabanik@gmail.com>
  • Loading branch information
2 people authored and 26tanishabanik committed Nov 1, 2022
1 parent 05d4e33 commit 1708e37
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ To learn more about active deprecations, we recommend checking [GitHub Discussio
- **General:** Introduce new CouchDB Scaler ([#3746](https://github.com/kedacore/keda/issues/3746))
- **Azure Service Bus Scaler**: Add support for Shared Access Signature (SAS) tokens for authentication. ([#2920](https://github.com/kedacore/keda/issues/2920))
- **Azure Service Bus Scaler:** Support regex usage in queueName / subscriptionName parameters. ([#1624](https://github.com/kedacore/keda/issues/1624))
- **Selenium Grid Scaler:** Allow setting url trigger parameter from TriggerAuthentication/ClusterTriggerAuthentication ([#3752](https://github.com/kedacore/keda/pull/3752))

### Improvements

Expand Down
4 changes: 3 additions & 1 deletion pkg/scalers/selenium_grid_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ func parseSeleniumGridScalerMetadata(config *ScalerConfig) (*seleniumGridScalerM
targetValue: 1,
}

if val, ok := config.TriggerMetadata["url"]; ok {
if val, ok := config.AuthParams["url"]; ok {
meta.url = val
} else if val, ok := config.TriggerMetadata["url"]; ok {
meta.url = val
} else {
return nil, fmt.Errorf("no selenium grid url given in metadata")
Expand Down
22 changes: 22 additions & 0 deletions pkg/scalers/selenium_grid_scaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,28 @@ func Test_parseSeleniumGridScalerMetadata(t *testing.T) {
browserVersion: "latest",
},
},
{
name: "valid url in AuthParams, browsername, and sessionbrowsername should return metadata",
args: args{
config: &ScalerConfig{
AuthParams: map[string]string{
"url": "http://user:password@selenium-hub:4444/graphql",
},
TriggerMetadata: map[string]string{
"browserName": "MicrosoftEdge",
"sessionBrowserName": "msedge",
},
},
},
wantErr: false,
want: &seleniumGridScalerMetadata{
url: "http://user:password@selenium-hub:4444/graphql",
browserName: "MicrosoftEdge",
sessionBrowserName: "msedge",
targetValue: 1,
browserVersion: "latest",
},
},
{
name: "valid url and browsername should return metadata",
args: args{
Expand Down

0 comments on commit 1708e37

Please sign in to comment.