-
Notifications
You must be signed in to change notification settings - Fork 73
/
config.ts
82 lines (75 loc) · 2.71 KB
/
config.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
import {
getBooleanInput,
getInput,
getMultilineInput,
getNumberInput,
getUnionInput,
getYAMLInput,
} from 'actions-parsers';
import * as rt from 'runtypes';
import { parseSemicolorToArray } from './libs/utils';
// installationConfig is the expected Action inputs when
// the user intends to download the Pulumi CLI without
// running any other Pulumi operations.
// We expect command NOT to be provided.
export const installationConfig = rt.Record({
command: rt.Undefined,
pulumiVersion: rt.String,
});
export type InstallationConfig = rt.Static<typeof installationConfig>;
export function makeInstallationConfig(): rt.Result<InstallationConfig> {
return installationConfig.validate({
command: getInput('command') || undefined,
pulumiVersion: getInput('pulumi-version') || '^3',
});
}
const configValueRt = rt.Dictionary(
rt.Record({
value: rt.String,
secret: rt.Boolean.optional(),
}),
rt.String,
);
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export function makeConfig() {
return {
command: getUnionInput('command', {
required: true,
alternatives: ['up', 'update', 'refresh', 'destroy', 'preview'] as const,
}),
stackName: getInput('stack-name', { required: true }),
pulumiVersion: getInput('pulumi-version', { required: true }),
workDir: getInput('work-dir', { required: true }),
secretsProvider: getInput('secrets-provider'),
cloudUrl: getInput('cloud-url'),
githubToken: getInput('github-token'),
commentOnPr: getBooleanInput('comment-on-pr'),
commentOnPrNumber: getNumberInput('comment-on-pr-number', {}),
upsert: getBooleanInput('upsert'),
remove: getBooleanInput('remove'),
refresh: getBooleanInput('refresh'),
configMap: getYAMLInput('config-map', {
parser: (configMap) => configValueRt.check(configMap),
}),
editCommentOnPr: getBooleanInput('edit-pr-comment'),
options: {
parallel: getNumberInput('parallel', {}),
message: getInput('message'),
expectNoChanges: getBooleanInput('expect-no-changes'),
diff: getBooleanInput('diff'),
replace: parseSemicolorToArray(getMultilineInput('replace')),
target: parseSemicolorToArray(getMultilineInput('target')),
targetDependents: getBooleanInput('target-dependents'),
policyPacks: parseSemicolorToArray(getMultilineInput('policyPacks')),
policyPackConfigs: parseSemicolorToArray(
getMultilineInput('policyPackConfigs'),
),
userAgent: 'pulumi/actions@v3',
color: getUnionInput('color', {
alternatives: ['always', 'never', 'raw', 'auto'] as const,
}),
},
};
}
export type Config = ReturnType<typeof makeConfig>;
export type Commands = Config['command'];