Skip to content

Commit 707b095

Browse files
authored
Add option to configure tlsServerName (kedacore#6820)
* Add option to configure tlsServerName Signed-off-by: dttung2905 <[email protected]> * Add CHANGELOG.md Signed-off-by: dttung2905 <[email protected]> --------- Signed-off-by: dttung2905 <[email protected]>
1 parent 8a6ee85 commit 707b095

File tree

3 files changed

+88
-5
lines changed

3 files changed

+88
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ To learn more about active deprecations, we recommend checking [GitHub Discussio
7272
- **General**: Improve Events emitted from ScaledObject controller ([#6802](https://github.com/kedacore/keda/issues/6802))
7373
- **General**: Internal gRPC connection's certificates are hot reloaded ([#6756](https://github.com/kedacore/keda/pull/6756))
7474
- **Metrics API**: Support multiple auth methods simultaneously in Metrics API scaler ([#6642](https://github.com/kedacore/keda/issues/6642))
75+
- **Temporal Scaler**: Support custom tlsServerName ([#6820](https://github.com/kedacore/keda/pull/6820))
7576

7677
### Fixes
7778

pkg/scalers/temporal.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,12 @@ type temporalMetadata struct {
4747
APIKey string `keda:"name=apiKey, order=authParams;resolvedEnv, optional"`
4848
MinConnectTimeout int `keda:"name=minConnectTimeout, order=triggerMetadata, default=5"`
4949

50-
UnsafeSsl bool `keda:"name=unsafeSsl, order=triggerMetadata, optional"`
51-
Cert string `keda:"name=cert, order=authParams, optional"`
52-
Key string `keda:"name=key, order=authParams, optional"`
53-
KeyPassword string `keda:"name=keyPassword, order=authParams, optional"`
54-
CA string `keda:"name=ca, order=authParams, optional"`
50+
UnsafeSsl bool `keda:"name=unsafeSsl, order=triggerMetadata, optional"`
51+
Cert string `keda:"name=cert, order=authParams, optional"`
52+
Key string `keda:"name=key, order=authParams, optional"`
53+
KeyPassword string `keda:"name=keyPassword, order=authParams, optional"`
54+
CA string `keda:"name=ca, order=authParams, optional"`
55+
TLSServerName string `keda:"name=tlsServerName, order=triggerMetadata, optional"`
5556

5657
triggerIndex int
5758
}
@@ -240,6 +241,10 @@ func getTemporalClient(ctx context.Context, meta *temporalMetadata, log logr.Log
240241
}
241242
}
242243

244+
if tlsConfig != nil && meta.TLSServerName != "" {
245+
tlsConfig.ServerName = meta.TLSServerName
246+
}
247+
243248
options.ConnectionOptions = sdk.ConnectionOptions{
244249
DialOptions: dialOptions,
245250
TLS: tlsConfig,

pkg/scalers/temporal_test.go

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,83 @@ func TestParseTemporalMetadata(t *testing.T) {
248248
},
249249
wantErr: false,
250250
},
251+
{
252+
name: "with tlsServerName",
253+
metadata: map[string]string{
254+
"endpoint": "test:7233",
255+
"namespace": "default",
256+
"taskQueue": "testxx",
257+
"tlsServerName": "my-namespace.tmpr.cloud",
258+
},
259+
wantMeta: &temporalMetadata{
260+
Endpoint: "test:7233",
261+
Namespace: "default",
262+
TaskQueue: "testxx",
263+
TargetQueueSize: 5,
264+
ActivationTargetQueueSize: 0,
265+
AllActive: false,
266+
Unversioned: false,
267+
MinConnectTimeout: 5,
268+
TLSServerName: "my-namespace.tmpr.cloud",
269+
},
270+
wantErr: false,
271+
},
272+
{
273+
name: "with tlsServerName and apiKey",
274+
metadata: map[string]string{
275+
"endpoint": "test:7233",
276+
"namespace": "default",
277+
"taskQueue": "testxx",
278+
"tlsServerName": "my-namespace.tmpr.cloud",
279+
},
280+
authParams: map[string]string{
281+
"apiKey": "test01",
282+
},
283+
wantMeta: &temporalMetadata{
284+
Endpoint: "test:7233",
285+
Namespace: "default",
286+
TaskQueue: "testxx",
287+
TargetQueueSize: 5,
288+
ActivationTargetQueueSize: 0,
289+
AllActive: false,
290+
Unversioned: false,
291+
APIKey: "test01",
292+
MinConnectTimeout: 5,
293+
TLSServerName: "my-namespace.tmpr.cloud",
294+
},
295+
wantErr: false,
296+
},
297+
{
298+
name: "with tlsServerName and certificate",
299+
metadata: map[string]string{
300+
"endpoint": "test:7233",
301+
"namespace": "default",
302+
"taskQueue": "testxx",
303+
"tlsServerName": "my-namespace.tmpr.cloud",
304+
},
305+
authParams: map[string]string{
306+
"cert": "cert-data",
307+
"key": "key-data",
308+
"keyPassword": "password",
309+
"ca": "ca-data",
310+
},
311+
wantMeta: &temporalMetadata{
312+
Endpoint: "test:7233",
313+
Namespace: "default",
314+
TaskQueue: "testxx",
315+
TargetQueueSize: 5,
316+
ActivationTargetQueueSize: 0,
317+
AllActive: false,
318+
Unversioned: false,
319+
Cert: "cert-data",
320+
Key: "key-data",
321+
KeyPassword: "password",
322+
CA: "ca-data",
323+
MinConnectTimeout: 5,
324+
TLSServerName: "my-namespace.tmpr.cloud",
325+
},
326+
wantErr: false,
327+
},
251328
}
252329

253330
for _, testCase := range cases {

0 commit comments

Comments
 (0)