Skip to content

Commit a5bea53

Browse files
authored
feat(wasm): add defaultProjectID to run config (#3207)
1 parent ff8cc42 commit a5bea53

File tree

5 files changed

+16
-6
lines changed

5 files changed

+16
-6
lines changed

internal/platform/web/web.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,26 @@ import (
77
)
88

99
type Platform struct {
10-
UserAgent string
11-
JWT string
10+
UserAgent string
11+
JWT string
12+
DefaultProjectID string
1213
}
1314

1415
func (p *Platform) CreateClient(client *http.Client, _ string, _ string) (*scw.Client, error) {
1516
opts := []scw.ClientOption{
1617
scw.WithDefaultRegion(scw.RegionFrPar),
1718
scw.WithDefaultZone(scw.ZoneFrPar1),
18-
scw.WithDefaultZone(scw.ZoneFrPar1),
1919
scw.WithUserAgent(p.UserAgent),
2020
scw.WithUserAgent("cli/web"),
2121
scw.WithProfile(scw.LoadEnvProfile()),
2222
scw.WithHTTPClient(client),
2323
scw.WithJWT(p.JWT),
2424
}
2525

26+
if p.DefaultProjectID != "" {
27+
opts = append(opts, scw.WithDefaultProjectID(p.DefaultProjectID))
28+
}
29+
2630
return scw.NewClient(opts...)
2731
}
2832

internal/wasm/run.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ func getCommands() *core.Commands {
1919
}
2020

2121
type RunConfig struct {
22-
JWT string `js:"jwt"`
22+
JWT string `js:"jwt"`
23+
DefaultProjectID string `js:"defaultProjectID"`
2324
}
2425

2526
type RunResponse struct {
@@ -37,7 +38,8 @@ func runCommand(cfg *RunConfig, args []string, stdout io.Writer, stderr io.Write
3738
Stderr: stderr,
3839
Stdin: nil,
3940
Platform: &web.Platform{
40-
JWT: cfg.JWT,
41+
JWT: cfg.JWT,
42+
DefaultProjectID: cfg.DefaultProjectID,
4143
},
4244
})
4345

wasm/cli.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export type RunConfig = {
22
jwt: string
3+
defaultProjectID: string
34
}
45

56
export type RunResponse = {

wasm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@scaleway/scaleway-cli-wasm",
3-
"version": "0.0.6",
3+
"version": "0.0.7",
44
"description": "",
55
"type": "module",
66
"main": "index.js",

wasm/src/cli.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ describe('With wasm CLI', async () => {
2626
if (runCfg === null) {
2727
runCfg = {
2828
jwt: "",
29+
defaultProjectID: ""
2930
}
3031
}
3132

@@ -38,6 +39,7 @@ describe('With wasm CLI', async () => {
3839
if (runCfg === null) {
3940
runCfg = {
4041
jwt: "",
42+
defaultProjectID: "",
4143
}
4244
}
4345
const resp = await cli.run(runCfg, command)
@@ -49,6 +51,7 @@ describe('With wasm CLI', async () => {
4951
if (runCfg === null) {
5052
runCfg = {
5153
jwt: "",
54+
defaultProjectID: ""
5255
}
5356
}
5457
let toComplete = command.pop() || ""

0 commit comments

Comments
 (0)