@intentius/terragucci 0.2.1 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/terragucci.mjs +245 -233
- package/dist/terragucci.mjs.map +4 -4
- package/dist/types.d.ts +47 -19
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
export declare const BINARIES: readonly ["terraform", "tofu", "choudoufu"
|
|
1
|
+
export declare const BINARIES: readonly ["terraform", "tofu", "choudoufu"];
|
|
2
2
|
export declare const FORGES: readonly ["github", "gitlab", "forgejo"];
|
|
3
3
|
export declare const GATES: readonly ["always", "on-destroy", "never"];
|
|
4
|
-
|
|
4
|
+
/** Every stage runs on the forge's CI. */
|
|
5
|
+
export declare const RUNTIMES: readonly ["forge"];
|
|
5
6
|
export declare const DEPENDENTS: readonly ["follow", "plan"];
|
|
6
7
|
export declare const POLICY_ENGINES: readonly ["conftest", "opa"];
|
|
7
8
|
export declare const POLICY_INPUTS: readonly ["plan", "hcp"];
|
|
9
|
+
/** When a change applies: after it merges (default), or from its open pull request before it merges. */
|
|
10
|
+
export declare const APPLY_WHEN: readonly ["merge", "pull-request"];
|
|
11
|
+
/** With `apply.when: pull-request`, who merges once every wave applied: a person (default), or terragucci. */
|
|
12
|
+
export declare const APPLY_MERGE: readonly ["manual", "auto"];
|
|
8
13
|
export type Binary = (typeof BINARIES)[number];
|
|
9
14
|
export type ForgeName = (typeof FORGES)[number];
|
|
10
15
|
export type Gate = (typeof GATES)[number];
|
|
@@ -12,6 +17,23 @@ export type Runtime = (typeof RUNTIMES)[number];
|
|
|
12
17
|
export type Dependents = (typeof DEPENDENTS)[number];
|
|
13
18
|
export type PolicyEngine = (typeof POLICY_ENGINES)[number];
|
|
14
19
|
export type PolicyInput = (typeof POLICY_INPUTS)[number];
|
|
20
|
+
export type ApplyWhen = (typeof APPLY_WHEN)[number];
|
|
21
|
+
export type ApplyMerge = (typeof APPLY_MERGE)[number];
|
|
22
|
+
/**
|
|
23
|
+
* `apply:`: when a change applies. `when: merge` (the default) applies the
|
|
24
|
+
* default branch after a merge. `when: pull-request` applies an open pull
|
|
25
|
+
* request's head on `/terragucci apply`, under the same waves and gates, and
|
|
26
|
+
* the push after the merge plans and reports drift without applying.
|
|
27
|
+
* `merge: auto` merges the pull request once every wave applied, in a job of
|
|
28
|
+
* its own, with the token in the secret `merge_token_env` names when it is
|
|
29
|
+
* set (required on Forgejo, whose job token cannot push to the default
|
|
30
|
+
* branch). Plain roots on GitHub and Forgejo only (NO_GITLAB_PR_APPLY).
|
|
31
|
+
*/
|
|
32
|
+
export interface ApplySettings {
|
|
33
|
+
when?: ApplyWhen;
|
|
34
|
+
merge?: ApplyMerge;
|
|
35
|
+
merge_token_env?: string;
|
|
36
|
+
}
|
|
15
37
|
/**
|
|
16
38
|
* Policy as code, off unless set. `tf-plan` runs the engine over each planned
|
|
17
39
|
* root's plan JSON and fails the root on a denial. No response, agent or
|
|
@@ -79,27 +101,24 @@ export interface TerragruntSettings {
|
|
|
79
101
|
}
|
|
80
102
|
/**
|
|
81
103
|
* Pipeline events and the responses each takes. The first mode is the
|
|
82
|
-
* default and needs no model
|
|
83
|
-
* top of the deterministic response, and is never the default. `drift:
|
|
84
|
-
* attribute` also names who changed each drifted attribute (a known-writes
|
|
104
|
+
* default and needs no model. `drift: attribute` also names who changed each drifted attribute (a known-writes
|
|
85
105
|
* table, then the audit log, then a typed decision when `decide:` is set).
|
|
86
106
|
*/
|
|
87
107
|
export declare const RESPONSES: {
|
|
88
|
-
readonly plan: readonly ["summary"
|
|
108
|
+
readonly plan: readonly ["summary"];
|
|
89
109
|
readonly "wave-refused": readonly ["diff", "off"];
|
|
90
|
-
readonly "apply-failed": readonly ["triage", "
|
|
91
|
-
readonly drift: readonly ["pull-request", "attribute", "
|
|
110
|
+
readonly "apply-failed": readonly ["triage", "off"];
|
|
111
|
+
readonly drift: readonly ["pull-request", "attribute", "off"];
|
|
92
112
|
readonly tips: readonly ["pull-request", "off"];
|
|
93
113
|
readonly fmt: readonly ["commit", "off"];
|
|
94
|
-
readonly publish: readonly ["notes", "
|
|
114
|
+
readonly publish: readonly ["notes", "off"];
|
|
95
115
|
readonly rollout: readonly ["next-wave", "off"];
|
|
96
|
-
readonly question: readonly ["off", "agent"];
|
|
97
116
|
readonly "version-bump": readonly ["off", "suggest"];
|
|
98
117
|
/** terragucci#30: a typed decision flags a pull request whose description leaves out what its plan destroys or replaces. Needs `decide:`. */
|
|
99
118
|
readonly description: readonly ["off", "check"];
|
|
100
119
|
};
|
|
101
120
|
export type RespondEvent = keyof typeof RESPONSES;
|
|
102
|
-
export declare const AGENT_VIA: readonly ["forge"
|
|
121
|
+
export declare const AGENT_VIA: readonly ["forge"];
|
|
103
122
|
/** The services `decide:` can name; each speaks the Jev request and response shape. */
|
|
104
123
|
export declare const DECIDE_BACKENDS: readonly ["laya", "von", "decider", "jev"];
|
|
105
124
|
export type DecideBackend = (typeof DECIDE_BACKENDS)[number];
|
|
@@ -146,8 +165,8 @@ export declare const DASHBOARD_DURATION_KEYS: readonly ["drift_age", "wave_wait"
|
|
|
146
165
|
* `agent.comment`: the `/terragucci agent <ask>` pull request comment, off
|
|
147
166
|
* unless set. The comment starts a job that runs a coding agent on the pull
|
|
148
167
|
* request's head branch and pushes what it changes with `agent.token_env`'s
|
|
149
|
-
* token. The job gets no cloud credentials: no `oidc` role
|
|
150
|
-
*
|
|
168
|
+
* token. The job gets no cloud credentials: no `oidc` role. `true` takes every
|
|
169
|
+
* default.
|
|
151
170
|
*/
|
|
152
171
|
export interface AgentCommentSettings {
|
|
153
172
|
/** The agent's command line, run in the checkout with the prompt on stdin. Default: Claude Code in print mode with file tools only (AGENT_COMMAND in agent-comment.ts). */
|
|
@@ -174,6 +193,8 @@ export interface ProjectSettings {
|
|
|
174
193
|
url?: string;
|
|
175
194
|
/** When a wave waits for an approval. */
|
|
176
195
|
gate?: Gate;
|
|
196
|
+
/** When a change applies; see ApplySettings. */
|
|
197
|
+
apply?: ApplySettings;
|
|
177
198
|
waves?: {
|
|
178
199
|
canary?: string[];
|
|
179
200
|
};
|
|
@@ -184,12 +205,15 @@ export interface ProjectSettings {
|
|
|
184
205
|
* A bucket for plan reports. `url` is the address that serves the bucket's
|
|
185
206
|
* objects to a browser (a static site, a CDN, the store's public endpoint);
|
|
186
207
|
* with it, the note, the index and the dashboards link the bucket's copy.
|
|
208
|
+
* `role` is an AWS role the job assumes with its OIDC token to write the
|
|
209
|
+
* reports, apart from the job's own role.
|
|
187
210
|
*/
|
|
188
211
|
reports?: {
|
|
189
212
|
bucket: string;
|
|
190
213
|
endpoint?: string;
|
|
191
214
|
prefix?: string;
|
|
192
215
|
url?: string;
|
|
216
|
+
role?: string;
|
|
193
217
|
};
|
|
194
218
|
/** The environment variable holding the forge token. */
|
|
195
219
|
token_env?: string;
|
|
@@ -215,8 +239,6 @@ export interface ProjectSettings {
|
|
|
215
239
|
* write one. The two must differ, on every cloud set.
|
|
216
240
|
*/
|
|
217
241
|
oidc?: OidcSettings;
|
|
218
|
-
/** Whether removing the project from a control repo removes its generated files. */
|
|
219
|
-
owned?: boolean;
|
|
220
242
|
/** How many roots of one dependency layer plan at once. Default: from the state backend. */
|
|
221
243
|
parallelism?: number;
|
|
222
244
|
/** Terragrunt settings, for a repo terragucci finds Terragrunt in. */
|
|
@@ -226,13 +248,12 @@ export interface ProjectSettings {
|
|
|
226
248
|
/** The response to each pipeline event; see RESPONSES. */
|
|
227
249
|
respond?: Partial<Record<RespondEvent, string>>;
|
|
228
250
|
/**
|
|
229
|
-
*
|
|
230
|
-
*
|
|
251
|
+
* The agent integration behind `agent.comment`. Its token can comment and
|
|
252
|
+
* push to a pull request's branch; its role, when named, is read-only.
|
|
231
253
|
*/
|
|
232
254
|
agent?: {
|
|
233
255
|
via: (typeof AGENT_VIA)[number];
|
|
234
256
|
token_env: string;
|
|
235
|
-
role?: string;
|
|
236
257
|
comment?: boolean | AgentCommentSettings;
|
|
237
258
|
};
|
|
238
259
|
/** The typed-decision service; see DecideSettings. Off when absent. A project's `decide` replaces the defaults' whole. */
|
|
@@ -255,7 +276,6 @@ export interface ResolvedSettings extends ProjectSettings {
|
|
|
255
276
|
drift: string | false;
|
|
256
277
|
runtime: Runtime;
|
|
257
278
|
tips: boolean;
|
|
258
|
-
owned: boolean;
|
|
259
279
|
env: Record<string, string>;
|
|
260
280
|
}
|
|
261
281
|
export declare const BUILT_IN: ResolvedSettings;
|
|
@@ -269,6 +289,14 @@ export declare function checkMode(mode: string): "dry-run" | "apply";
|
|
|
269
289
|
export declare const CONFIG_NAMES: string[];
|
|
270
290
|
/** The config file in `dir`, or undefined. Two of them is an error. */
|
|
271
291
|
export declare function findConfig(dir: string): string | undefined;
|
|
292
|
+
/**
|
|
293
|
+
* Why GitLab has no apply before merge. GitLab builds a merge request's
|
|
294
|
+
* pipeline from the merge request's own `.gitlab-ci.yml`, so a job that
|
|
295
|
+
* applies it would run the checks before the apply (approval, locks, the
|
|
296
|
+
* pipeline file) inside a pipeline the merge request controls, and the apply
|
|
297
|
+
* role would have to trust every branch of the project.
|
|
298
|
+
*/
|
|
299
|
+
export declare const NO_GITLAB_PR_APPLY = "pull-request is not supported on GitLab, where a merge request's pipeline is defined by the merge request itself, so nothing it runs can be trusted with the apply role; leave apply.when unset, and the change applies after it merges";
|
|
272
300
|
/** Check a parsed config and return it typed, or throw with every problem listed. */
|
|
273
301
|
export declare function validateConfig(raw: unknown, where: string): TerragucciConfig;
|
|
274
302
|
export type ConfigMode = "fold" | "run" | "check";
|
package/package.json
CHANGED