This repository was archived by the owner on Jun 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathExecutorMapping.tsx
More file actions
129 lines (123 loc) · 3.68 KB
/
ExecutorMapping.tsx
File metadata and controls
129 lines (123 loc) · 3.68 KB
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
124
125
126
127
128
129
import { executors, Job, reusable, WorkflowJob } from '@circleci/circleci-config-sdk';
import ExecutorSummary from '../components/atoms/summaries/ExecutorSummary';
import ExecutorInspector from '../components/containers/inspector/ExecutorInspector';
import { executorSubtypes } from '../components/containers/inspector/subtypes/ExecutorSubtypes';
import { componentParametersSubtypes } from '../components/containers/inspector/subtypes/ParameterSubtypes';
import ExecutorTypePageNav from '../components/menus/definitions/subtypes/ExecutorTypePage';
import ExecutorIcon from '../icons/components/ExecutorIcon';
import ComponentMapping from './ComponentMapping';
import JobMapping from './JobMapping';
export type AnyExecutor =
| executors.DockerExecutor
| executors.MacOSExecutor
| executors.MachineExecutor
| executors.WindowsExecutor
| executors.Executor;
const transform = (values: any) => {
const subtypes: { [type: string]: () => AnyExecutor } = {
docker: () =>
new executors.DockerExecutor(
values.executor.image.image || 'cimg/base:stable',
values.executor.resource_class,
values.executor.parameters,
),
machine: () =>
new executors.MachineExecutor(
values.executor.resource_class,
values.executor.image || 'cimg/base:latest',
values.executor.parameters,
),
macos: () =>
new executors.MacOSExecutor(
values.executor.xcode,
values.executor.resource_class,
values.executor.parameters,
),
windows: () =>
new executors.WindowsExecutor(
values.executor.image,
values.executor.resource_class,
values.executor.parameters,
),
};
return new reusable.ReusableExecutor(values.name, subtypes[values.type]());
};
const ExecutorMapping: ComponentMapping<reusable.ReusableExecutor, WorkflowJob> = {
type: 'executors',
name: {
singular: 'Executor',
plural: 'Executors',
},
defaults: {
docker: {
name: 'docker',
executor: {
image: {
image: 'cimg/base:stable',
},
parameters: {},
},
resource_class: 'medium',
},
machine: {
name: 'machine',
executor: {
image: 'ubuntu-2004:202111-01',
parameters: {},
},
resource_class: 'medium',
},
macos: {
name: 'macos',
executor: {
xcode: '13.2.0',
parameters: {},
},
resource_class: 'medium',
},
windows: {
name: 'windows_server',
executor: {
image: 'windows-server-2019-vs2019:stable',
parameters: {},
},
resource_class: 'medium',
},
},
parameters: componentParametersSubtypes.executor,
transform: transform,
store: {
get: (state) => state.definitions.executors,
add: (actions) => actions.defineExecutor,
update: (actions) => actions.updateExecutor,
remove: (actions) => actions.undefineExecutor,
},
dragTarget: JobMapping.type,
applyToNode: (data, nodeData) => {
const oldJob = nodeData.job;
return new WorkflowJob(
new Job(oldJob.name, data, oldJob.steps),
nodeData.parameters,
);
},
subtypes: {
component: ExecutorTypePageNav,
getSubtype: (reusableExec: reusable.ReusableExecutor) => {
return Object.keys(executorSubtypes).find(
(subtype) =>
reusableExec.executor instanceof executorSubtypes[subtype].component,
);
},
definitions: executorSubtypes,
},
components: {
icon: ExecutorIcon,
summary: ExecutorSummary,
inspector: ExecutorInspector,
},
docsInfo: {
description: 'Technology/Environment to run with',
link: 'https://circleci.com/docs/2.0/executor-types/',
},
};
export default ExecutorMapping;