/
workflow.flags.ts
123 lines (110 loc) · 4.42 KB
/
workflow.flags.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import { CheckBoxFlag, DropDownFlag, InputFlag } from './flag';
export class NewWorkflowFlags {
flags= {};
constructor(workflows) {
// General flags.
this.flags['skip_start'] = new SkipStartFlag(0, 'skip_start');
this.flags['skip_start'].positional = true;
this.flags['skip_start'].namedPositional = 'skip_start';
this.flags['factory_name'] = new FactoryNameFlag(1, 'factory_name', workflows);
this.flags['factory_name'].positional = true;
// Flags for the Sleep workflow.
this.flags['sleep_duration'] = new SleepDurationFlag(2, 'sleep_duration');
this.flags['sleep_duration'].positional = true;
this.flags['sleep_duration'].namedPositional = 'duration';
// Flags for the Schema Swap workflow.
this.flags['schema_swap_keyspace'] = new SchemaSwapKeyspaceFlag(3, 'schema_swap_keyspace');
this.flags['schema_swap_keyspace'].positional = true;
this.flags['schema_swap_keyspace'].namedPositional = 'keyspace';
this.flags['schema_swap_sql'] = new SchemaSwapSQLFlag(4, 'schema_swap_sql');
this.flags['schema_swap_sql'].positional = true;
this.flags['schema_swap_sql'].namedPositional = 'sql';
// Flags for Horizontal Resharding workflow.
this.flags['horizontal_resharding_keyspace'] = new HorizontalReshardingKeyspaceFlag(5, 'horizontal_resharding_keyspace');
this.flags['horizontal_resharding_keyspace'].positional = true;
this.flags['horizontal_resharding_keyspace'].namedPositional = 'keyspace';
this.flags['horizontal_resharding_vtworkers'] = new HorizontalReshardingVtworkerFlag(6, 'horizontal_resharding_vtworkers');
this.flags['horizontal_resharding_vtworkers'].positional = true
this.flags['horizontal_resharding_vtworkers'].namedPositional = 'vtworkers'
}
}
export class FactoryNameFlag extends DropDownFlag {
constructor(position: number, id: string, workflows) {
super(position, id, 'Factory Name', 'Specifies the type of workflow to create.', '');
let options = [];
if (workflows.horizontal_resharding) {
options.push({
label: 'Horizontal Resharding',
value: 'horizontal_resharding'
});
}
if (workflows.schema_swap) {
options.push({
label: 'Schema Swap',
value: 'schema_swap'
});
}
if (workflows.sleep) {
options.push({
label: 'Sleep',
value: 'sleep'
});
}
if (workflows.topo_validator) {
options.push({
label: 'Topology Validator',
value: 'topo_validator',
});
}
this.setOptions(options);
this.value = options[0].value;
}
}
export class SkipStartFlag extends CheckBoxFlag {
constructor(position: number, id: string, value= false) {
super(position, id, 'Skip Start', 'Create the workflow, but don\'t start it.', value);
}
}
export class SleepDurationFlag extends InputFlag {
constructor(position: number, id: string, value= '') {
super(position, id, 'Sleep Duration', 'Time to sleep for, in seconds.', value);
this.setDisplayOn('factory_name', 'sleep');
}
}
export class SchemaSwapKeyspaceFlag extends InputFlag {
constructor(position: number, id: string, value= '') {
super(position, id, 'Keyspace', 'Name of a keyspace.', value);
this.setDisplayOn('factory_name', 'schema_swap');
}
}
export class SchemaSwapSQLFlag extends InputFlag {
constructor(position: number, id: string, value= '') {
super(position, id, 'SQL', 'SQL representing the schema change.', value);
this.setDisplayOn('factory_name', 'schema_swap');
}
}
export class HorizontalReshardingKeyspaceFlag extends InputFlag {
constructor(position: number, id: string, value= '') {
super(position, id, 'Keyspace', 'Name of a keyspace.', value);
this.setDisplayOn('factory_name', 'horizontal_resharding');
}
}
export class HorizontalReshardingVtworkerFlag extends InputFlag {
constructor(position: number, id: string, value= '') {
super(position, id, 'Vtworkers', 'Comma-separated list of vtworker addresses.', value);
this.setDisplayOn('factory_name', 'horizontal_resharding');
}
}
// WorkflowFlags is used by the Start / Stop / Delete dialogs.
export class WorkflowFlags {
flags= {};
constructor(path) {
this.flags['workflow_uuid'] = new WorkflowUuidFlag(0, 'workflow_uuid', path);
this.flags['workflow_uuid']['positional'] = true;
}
}
export class WorkflowUuidFlag extends InputFlag {
constructor(position: number, id: string, value= '') {
super(position, id, '', '', value, false);
}
}