node.cluster is optional in the bootstrap file

This commit is contained in:
Michael Lumish 2020-08-25 09:45:47 -07:00
parent 0e8e1adfc4
commit 7e35657cf1
1 changed files with 8 additions and 9 deletions

View File

@ -157,15 +157,6 @@ function validateNode(obj: any): Node {
throw new Error(`node.id field: expected string, got ${typeof obj.id}`);
}
result.id = obj.id;
if (!('cluster' in obj)) {
throw new Error('cluster field missing in node element');
}
if (typeof obj.cluster !== 'string') {
throw new Error(
`node.cluster field: expected string, got ${typeof obj.cluster}`
);
}
result.cluster = obj.cluster;
if (!('locality' in obj)) {
throw new Error('locality field missing in node element');
}
@ -197,6 +188,14 @@ function validateNode(obj: any): Node {
}
result.locality.sub_zone = obj.locality.sub_zone;
}
if ('cluster' in obj) {
if (typeof obj.cluster !== 'string') {
throw new Error(
`node.cluster field: expected string, got ${typeof obj.cluster}`
);
}
result.cluster = obj.cluster;
}
if ('metadata' in obj) {
result.metadata = getStructFromJson(obj.metadata);
}