Skip to content

Commit 2d7cecf

Browse files
remyleonekindermoumouteestellesoulard
authored
feat(object): add support for IAM Access Key syntax (#4543)
Co-authored-by: Olivier Cano <kindermoumoute@users.noreply.github.com> Co-authored-by: Estelle Soulard <esoulard@scaleway.com>
1 parent da45726 commit 2d7cecf

18 files changed

+200
-21
lines changed

cmd/scw/testdata/test-all-usage-object-config-get-usage.golden

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ EXAMPLES:
1818
ARGS:
1919
type Type of S3 tool you want to generate a config for (rclone | s3cmd | mc)
2020
[name=scaleway] Name of the s3 remote you want to generate
21+
[project-id] Scaleway project ID to use with IAM Access Key syntax
2122
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams)
2223

2324
FLAGS:

cmd/scw/testdata/test-all-usage-object-config-install-usage.golden

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ EXAMPLES:
1818
ARGS:
1919
type Type of S3 tool you want to generate a config for (rclone | s3cmd | mc)
2020
[name=scaleway] Name of the s3 remote you want to generate
21+
[project-id] Scaleway project ID to use with IAM Access Key syntax
2122
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams)
2223

2324
FLAGS:

docs/commands/object.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ scw object config get [arg=value ...]
146146
|------|---|-------------|
147147
| type | Required<br />One of: `rclone`, `s3cmd`, `mc` | Type of S3 tool you want to generate a config for |
148148
| name | Default: `scaleway` | Name of the s3 remote you want to generate |
149+
| project-id | | Scaleway project ID to use with IAM Access Key syntax |
149150
| region | Default: `fr-par`<br />One of: `fr-par`, `nl-ams` | Region to target. If none is passed will use default region from the config |
150151

151152

@@ -187,6 +188,7 @@ scw object config install [arg=value ...]
187188
|------|---|-------------|
188189
| type | Required<br />One of: `rclone`, `s3cmd`, `mc` | Type of S3 tool you want to generate a config for |
189190
| name | Default: `scaleway` | Name of the s3 remote you want to generate |
191+
| project-id | | Scaleway project ID to use with IAM Access Key syntax |
190192
| region | Default: `fr-par`<br />One of: `fr-par`, `nl-ams` | Region to target. If none is passed will use default region from the config |
191193

192194

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
version: 1
3+
interactions:
4+
- request:
5+
body: '{"access_key":"SCW2RRD4GEWP546QJ71C","secret_key":null,"description":"my-key","created_at":"2026-04-02T14:31:06.008718Z","updated_at":"2026-04-02T14:31:06.008718Z","expires_at":"2026-04-02T15:31:05.899Z","default_project_id":"5ebc0159-7cb7-406c-9521-9347d1987fb2","editable":true,"deletable":true,"managed":false,"creation_ip":"51.159.73.9","user_id":"fe7ad43d-91bc-4206-a4b9-f9d4150eafef"}'
6+
form: {}
7+
headers:
8+
User-Agent:
9+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.26.1; linux; amd64) cli-e2e-test
10+
url: https://api.scaleway.com/iam/v1alpha1/api-keys/SCW2RRD4GEWP546QJ71C
11+
method: GET
12+
response:
13+
body: '{"access_key":"SCW2RRD4GEWP546QJ71C","secret_key":null,"description":"my-key","created_at":"2026-04-02T14:31:06.008718Z","updated_at":"2026-04-02T14:31:06.008718Z","expires_at":"2026-04-02T15:31:05.899Z","default_project_id":"5ebc0159-7cb7-406c-9521-9347d1987fb2","editable":true,"deletable":true,"managed":false,"creation_ip":"51.159.73.9","user_id":"fe7ad43d-91bc-4206-a4b9-f9d4150eafef"}'
14+
headers:
15+
Content-Length:
16+
- "390"
17+
Content-Security-Policy:
18+
- default-src 'none'; frame-ancestors 'none'
19+
Content-Type:
20+
- application/json
21+
Date:
22+
- Thu, 02 Apr 2026 14:31:23 GMT
23+
Server:
24+
- Scaleway API Gateway (fr-par-1;edge02)
25+
Strict-Transport-Security:
26+
- max-age=63072000
27+
X-Content-Type-Options:
28+
- nosniff
29+
X-Frame-Options:
30+
- DENY
31+
X-Request-Id:
32+
- c6a06de4-d669-4faf-92de-9ae304c7228d
33+
status: 200 OK
34+
code: 200
35+
duration: ""
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
version: 1
3+
interactions:
4+
- request:
5+
body: '{"access_key":"SCW2RRD4GEWP546QJ71C","secret_key":null,"description":"my-key","created_at":"2026-04-02T14:31:06.008718Z","updated_at":"2026-04-02T14:31:06.008718Z","expires_at":"2026-04-02T15:31:05.899Z","default_project_id":"5ebc0159-7cb7-406c-9521-9347d1987fb2","editable":true,"deletable":true,"managed":false,"creation_ip":"51.159.73.9","user_id":"fe7ad43d-91bc-4206-a4b9-f9d4150eafef"}'
6+
form: {}
7+
headers:
8+
User-Agent:
9+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.26.1; linux; amd64) cli-e2e-test
10+
url: https://api.scaleway.com/iam/v1alpha1/api-keys/SCW2RRD4GEWP546QJ71C
11+
method: GET
12+
response:
13+
body: '{"access_key":"SCW2RRD4GEWP546QJ71C","secret_key":null,"description":"my-key","created_at":"2026-04-02T14:31:06.008718Z","updated_at":"2026-04-02T14:31:06.008718Z","expires_at":"2026-04-02T15:31:05.899Z","default_project_id":"5ebc0159-7cb7-406c-9521-9347d1987fb2","editable":true,"deletable":true,"managed":false,"creation_ip":"51.159.73.9","user_id":"fe7ad43d-91bc-4206-a4b9-f9d4150eafef"}'
14+
headers:
15+
Content-Length:
16+
- "390"
17+
Content-Security-Policy:
18+
- default-src 'none'; frame-ancestors 'none'
19+
Content-Type:
20+
- application/json
21+
Date:
22+
- Thu, 02 Apr 2026 14:31:23 GMT
23+
Server:
24+
- Scaleway API Gateway (fr-par-1;edge02)
25+
Strict-Transport-Security:
26+
- max-age=63072000
27+
X-Content-Type-Options:
28+
- nosniff
29+
X-Frame-Options:
30+
- DENY
31+
X-Request-Id:
32+
- 57113c83-37d3-443c-ae55-df2a61401fce
33+
status: 200 OK
34+
code: 200
35+
duration: ""
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
version: 1
3+
interactions:
4+
- request:
5+
body: '{"access_key":"SCW2RRD4GEWP546QJ71C","secret_key":null,"description":"my-key","created_at":"2026-04-02T14:31:06.008718Z","updated_at":"2026-04-02T14:31:06.008718Z","expires_at":"2026-04-02T15:31:05.899Z","default_project_id":"5ebc0159-7cb7-406c-9521-9347d1987fb2","editable":true,"deletable":true,"managed":false,"creation_ip":"51.159.73.9","user_id":"fe7ad43d-91bc-4206-a4b9-f9d4150eafef"}'
6+
form: {}
7+
headers:
8+
User-Agent:
9+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.26.1; linux; amd64) cli-e2e-test
10+
url: https://api.scaleway.com/iam/v1alpha1/api-keys/SCW2RRD4GEWP546QJ71C
11+
method: GET
12+
response:
13+
body: '{"access_key":"SCW2RRD4GEWP546QJ71C","secret_key":null,"description":"my-key","created_at":"2026-04-02T14:31:06.008718Z","updated_at":"2026-04-02T14:31:06.008718Z","expires_at":"2026-04-02T15:31:05.899Z","default_project_id":"5ebc0159-7cb7-406c-9521-9347d1987fb2","editable":true,"deletable":true,"managed":false,"creation_ip":"51.159.73.9","user_id":"fe7ad43d-91bc-4206-a4b9-f9d4150eafef"}'
14+
headers:
15+
Content-Length:
16+
- "390"
17+
Content-Security-Policy:
18+
- default-src 'none'; frame-ancestors 'none'
19+
Content-Type:
20+
- application/json
21+
Date:
22+
- Thu, 02 Apr 2026 14:31:23 GMT
23+
Server:
24+
- Scaleway API Gateway (fr-par-1;edge02)
25+
Strict-Transport-Security:
26+
- max-age=63072000
27+
X-Content-Type-Options:
28+
- nosniff
29+
X-Frame-Options:
30+
- DENY
31+
X-Request-Id:
32+
- 37aaafb3-027a-4deb-9fce-52f668750686
33+
status: 200 OK
34+
code: 200
35+
duration: ""
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
version: 1
3+
interactions:
4+
- request:
5+
body: '{"access_key":"SCW2RRD4GEWP546QJ71C","secret_key":null,"description":"my-key","created_at":"2026-04-02T14:31:06.008718Z","updated_at":"2026-04-02T14:31:06.008718Z","expires_at":"2026-04-02T15:31:05.899Z","default_project_id":"5ebc0159-7cb7-406c-9521-9347d1987fb2","editable":true,"deletable":true,"managed":false,"creation_ip":"51.159.73.9","user_id":"fe7ad43d-91bc-4206-a4b9-f9d4150eafef"}'
6+
form: {}
7+
headers:
8+
User-Agent:
9+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.26.1; linux; amd64) cli-e2e-test
10+
url: https://api.scaleway.com/iam/v1alpha1/api-keys/SCW2RRD4GEWP546QJ71C
11+
method: GET
12+
response:
13+
body: '{"access_key":"SCW2RRD4GEWP546QJ71C","secret_key":null,"description":"my-key","created_at":"2026-04-02T14:31:06.008718Z","updated_at":"2026-04-02T14:31:06.008718Z","expires_at":"2026-04-02T15:31:05.899Z","default_project_id":"5ebc0159-7cb7-406c-9521-9347d1987fb2","editable":true,"deletable":true,"managed":false,"creation_ip":"51.159.73.9","user_id":"fe7ad43d-91bc-4206-a4b9-f9d4150eafef"}'
14+
headers:
15+
Content-Length:
16+
- "390"
17+
Content-Security-Policy:
18+
- default-src 'none'; frame-ancestors 'none'
19+
Content-Type:
20+
- application/json
21+
Date:
22+
- Thu, 02 Apr 2026 14:31:23 GMT
23+
Server:
24+
- Scaleway API Gateway (fr-par-1;edge02)
25+
Strict-Transport-Security:
26+
- max-age=63072000
27+
X-Content-Type-Options:
28+
- nosniff
29+
X-Frame-Options:
30+
- DENY
31+
X-Request-Id:
32+
- 6a824b28-e70e-4df3-a171-2b264bc8c9d7
33+
status: 200 OK
34+
code: 200
35+
duration: ""

internal/namespaces/object/v1/custom_config_get.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ import (
1212

1313
func configGetCommand() *core.Command {
1414
type getArgs struct {
15-
Region scw.Region
16-
Type s3tool
17-
Name string
15+
Region scw.Region
16+
Type s3tool
17+
Name string
18+
ProjectID string
1819
}
1920

2021
return &core.Command{
@@ -37,6 +38,12 @@ func configGetCommand() *core.Command {
3738
Required: false,
3839
Default: core.DefaultValueSetter("scaleway"),
3940
},
41+
{
42+
Name: "project-id",
43+
Short: "Scaleway project ID to use with IAM Access Key syntax",
44+
Required: false,
45+
ValidateFunc: core.ValidateProjectID(),
46+
},
4047
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms),
4148
},
4249
Examples: []*core.Example{
@@ -62,7 +69,7 @@ func configGetCommand() *core.Command {
6269
Run: func(ctx context.Context, argsI any) (any, error) {
6370
args := argsI.(*getArgs)
6471

65-
config, err := newS3Config(ctx, args.Region, args.Name)
72+
config, err := newS3Config(ctx, args.Region, args.Name, args.ProjectID)
6673
if err != nil {
6774
return "", err
6875
}

internal/namespaces/object/v1/custom_config_get_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ func Test_ConfigGet(t *testing.T) {
1616
"11111111-1111-1111-1111-111111111111",
1717
),
1818
scw.WithDefaultOrganizationID("11111111-1111-1111-1111-111111111111"),
19+
scw.WithDefaultProjectID("11111111-1111-1111-1111-111111111111"),
1920
scw.WithDefaultZone(scw.ZoneFrPar1),
2021
scw.WithDefaultRegion(scw.RegionFrPar),
2122
)

internal/namespaces/object/v1/custom_config_install.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ import (
1616

1717
func configInstallCommand() *core.Command {
1818
type installArgs struct {
19-
Region scw.Region
20-
Type s3tool
21-
Name string
19+
Region scw.Region
20+
Type s3tool
21+
Name string
22+
ProjectID string
2223
}
2324

2425
return &core.Command{
@@ -41,6 +42,12 @@ func configInstallCommand() *core.Command {
4142
Required: false,
4243
Default: core.DefaultValueSetter("scaleway"),
4344
},
45+
{
46+
Name: "project-id",
47+
Short: "Scaleway project ID to use with IAM Access Key syntax",
48+
Required: false,
49+
ValidateFunc: core.ValidateProjectID(),
50+
},
4451
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms),
4552
},
4653
Examples: []*core.Example{
@@ -67,7 +74,7 @@ func configInstallCommand() *core.Command {
6774
Run: func(ctx context.Context, argsI any) (any, error) {
6875
args := argsI.(*installArgs)
6976

70-
config, err := newS3Config(ctx, args.Region, args.Name)
77+
config, err := newS3Config(ctx, args.Region, args.Name, args.ProjectID)
7178
if err != nil {
7279
return "", err
7380
}

0 commit comments

Comments
 (0)