Skip to content

Commit e45d432

Browse files
authored
Refactor console log and add label validation
1 parent 494c48b commit e45d432

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

functions/scheduleinstance/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,9 @@ functions.cloudEvent('stopInstanceEvent', async cloudEvent => {
115115
);
116116

117117
if (instances.length === 0) {
118-
console.log(`
119-
No SQL instances found in project '${project}' matching filter '${filter}'.`);
118+
console.log(
119+
`No SQL instances found in project '${project}' matching filter '${filter}'.`
120+
);
120121
return;
121122
}
122123

@@ -159,6 +160,9 @@ const _validatePayload = cloudEvent => {
159160
if (!payload.label) {
160161
throw new Error("Attribute 'label' missing from payload");
161162
}
163+
if (typeof payload.label !== 'string' || !payload.label.includes('=')) {
164+
throw new Error("Attribute 'label' must be in the format 'key=value'");
165+
}
162166
return payload;
163167
};
164168
// [END functions_start_instance_pubsub]

0 commit comments

Comments
 (0)