Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Commit e66aea8

Browse files
authored
Add labels specified in serverless.yml functions to triggers (#223)
1 parent 5775426 commit e66aea8

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

lib/deploy.js

+23-12
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,10 @@ function deployMQTrigger(mqType, name, namespace, topic, options) {
400400
metadata: {
401401
name: _.kebabCase(`${name}-${topic}`),
402402
namespace,
403-
labels: {
404-
'created-by': 'kubeless',
405-
},
403+
labels: Object.assign(
404+
{ 'created-by': 'kubeless' },
405+
options.labels
406+
),
406407
},
407408
spec: {
408409
functionSelector: {
@@ -438,9 +439,10 @@ function deployScheduleTrigger(name, namespace, schedule, options) {
438439
metadata: {
439440
name,
440441
namespace,
441-
labels: {
442-
'created-by': 'kubeless',
443-
},
442+
labels: Object.assign(
443+
{ 'created-by': 'kubeless' },
444+
options.labels
445+
),
444446
},
445447
spec: {
446448
'function-name': name,
@@ -474,9 +476,10 @@ function deployHttpTrigger(name, namespace, path, options) {
474476
metadata: {
475477
name,
476478
namespace,
477-
labels: {
478-
'created-by': 'kubeless',
479-
},
479+
labels: Object.assign(
480+
{ 'created-by': 'kubeless' },
481+
options.labels
482+
),
480483
annotations: Object.assign(baseAnnotations, options.ingress.additionalAnnotations),
481484
},
482485
spec: {
@@ -590,7 +593,7 @@ function handleMQTDeployment(trigger, name, namespace, options) {
590593
name,
591594
namespace,
592595
mqTrigger.topic,
593-
{ log: options.log }
596+
options
594597
);
595598
}
596599

@@ -614,6 +617,7 @@ function deployTrigger(event, funcName, namespace, service, options) {
614617
log: options.log,
615618
ingress: options.ingress || {},
616619
hostname: event.hostname || options.hostname || defaultHostname,
620+
labels: options.labels,
617621
}
618622
);
619623
break;
@@ -625,7 +629,10 @@ function deployTrigger(event, funcName, namespace, service, options) {
625629
event.trigger,
626630
funcName,
627631
namespace,
628-
{ log: options.log }
632+
{
633+
log: options.log,
634+
labels: options.labels,
635+
}
629636
);
630637
break;
631638
case 'schedule':
@@ -636,7 +643,10 @@ function deployTrigger(event, funcName, namespace, service, options) {
636643
funcName,
637644
namespace,
638645
event.schedule,
639-
{ log: options.log }
646+
{
647+
log: options.log,
648+
labels: options.labels,
649+
}
640650
);
641651
break;
642652
default:
@@ -661,6 +671,7 @@ function deploy(functions, runtime, service, options) {
661671
verbose: false,
662672
log: console.log,
663673
contentType: ('contentType' in description) ? description.contentType : 'text',
674+
labels: description.labels || {},
664675
});
665676

666677
const ns = description.namespace || opts.namespace;

0 commit comments

Comments
 (0)