Skip to content

Commit 85808d7

Browse files
committed
feat(cmd): Add missing examples and slightly reword
Signed-off-by: Cezar Craciunoiu <[email protected]>
1 parent 4df96a4 commit 85808d7

15 files changed

Lines changed: 505 additions & 88 deletions

internal/cmd/build.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (BuildCmd) Examples() []kingkong.Example {
3838
},
3939
},
4040
{
41-
Description: "Build and publish an image from a Kraftfile",
41+
Description: "Build and publish an image to a registry",
4242
Commands: []string{
4343
"unikraft build . --output my-org/my-app:latest",
4444
},
@@ -49,6 +49,12 @@ func (BuildCmd) Examples() []kingkong.Example {
4949
"unikraft build ./app --build-arg VERSION=1.2.3 --build-arg COMMIT=abc123",
5050
},
5151
},
52+
{
53+
Description: "Build without using cache",
54+
Commands: []string{
55+
"unikraft build . --no-cache",
56+
},
57+
},
5258
{
5359
Description: "Build with secret and SSH access",
5460
Commands: []string{

internal/cmd/certificates.go

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -278,30 +278,36 @@ func (Certificate) Examples() map[cmd.CmdType][]kingkong.Example {
278278
return map[cmd.CmdType][]kingkong.Example{
279279
cmd.CmdTypeGet: {
280280
{
281-
Description: "Get a certificate by name or UUID",
281+
Description: "Inspect a certificate by name or UUID",
282282
Commands: []string{"unikraft certificate get demo-cert"},
283283
},
284+
{
285+
Description: "Inspect a certificate in a specific metro",
286+
Commands: []string{"unikraft certificate get fra/demo-cert"},
287+
},
288+
{
289+
Description: "Show certificate details in JSON format",
290+
Commands: []string{"unikraft certificate get demo-cert -o json"},
291+
},
284292
},
285293
cmd.CmdTypeList: {
286294
{
287-
Description: "List all certificates",
295+
Description: "List all certificates across metros",
288296
Commands: []string{"unikraft certificate list"},
289297
},
298+
{
299+
Description: "List certificates and watch for changes",
300+
Commands: []string{"unikraft certificate list -w"},
301+
},
290302
},
291303
cmd.CmdTypeCreate: {
292304
{
293-
Description: "Create a new certificate",
305+
Description: "Create a self-signed certificate and upload it",
294306
Commands: []string{
295307
`openssl req -x509 -newkey rsa:2048 -sha256 -days 365 -nodes \
296308
-subj "/CN=demo.unikraft.dev" \
297309
-keyout cert.key \
298310
-out cert.pem`,
299-
// `unikraft certificate create \
300-
// --set name=demo-cert \
301-
// --set cn=demo.unikraft.dev. \
302-
// --set-file chain=cert.pem \
303-
// --set-file pkey=cert.key \
304-
// --set metro=fra`,
305311
`unikraft certificate create \
306312
--name demo-cert \
307313
--cn demo.unikraft.dev. \
@@ -310,12 +316,27 @@ func (Certificate) Examples() map[cmd.CmdType][]kingkong.Example {
310316
--metro fra`,
311317
},
312318
},
319+
{
320+
Description: "Preview certificate creation without applying",
321+
Commands: []string{
322+
`unikraft certificate create \
323+
--cn example.com. \
324+
--chain cert.pem \
325+
--pkey cert.key \
326+
--metro sfo \
327+
--dry-run`,
328+
},
329+
},
313330
},
314331
cmd.CmdTypeDelete: {
315332
{
316-
Description: "Delete a certificate by name or UUID",
333+
Description: "Delete a certificate by name",
317334
Commands: []string{"unikraft certificate delete demo-cert"},
318335
},
336+
{
337+
Description: "Delete all certificates (with confirmation prompt)",
338+
Commands: []string{"unikraft certificate delete --all"},
339+
},
319340
},
320341
}
321342
}

internal/cmd/config.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ func (Config) Examples() map[cmd.CmdType][]kingkong.Example {
8383
Description: "Show the current configuration",
8484
Commands: []string{"unikraft config get"},
8585
},
86+
{
87+
Description: "Show config from a specific file",
88+
Commands: []string{"unikraft config get /path/to/config.yaml"},
89+
},
90+
{
91+
Description: "Show a specific field in JSON format",
92+
Commands: []string{"unikraft config get -f profiles -o json"},
93+
},
8694
},
8795
}
8896
}

internal/cmd/images.go

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,14 @@ func (Image) Examples() map[cmd.CmdType][]kingkong.Example {
224224
Description: "Inspect an image by tag",
225225
Commands: []string{"unikraft image get nginx:latest"},
226226
},
227+
{
228+
Description: "Show image details in JSON format",
229+
Commands: []string{"unikraft image get nginx:latest -o json"},
230+
},
231+
{
232+
Description: "Show all image fields including kernel and initrd info",
233+
Commands: []string{"unikraft image get my-app:v1.0 -f +kernel,+initrd"},
234+
},
227235
},
228236
cmd.CmdTypeList: {
229237
{
@@ -234,6 +242,10 @@ func (Image) Examples() map[cmd.CmdType][]kingkong.Example {
234242
Description: "Filter images by reference",
235243
Commands: []string{`unikraft image list --filter 'ref~="/nginx"'`},
236244
},
245+
{
246+
Description: "List images in table format",
247+
Commands: []string{"unikraft image list -o table"},
248+
},
237249
},
238250
cmd.CmdTypeDelete: {
239251
{
@@ -648,23 +660,29 @@ type ImagesCopyCmd struct {
648660
func (cmd ImagesCopyCmd) Examples() []kingkong.Example {
649661
return []kingkong.Example{
650662
{
651-
Description: "Create a copy of an image",
663+
Description: "Copy an official image to your namespace",
652664
Commands: []string{
653-
"unikraft image copy unikraft.io/official/nginx:latest unikraft.io/my-user/my-nginx",
665+
"unikraft image copy unikraft.io/official/nginx:latest unikraft.io/my-user/my-nginx:latest",
654666
},
655667
},
656668
{
657-
Description: "Upload a local image to a remote registry",
669+
Description: "Upload a local OCI archive to a remote registry",
658670
Commands: []string{
659671
"unikraft image copy ./my-local-image.tar unikraft.io/my-user/my-image:1.0.0",
660672
},
661673
},
662674
{
663-
Description: "Download an image from a remote registry",
675+
Description: "Download an image to a local archive",
664676
Commands: []string{
665677
"unikraft image copy unikraft.io/official/redis:latest ./my-redis-image.tar",
666678
},
667679
},
680+
{
681+
Description: "Tag an image with a new version",
682+
Commands: []string{
683+
"unikraft image copy unikraft.io/my-user/my-app:latest unikraft.io/my-user/my-app:v2.0",
684+
},
685+
},
668686
}
669687
}
670688

internal/cmd/instance_templates.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,27 +412,45 @@ func (InstanceTemplate) Examples() map[cmd.CmdType][]kingkong.Example {
412412
return map[cmd.CmdType][]kingkong.Example{
413413
cmd.CmdTypeGet: {
414414
{
415-
Description: "Inspect an instance template by name or UUID",
415+
Description: "Inspect an instance template by name",
416416
Commands: []string{"unikraft instance template get demo-template"},
417417
},
418+
{
419+
Description: "Show template details in JSON format",
420+
Commands: []string{"unikraft instance template get demo-template -o json"},
421+
},
418422
},
419423
cmd.CmdTypeList: {
420424
{
421425
Description: "List instance templates across metros",
422426
Commands: []string{"unikraft instance template list"},
423427
},
428+
{
429+
Description: "List templates in table format",
430+
Commands: []string{"unikraft instance template list -o table"},
431+
},
424432
},
425433
cmd.CmdTypeCreate: {
426434
{
427435
Description: "Convert a stopped instance into a template",
428436
Commands: []string{"unikraft instance template create demo-instance"},
429437
},
438+
{
439+
Description: "Convert multiple instances into templates",
440+
Commands: []string{"unikraft instance template create instance-1 instance-2"},
441+
},
430442
},
431443
cmd.CmdTypeEdit: {
432444
{
433445
Description: "Update template tags",
434446
Commands: []string{
435-
"unikraft instance template edit demo-template --set tags=env-dev",
447+
"unikraft instance template edit demo-template --tags env-prod,team-platform",
448+
},
449+
},
450+
{
451+
Description: "Lock a template to prevent deletion",
452+
Commands: []string{
453+
"unikraft instance template edit demo-template --delete-lock",
436454
},
437455
},
438456
},
@@ -441,6 +459,10 @@ func (InstanceTemplate) Examples() map[cmd.CmdType][]kingkong.Example {
441459
Description: "Delete an instance template",
442460
Commands: []string{"unikraft instance template delete demo-template"},
443461
},
462+
{
463+
Description: "Delete all instance templates (with confirmation)",
464+
Commands: []string{"unikraft instance template delete --all"},
465+
},
444466
},
445467
}
446468
}

0 commit comments

Comments
 (0)