This repository has been archived by the owner on Feb 10, 2024. It is now read-only.
/
PipelineRunType.ts
76 lines (57 loc) · 1.81 KB
/
PipelineRunType.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Copyright (c) 2021. Sendanor <info@sendanor.fi>. All rights reserved.
export enum PipelineRunType {
/**
* No pipeline runs will be created by the system.
*/
NONE = "NONE",
/**
* Schedule single run to be executed by the first available agent.
*
* Only one pipeline instance will be created and added to every configured agent room.
*/
ONCE = "ONCE",
/**
* Schedule multiple runs, one for every agent room configured.
*
* *Note!* Not implemented yet.
*/
ONCE_PER_POOL = "ONCE_POOL"
}
export function isPipelineRunType (value: any): value is PipelineRunType {
switch (value) {
case PipelineRunType.NONE:
case PipelineRunType.ONCE:
case PipelineRunType.ONCE_PER_POOL:
return true;
default:
return false;
}
}
export function stringifyPipelineRunType (value: PipelineRunType): string {
switch (value) {
case PipelineRunType.NONE : return 'NONE';
case PipelineRunType.ONCE : return 'ONCE';
case PipelineRunType.ONCE_PER_POOL : return 'ONCE_PER_POOL';
}
throw new TypeError(`Unsupported PipelineRunType value: ${value}`);
}
export function parsePipelineRunType (value: any): PipelineRunType | undefined {
if ( value === undefined ) return undefined;
switch (`${value}`.toUpperCase()) {
case 'FALSE':
case 'DISABlED':
case 'NEVER':
case 'NONE' : return PipelineRunType.NONE;
case 'TRUE':
case 'ENABLED':
case 'ONCE' :
case 'ONCE_RUN' :
case 'ONCE_PER_RUN' :
return PipelineRunType.ONCE;
case 'ONCE_POOL':
case 'ONCE_PER_POOL' : return PipelineRunType.ONCE_PER_POOL;
default :
return undefined;
}
}
export default PipelineRunType;