Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions internal/platform/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,26 @@ import (
)

type Platform struct {
UserAgent string
JWT string
UserAgent string
JWT string
DefaultProjectID string
}

func (p *Platform) CreateClient(client *http.Client, _ string, _ string) (*scw.Client, error) {
opts := []scw.ClientOption{
scw.WithDefaultRegion(scw.RegionFrPar),
scw.WithDefaultZone(scw.ZoneFrPar1),
scw.WithDefaultZone(scw.ZoneFrPar1),
scw.WithUserAgent(p.UserAgent),
scw.WithUserAgent("cli/web"),
scw.WithProfile(scw.LoadEnvProfile()),
scw.WithHTTPClient(client),
scw.WithJWT(p.JWT),
}

if p.DefaultProjectID != "" {
opts = append(opts, scw.WithDefaultProjectID(p.DefaultProjectID))
}

return scw.NewClient(opts...)
}

Expand Down
6 changes: 4 additions & 2 deletions internal/wasm/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ func getCommands() *core.Commands {
}

type RunConfig struct {
JWT string `js:"jwt"`
JWT string `js:"jwt"`
DefaultProjectID string `js:"defaultProjectID"`
}

type RunResponse struct {
Expand All @@ -37,7 +38,8 @@ func runCommand(cfg *RunConfig, args []string, stdout io.Writer, stderr io.Write
Stderr: stderr,
Stdin: nil,
Platform: &web.Platform{
JWT: cfg.JWT,
JWT: cfg.JWT,
DefaultProjectID: cfg.DefaultProjectID,
},
})

Expand Down
1 change: 1 addition & 0 deletions wasm/cli.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export type RunConfig = {
jwt: string
defaultProjectID: string
}

export type RunResponse = {
Expand Down
2 changes: 1 addition & 1 deletion wasm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@scaleway/scaleway-cli-wasm",
"version": "0.0.6",
"version": "0.0.7",
"description": "",
"type": "module",
"main": "index.js",
Expand Down
3 changes: 3 additions & 0 deletions wasm/src/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe('With wasm CLI', async () => {
if (runCfg === null) {
runCfg = {
jwt: "",
defaultProjectID: ""
}
}

Expand All @@ -38,6 +39,7 @@ describe('With wasm CLI', async () => {
if (runCfg === null) {
runCfg = {
jwt: "",
defaultProjectID: "",
}
}
const resp = await cli.run(runCfg, command)
Expand All @@ -49,6 +51,7 @@ describe('With wasm CLI', async () => {
if (runCfg === null) {
runCfg = {
jwt: "",
defaultProjectID: ""
}
}
let toComplete = command.pop() || ""
Expand Down