canic-cli 0.58.2

Operator CLI for Canic fleet setup, builds, evidence, catalog, backup, and restore workflows
Documentation
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
use super::super::value_arg;
use crate::cli::clap::passthrough_subcommand;
use clap::Command as ClapCommand;

#[derive(Clone, Copy)]
struct PromoteSubcommand {
    name: &'static str,
    about: &'static str,
}

#[derive(Clone, Copy)]
struct PromoteReportCommand {
    name: &'static str,
    about: &'static str,
    bin_name: &'static str,
    help_after: &'static str,
}

const TOP_COMMANDS: &[PromoteSubcommand] = &[
    PromoteSubcommand {
        name: "plan",
        about: "Build a passive artifact promotion plan",
    },
    PromoteSubcommand {
        name: "check",
        about: "Build a passive artifact promotion readiness check",
    },
    PromoteSubcommand {
        name: "diff",
        about: "Build a passive artifact promotion diff",
    },
    PromoteSubcommand {
        name: "inspect",
        about: "Inspect passive artifact promotion internals",
    },
];

const INSPECT_COMMANDS: &[PromoteSubcommand] = &[
    PromoteSubcommand {
        name: "readiness",
        about: "Build a passive promotion readiness report",
    },
    PromoteSubcommand {
        name: "artifact-identity",
        about: "Build a passive promotion artifact identity report",
    },
    PromoteSubcommand {
        name: "transform",
        about: "Build a passive promoted-plan transform",
    },
    PromoteSubcommand {
        name: "transform-evidence",
        about: "Build passive promoted-plan transform evidence",
    },
    PromoteSubcommand {
        name: "target-lineage",
        about: "Build passive target execution lineage",
    },
    PromoteSubcommand {
        name: "provenance",
        about: "Build a passive artifact promotion provenance report",
    },
    PromoteSubcommand {
        name: "wasm-store-identity",
        about: "Build a passive wasm-store identity report",
    },
    PromoteSubcommand {
        name: "catalog-verification",
        about: "Build a passive wasm-store catalog verification report",
    },
    PromoteSubcommand {
        name: "execution-receipt",
        about: "Build a passive artifact promotion execution receipt wrapper",
    },
    PromoteSubcommand {
        name: "policy",
        about: "Build a passive promotion policy check",
    },
    PromoteSubcommand {
        name: "materialization-identity",
        about: "Build a passive source/build materialization identity report",
    },
];

const DEPLOY_PROMOTE_HELP_AFTER: &str = "\
Examples:
  canic deploy promote plan --request promotion-plan.json
  canic deploy promote check --request promotion-check.json
  canic deploy promote diff --request promotion-diff.json
  canic deploy promote inspect readiness --request promotion-readiness.json
  canic deploy promote inspect artifact-identity --request promotion-artifacts.json
  canic deploy promote inspect provenance --request promotion-provenance.json
  canic deploy promote inspect readiness --request promotion-readiness.json --format text

0.44 promotion commands are passive report builders. They do not install,
stage artifacts, query wasm_store, or mutate deployment/controller state.";
const DEPLOY_PROMOTE_INSPECT_HELP_AFTER: &str = "\
Examples:
  canic deploy promote inspect readiness --request promotion-readiness.json
  canic deploy promote inspect artifact-identity --request promotion-artifacts.json
  canic deploy promote inspect transform --request promotion-transform.json
  canic deploy promote inspect transform-evidence --request transform-evidence.json
  canic deploy promote inspect target-lineage --request target-lineage.json
  canic deploy promote inspect provenance --request promotion-provenance.json
  canic deploy promote inspect wasm-store-identity --request wasm-store-identity.json
  canic deploy promote inspect catalog-verification --request catalog-verification.json
  canic deploy promote inspect materialization-identity --request materialization.json
  canic deploy promote inspect policy --request promotion-policy.json
  canic deploy promote inspect execution-receipt --request promotion-execution-receipt.json

Advanced promotion inspection commands expose archived/passive artifact DTOs.
They do not install, stage artifacts, query wasm_store, or mutate deployment or
controller state.";
const DEPLOY_PROMOTE_READINESS_HELP_AFTER: &str = "\
Examples:
  canic deploy promote inspect readiness --request promotion-readiness.json
  canic deploy promote inspect readiness --request promotion-readiness.json --format text

Reads a PromotionReadinessRequest-shaped JSON file and prints
PromotionReadinessV1 JSON by default, or passive text with --format text.";
const DEPLOY_PROMOTE_CHECK_HELP_AFTER: &str = "\
Examples:
  canic deploy promote check --request promotion-check.json
  canic deploy promote check --request promotion-check.json --format text

Reads a PromotionReadinessRequest-shaped JSON file and prints a passive
PromotionReadinessV1 check report by default, or passive text with
--format text.";
const DEPLOY_PROMOTE_ARTIFACT_IDENTITY_HELP_AFTER: &str = "\
Examples:
  canic deploy promote inspect artifact-identity --request promotion-artifacts.json
  canic deploy promote inspect artifact-identity --request promotion-artifacts.json --format text

Reads a PromotionArtifactIdentityReportRequest-shaped JSON file and prints
PromotionArtifactIdentityReportV1 JSON by default, or passive text with
--format text.";
const DEPLOY_PROMOTE_TRANSFORM_HELP_AFTER: &str = "\
Examples:
  canic deploy promote inspect transform --request promotion-transform.json
  canic deploy promote inspect transform --request promotion-transform.json --format text

Reads a PromotionPlanTransformRequest-shaped JSON file and prints
PromotionPlanTransformV1 JSON by default, or passive text with --format text.";
const DEPLOY_PROMOTE_DIFF_HELP_AFTER: &str = "\
Examples:
  canic deploy promote diff --request promotion-diff.json
  canic deploy promote diff --request promotion-diff.json --format text

Reads a PromotionPlanTransformRequest-shaped JSON file and prints a passive
PromotionPlanTransformV1 diff report by default, or passive text with
--format text.";
const DEPLOY_PROMOTE_TRANSFORM_EVIDENCE_HELP_AFTER: &str = "\
Examples:
  canic deploy promote inspect transform-evidence --request transform-evidence.json
  canic deploy promote inspect transform-evidence --request transform-evidence.json --format text

Reads a PromotionPlanTransformEvidenceRequest-shaped JSON file and prints
PromotionPlanTransformEvidenceV1 JSON by default, or passive text with
--format text.";
const DEPLOY_PROMOTE_TARGET_LINEAGE_HELP_AFTER: &str = "\
Examples:
  canic deploy promote inspect target-lineage --request target-lineage.json
  canic deploy promote inspect target-lineage --request target-lineage.json --format text

Reads a PromotionTargetExecutionLineageRequest-shaped JSON file and prints
PromotionTargetExecutionLineageV1 JSON by default, or passive text with
--format text.";
const DEPLOY_PROMOTE_PLAN_HELP_AFTER: &str = "\
Examples:
  canic deploy promote plan --request promotion-plan.json
  canic deploy promote plan --request promotion-plan.json --format text

Reads an ArtifactPromotionPlanRequest-shaped JSON file and prints
ArtifactPromotionPlanV1 JSON by default, or passive text with --format text.";
const DEPLOY_PROMOTE_PROVENANCE_HELP_AFTER: &str = "\
Examples:
  canic deploy promote inspect provenance --request promotion-provenance.json
  canic deploy promote inspect provenance --request promotion-provenance.json --format text

Reads an ArtifactPromotionProvenanceReportRequest-shaped JSON file and prints
ArtifactPromotionProvenanceReportV1 JSON by default, or passive text with
--format text.";
const DEPLOY_PROMOTE_WASM_STORE_IDENTITY_HELP_AFTER: &str = "\
Examples:
  canic deploy promote inspect wasm-store-identity --request wasm-store-identity.json
  canic deploy promote inspect wasm-store-identity --request wasm-store-identity.json --format text

Reads a PromotionWasmStoreIdentityReportRequest-shaped JSON file and prints
PromotionWasmStoreIdentityReportV1 JSON by default, or passive text with
--format text.";
const DEPLOY_PROMOTE_CATALOG_VERIFICATION_HELP_AFTER: &str = "\
Examples:
  canic deploy promote inspect catalog-verification --request catalog-verification.json
  canic deploy promote inspect catalog-verification --request catalog-verification.json --format text

Reads a PromotionWasmStoreCatalogVerificationRequest-shaped JSON file and
prints PromotionWasmStoreCatalogVerificationV1 JSON by default, or passive
text with --format text.";
const DEPLOY_PROMOTE_EXECUTION_RECEIPT_HELP_AFTER: &str = "\
Examples:
  canic deploy promote inspect execution-receipt --request promotion-execution-receipt.json
  canic deploy promote inspect execution-receipt --request promotion-execution-receipt.json --format text

Reads an ArtifactPromotionExecutionReceiptRequest-shaped JSON file and prints
ArtifactPromotionExecutionReceiptV1 JSON by default, or passive text with
--format text.";
const DEPLOY_PROMOTE_POLICY_CHECK_HELP_AFTER: &str = "\
Examples:
  canic deploy promote inspect policy --request promotion-policy.json
  canic deploy promote inspect policy --request promotion-policy.json --format text

Reads a PromotionPolicyCheckRequest-shaped JSON file and prints
PromotionPolicyCheckV1 JSON by default, or passive text with --format text.";
const DEPLOY_PROMOTE_MATERIALIZATION_IDENTITY_HELP_AFTER: &str = "\
Examples:
  canic deploy promote inspect materialization-identity --request materialization.json
  canic deploy promote inspect materialization-identity --request materialization.json --format text

Reads a PromotionMaterializationIdentityReportRequest-shaped JSON file and
prints PromotionMaterializationIdentityReportV1 JSON by default, or passive
text with --format text.";

const READINESS_REPORT_COMMAND: PromoteReportCommand = PromoteReportCommand {
    name: "readiness",
    about: "Build a passive promotion readiness report",
    bin_name: "canic deploy promote inspect readiness",
    help_after: DEPLOY_PROMOTE_READINESS_HELP_AFTER,
};
const CHECK_REPORT_COMMAND: PromoteReportCommand = PromoteReportCommand {
    name: "check",
    about: "Build a passive artifact promotion readiness check",
    bin_name: "canic deploy promote check",
    help_after: DEPLOY_PROMOTE_CHECK_HELP_AFTER,
};
const ARTIFACT_IDENTITY_REPORT_COMMAND: PromoteReportCommand = PromoteReportCommand {
    name: "artifact-identity",
    about: "Build a passive promotion artifact identity report",
    bin_name: "canic deploy promote inspect artifact-identity",
    help_after: DEPLOY_PROMOTE_ARTIFACT_IDENTITY_HELP_AFTER,
};
const TRANSFORM_REPORT_COMMAND: PromoteReportCommand = PromoteReportCommand {
    name: "transform",
    about: "Build a passive promoted-plan transform",
    bin_name: "canic deploy promote inspect transform",
    help_after: DEPLOY_PROMOTE_TRANSFORM_HELP_AFTER,
};
const DIFF_REPORT_COMMAND: PromoteReportCommand = PromoteReportCommand {
    name: "diff",
    about: "Build a passive artifact promotion diff",
    bin_name: "canic deploy promote diff",
    help_after: DEPLOY_PROMOTE_DIFF_HELP_AFTER,
};
const TRANSFORM_EVIDENCE_REPORT_COMMAND: PromoteReportCommand = PromoteReportCommand {
    name: "transform-evidence",
    about: "Build passive promoted-plan transform evidence",
    bin_name: "canic deploy promote inspect transform-evidence",
    help_after: DEPLOY_PROMOTE_TRANSFORM_EVIDENCE_HELP_AFTER,
};
const TARGET_LINEAGE_REPORT_COMMAND: PromoteReportCommand = PromoteReportCommand {
    name: "target-lineage",
    about: "Build passive target execution lineage",
    bin_name: "canic deploy promote inspect target-lineage",
    help_after: DEPLOY_PROMOTE_TARGET_LINEAGE_HELP_AFTER,
};
const PLAN_REPORT_COMMAND: PromoteReportCommand = PromoteReportCommand {
    name: "plan",
    about: "Build a passive artifact promotion plan",
    bin_name: "canic deploy promote plan",
    help_after: DEPLOY_PROMOTE_PLAN_HELP_AFTER,
};
const PROVENANCE_REPORT_COMMAND: PromoteReportCommand = PromoteReportCommand {
    name: "provenance",
    about: "Build a passive artifact promotion provenance report",
    bin_name: "canic deploy promote inspect provenance",
    help_after: DEPLOY_PROMOTE_PROVENANCE_HELP_AFTER,
};
const WASM_STORE_IDENTITY_REPORT_COMMAND: PromoteReportCommand = PromoteReportCommand {
    name: "wasm-store-identity",
    about: "Build a passive wasm-store identity report",
    bin_name: "canic deploy promote inspect wasm-store-identity",
    help_after: DEPLOY_PROMOTE_WASM_STORE_IDENTITY_HELP_AFTER,
};
const CATALOG_VERIFICATION_REPORT_COMMAND: PromoteReportCommand = PromoteReportCommand {
    name: "catalog-verification",
    about: "Build a passive wasm-store catalog verification report",
    bin_name: "canic deploy promote inspect catalog-verification",
    help_after: DEPLOY_PROMOTE_CATALOG_VERIFICATION_HELP_AFTER,
};
const EXECUTION_RECEIPT_REPORT_COMMAND: PromoteReportCommand = PromoteReportCommand {
    name: "execution-receipt",
    about: "Build a passive artifact promotion execution receipt wrapper",
    bin_name: "canic deploy promote inspect execution-receipt",
    help_after: DEPLOY_PROMOTE_EXECUTION_RECEIPT_HELP_AFTER,
};
const POLICY_CHECK_REPORT_COMMAND: PromoteReportCommand = PromoteReportCommand {
    name: "policy",
    about: "Build a passive promotion policy check",
    bin_name: "canic deploy promote inspect policy",
    help_after: DEPLOY_PROMOTE_POLICY_CHECK_HELP_AFTER,
};
const MATERIALIZATION_IDENTITY_REPORT_COMMAND: PromoteReportCommand = PromoteReportCommand {
    name: "materialization-identity",
    about: "Build a passive source/build materialization identity report",
    bin_name: "canic deploy promote inspect materialization-identity",
    help_after: DEPLOY_PROMOTE_MATERIALIZATION_IDENTITY_HELP_AFTER,
};

pub fn deploy_promote_command() -> ClapCommand {
    TOP_COMMANDS
        .iter()
        .fold(
            ClapCommand::new("promote")
                .bin_name("canic deploy promote")
                .about("Build passive artifact promotion reports")
                .disable_help_flag(true),
            |command, subcommand| command.subcommand(promote_passthrough_command(*subcommand)),
        )
        .after_help(DEPLOY_PROMOTE_HELP_AFTER)
}

pub fn deploy_promote_inspect_command() -> ClapCommand {
    INSPECT_COMMANDS
        .iter()
        .fold(
            ClapCommand::new("inspect")
                .bin_name("canic deploy promote inspect")
                .about("Inspect passive artifact promotion internals")
                .disable_help_flag(true),
            |command, subcommand| command.subcommand(promote_passthrough_command(*subcommand)),
        )
        .after_help(DEPLOY_PROMOTE_INSPECT_HELP_AFTER)
}

pub fn deploy_promote_readiness_command() -> ClapCommand {
    deploy_promote_report_command(READINESS_REPORT_COMMAND)
}

pub fn deploy_promote_check_command() -> ClapCommand {
    deploy_promote_report_command(CHECK_REPORT_COMMAND)
}

pub fn deploy_promote_artifact_identity_command() -> ClapCommand {
    deploy_promote_report_command(ARTIFACT_IDENTITY_REPORT_COMMAND)
}

pub fn deploy_promote_transform_command() -> ClapCommand {
    deploy_promote_report_command(TRANSFORM_REPORT_COMMAND)
}

pub fn deploy_promote_diff_command() -> ClapCommand {
    deploy_promote_report_command(DIFF_REPORT_COMMAND)
}

pub fn deploy_promote_transform_evidence_command() -> ClapCommand {
    deploy_promote_report_command(TRANSFORM_EVIDENCE_REPORT_COMMAND)
}

pub fn deploy_promote_target_lineage_command() -> ClapCommand {
    deploy_promote_report_command(TARGET_LINEAGE_REPORT_COMMAND)
}

pub fn deploy_promote_plan_command() -> ClapCommand {
    deploy_promote_report_command(PLAN_REPORT_COMMAND)
}

pub fn deploy_promote_provenance_command() -> ClapCommand {
    deploy_promote_report_command(PROVENANCE_REPORT_COMMAND)
}

pub fn deploy_promote_wasm_store_identity_command() -> ClapCommand {
    deploy_promote_report_command(WASM_STORE_IDENTITY_REPORT_COMMAND)
}

pub fn deploy_promote_catalog_verification_command() -> ClapCommand {
    deploy_promote_report_command(CATALOG_VERIFICATION_REPORT_COMMAND)
}

pub fn deploy_promote_execution_receipt_command() -> ClapCommand {
    deploy_promote_report_command(EXECUTION_RECEIPT_REPORT_COMMAND)
}

pub fn deploy_promote_policy_check_command() -> ClapCommand {
    deploy_promote_report_command(POLICY_CHECK_REPORT_COMMAND)
}

pub fn deploy_promote_materialization_identity_command() -> ClapCommand {
    deploy_promote_report_command(MATERIALIZATION_IDENTITY_REPORT_COMMAND)
}

fn promote_passthrough_command(spec: PromoteSubcommand) -> ClapCommand {
    passthrough_subcommand(
        ClapCommand::new(spec.name)
            .about(spec.about)
            .disable_help_flag(true),
    )
}

fn deploy_promote_report_command(spec: PromoteReportCommand) -> ClapCommand {
    ClapCommand::new(spec.name)
        .bin_name(spec.bin_name)
        .about(spec.about)
        .disable_help_flag(true)
        .arg(
            value_arg("request")
                .long("request")
                .value_name("file")
                .required(true)
                .help("Request JSON file for the passive promotion report"),
        )
        .arg(promotion_format_arg())
        .after_help(spec.help_after)
}

fn promotion_format_arg() -> clap::Arg {
    value_arg("format")
        .long("format")
        .value_name("json|text")
        .num_args(1)
        .help("Output format; defaults to json")
}

pub fn promote_usage() -> String {
    render_usage(deploy_promote_command)
}

pub fn promote_inspect_usage() -> String {
    render_usage(deploy_promote_inspect_command)
}

pub fn promote_readiness_usage() -> String {
    render_usage(deploy_promote_readiness_command)
}

pub fn promote_check_usage() -> String {
    render_usage(deploy_promote_check_command)
}

pub fn promote_artifact_identity_usage() -> String {
    render_usage(deploy_promote_artifact_identity_command)
}

pub fn promote_transform_usage() -> String {
    render_usage(deploy_promote_transform_command)
}

pub fn promote_diff_usage() -> String {
    render_usage(deploy_promote_diff_command)
}

pub fn promote_transform_evidence_usage() -> String {
    render_usage(deploy_promote_transform_evidence_command)
}

pub fn promote_target_lineage_usage() -> String {
    render_usage(deploy_promote_target_lineage_command)
}

pub fn promote_plan_usage() -> String {
    render_usage(deploy_promote_plan_command)
}

pub fn promote_provenance_usage() -> String {
    render_usage(deploy_promote_provenance_command)
}

pub fn promote_wasm_store_identity_usage() -> String {
    render_usage(deploy_promote_wasm_store_identity_command)
}

pub fn promote_catalog_verification_usage() -> String {
    render_usage(deploy_promote_catalog_verification_command)
}

pub fn promote_execution_receipt_usage() -> String {
    render_usage(deploy_promote_execution_receipt_command)
}

pub fn promote_policy_check_usage() -> String {
    render_usage(deploy_promote_policy_check_command)
}

pub fn promote_materialization_identity_usage() -> String {
    render_usage(deploy_promote_materialization_identity_command)
}

fn render_usage(command: fn() -> ClapCommand) -> String {
    let mut command = command();
    command.render_help().to_string()
}