Skip to content

Commit 8a4b571

Browse files
authored
feat(edge_services): add doc and cli for head stage (#5264)
1 parent a9d52a1 commit 8a4b571

File tree

7 files changed

+178
-3
lines changed

7 files changed

+178
-3
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
List Head stage for your pipeline.
4+
5+
USAGE:
6+
scw edge-services pipeline list-head <pipeline-id ...> [arg=value ...]
7+
8+
ARGS:
9+
pipeline-id ID of the pipeline to update
10+
11+
FLAGS:
12+
-h, --help help for list-head
13+
14+
GLOBAL FLAGS:
15+
-c, --config string The path to the config file
16+
-D, --debug Enable debug mode
17+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
18+
-p, --profile string The config profile to use
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
You must specify either a `add_new_head_stage` (to add a new head stage), `remove_head_stage` (to remove a head stage) or `swap_head_stage` (to replace a head stage).
4+
5+
USAGE:
6+
scw edge-services pipeline set-head <pipeline-id ...> [arg=value ...]
7+
8+
ARGS:
9+
pipeline-id ID of the pipeline to update
10+
[add-new-head-stage.new-stage-id]
11+
[remove-head-stage.remove-stage-id]
12+
[swap-head-stage.new-stage-id]
13+
[swap-head-stage.current-stage-id]
14+
15+
FLAGS:
16+
-h, --help help for set-head
17+
18+
GLOBAL FLAGS:
19+
-c, --config string The path to the config file
20+
-D, --debug Enable debug mode
21+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
22+
-p, --profile string The config profile to use

cmd/scw/testdata/test-all-usage-edge-services-pipeline-usage.golden

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ AVAILABLE COMMANDS:
1010
delete Delete pipeline
1111
get Get pipeline
1212
list List pipelines
13+
list-head List Head stage for your pipeline.
14+
set-head Configure a entry point to your pipeline. You must specify a `head stage` to form a stage-chain that goes all the way to the backend stage (origin), so the HTTP request will be processed according to the stages you created.
1315
update Update pipeline
1416

1517
FLAGS:

docs/commands/edge-services.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ Edge Services API
2525
- [Delete pipeline](#delete-pipeline)
2626
- [Get pipeline](#get-pipeline)
2727
- [List pipelines](#list-pipelines)
28+
- [List Head stage for your pipeline.](#list-head-stage-for-your-pipeline.)
29+
- [Configure a entry point to your pipeline. You must specify a `head stage` to form a stage-chain that goes all the way to the backend stage (origin), so the HTTP request will be processed according to the stages you created.](#configure-a-entry-point-to-your-pipeline.-you-must-specify-a-`head-stage`-to-form-a-stage-chain-that-goes-all-the-way-to-the-backend-stage-(origin),-so-the-http-request-will-be-processed-according-to-the-stages-you-created.)
2830
- [Update pipeline](#update-pipeline)
2931
- [Purge-request management commands](#purge-request-management-commands)
3032
- [Create purge request](#create-purge-request)
@@ -493,6 +495,48 @@ scw edge-services pipeline list [arg=value ...]
493495

494496

495497

498+
### List Head stage for your pipeline.
499+
500+
List Head stage for your pipeline.
501+
502+
**Usage:**
503+
504+
```
505+
scw edge-services pipeline list-head <pipeline-id ...> [arg=value ...]
506+
```
507+
508+
509+
**Args:**
510+
511+
| Name | | Description |
512+
|------|---|-------------|
513+
| pipeline-id | Required | ID of the pipeline to update |
514+
515+
516+
517+
### Configure a entry point to your pipeline. You must specify a `head stage` to form a stage-chain that goes all the way to the backend stage (origin), so the HTTP request will be processed according to the stages you created.
518+
519+
You must specify either a `add_new_head_stage` (to add a new head stage), `remove_head_stage` (to remove a head stage) or `swap_head_stage` (to replace a head stage).
520+
521+
**Usage:**
522+
523+
```
524+
scw edge-services pipeline set-head <pipeline-id ...> [arg=value ...]
525+
```
526+
527+
528+
**Args:**
529+
530+
| Name | | Description |
531+
|------|---|-------------|
532+
| pipeline-id | Required | ID of the pipeline to update |
533+
| add-new-head-stage.new-stage-id | | |
534+
| remove-head-stage.remove-stage-id | | |
535+
| swap-head-stage.new-stage-id | | |
536+
| swap-head-stage.current-stage-id | | |
537+
538+
539+
496540
### Update pipeline
497541

498542
Update the parameters of an existing pipeline, specified by its `pipeline_id`. Parameters which can be updated include the `name`, `description` and `dns_stage_id`.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ require (
2323
github.com/mattn/go-isatty v0.0.20
2424
github.com/moby/buildkit v0.26.3
2525
github.com/opencontainers/go-digest v1.0.0
26-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.36.0.20260107085608-8e8f76c5afac
26+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.36.0.20260107155641-2ffb96c688ff
2727
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
2828
github.com/spf13/cobra v1.10.2
2929
github.com/spf13/pflag v1.0.10

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,8 @@ github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7
468468
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
469469
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
470470
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
471-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.36.0.20260107085608-8e8f76c5afac h1:6k+C/FKpLBvJgjFZXqxQsOaUAwnFM9VDUIaQgtHxL84=
472-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.36.0.20260107085608-8e8f76c5afac/go.mod h1:LEsDu4BubxK7/cWhtlQWfuxwL4rf/2UEpxXz1o1EMtM=
471+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.36.0.20260107155641-2ffb96c688ff h1:URB4cZn80sXINbi3UR47Z6j5+I3g8koA5lXp85kIUk8=
472+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.36.0.20260107155641-2ffb96c688ff/go.mod h1:LEsDu4BubxK7/cWhtlQWfuxwL4rf/2UEpxXz1o1EMtM=
473473
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
474474
github.com/sclevine/spec v1.4.0/go.mod h1:LvpgJaFyvQzRvc1kaDs0bulYwzC70PbiYjC4QnFHkOM=
475475
github.com/secure-systems-lab/go-securesystemslib v0.9.1 h1:nZZaNz4DiERIQguNy0cL5qTdn9lR8XKHf4RUyG1Sx3g=

internal/namespaces/edge_services/v1beta1/edge_services_cli.go

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ func GetGeneratedCommands() *core.Commands {
3434
edgeServicesPipelineGet(),
3535
edgeServicesPipelineUpdate(),
3636
edgeServicesPipelineDelete(),
37+
edgeServicesPipelineListHead(),
38+
edgeServicesPipelineSetHead(),
3739
edgeServicesDNSStageList(),
3840
edgeServicesDNSStageCreate(),
3941
edgeServicesDNSStageGet(),
@@ -375,6 +377,93 @@ func edgeServicesPipelineDelete() *core.Command {
375377
}
376378
}
377379

380+
func edgeServicesPipelineListHead() *core.Command {
381+
return &core.Command{
382+
Short: `List Head stage for your pipeline.`,
383+
Long: `List Head stage for your pipeline.`,
384+
Namespace: "edge-services",
385+
Resource: "pipeline",
386+
Verb: "list-head",
387+
// Deprecated: false,
388+
ArgsType: reflect.TypeOf(edge_services.ListHeadStagesRequest{}),
389+
ArgSpecs: core.ArgSpecs{
390+
{
391+
Name: "pipeline-id",
392+
Short: `ID of the pipeline to update`,
393+
Required: true,
394+
Deprecated: false,
395+
Positional: true,
396+
},
397+
},
398+
Run: func(ctx context.Context, args any) (i any, e error) {
399+
request := args.(*edge_services.ListHeadStagesRequest)
400+
401+
client := core.ExtractClient(ctx)
402+
api := edge_services.NewAPI(client)
403+
opts := []scw.RequestOption{scw.WithAllPages()}
404+
resp, err := api.ListHeadStages(request, opts...)
405+
if err != nil {
406+
return nil, err
407+
}
408+
409+
return resp.HeadStages, nil
410+
},
411+
}
412+
}
413+
414+
func edgeServicesPipelineSetHead() *core.Command {
415+
return &core.Command{
416+
Short: `Configure a entry point to your pipeline. You must specify a ` + "`" + `head stage` + "`" + ` to form a stage-chain that goes all the way to the backend stage (origin), so the HTTP request will be processed according to the stages you created.`,
417+
Long: `You must specify either a ` + "`" + `add_new_head_stage` + "`" + ` (to add a new head stage), ` + "`" + `remove_head_stage` + "`" + ` (to remove a head stage) or ` + "`" + `swap_head_stage` + "`" + ` (to replace a head stage).`,
418+
Namespace: "edge-services",
419+
Resource: "pipeline",
420+
Verb: "set-head",
421+
// Deprecated: false,
422+
ArgsType: reflect.TypeOf(edge_services.SetHeadStageRequest{}),
423+
ArgSpecs: core.ArgSpecs{
424+
{
425+
Name: "pipeline-id",
426+
Short: `ID of the pipeline to update`,
427+
Required: true,
428+
Deprecated: false,
429+
Positional: true,
430+
},
431+
{
432+
Name: "add-new-head-stage.new-stage-id",
433+
Required: false,
434+
Deprecated: false,
435+
Positional: false,
436+
},
437+
{
438+
Name: "remove-head-stage.remove-stage-id",
439+
Required: false,
440+
Deprecated: false,
441+
Positional: false,
442+
},
443+
{
444+
Name: "swap-head-stage.new-stage-id",
445+
Required: false,
446+
Deprecated: false,
447+
Positional: false,
448+
},
449+
{
450+
Name: "swap-head-stage.current-stage-id",
451+
Required: false,
452+
Deprecated: false,
453+
Positional: false,
454+
},
455+
},
456+
Run: func(ctx context.Context, args any) (i any, e error) {
457+
request := args.(*edge_services.SetHeadStageRequest)
458+
459+
client := core.ExtractClient(ctx)
460+
api := edge_services.NewAPI(client)
461+
462+
return api.SetHeadStage(request)
463+
},
464+
}
465+
}
466+
378467
func edgeServicesDNSStageList() *core.Command {
379468
return &core.Command{
380469
Short: `List DNS stages`,

0 commit comments

Comments
 (0)