-
Notifications
You must be signed in to change notification settings - Fork 153
feat(object): add support for IAM Access Key syntax #4543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
remyleone
wants to merge
6
commits into
scaleway:master
Choose a base branch
from
remyleone:project_in_access_key
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
293a269
feat(object): add support for IAM Access Key syntax
remyleone 18d2c7b
Fix
remyleone 4fbc99c
Merge branch 'master' into project_in_access_key
remyleone 627da63
Fix
remyleone 45e78ed
Update internal/namespaces/object/v1/s3configfile.go
remyleone 15d2900
Update internal/namespaces/object/v1/s3configfile.go
remyleone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ type s3config struct { | |
Region scw.Region | ||
Name string | ||
ctx context.Context | ||
ProjectID string | ||
} | ||
|
||
const ( | ||
|
@@ -55,7 +56,7 @@ const s3cmdTemplate = `# Generated by scaleway-cli command | |
# Configuration file for s3cmd https://s3tools.org/s3cmd | ||
# Default location: $HOME/.s3cfg | ||
[default] | ||
access_key = {{ .AccessKey }} | ||
access_key = {{ .AccessKey }}@{{ .ProjectID }} | ||
bucket_location = {{ .Region }} | ||
host_base = s3.{{ .Region }}.scw.cloud | ||
host_bucket = %(bucket)s.s3.{{ .Region }}.scw.cloud | ||
|
@@ -71,7 +72,7 @@ type = s3 | |
provider = Scaleway | ||
env_auth = false | ||
endpoint = s3.{{ .Region }}.scw.cloud | ||
access_key_id = {{ .AccessKey }} | ||
access_key_id = {{ .AccessKey }}@{{ .ProjectID }} | ||
secret_access_key = {{ .SecretKey }} | ||
region = {{ .Region }} | ||
location_constraint = | ||
|
@@ -87,16 +88,24 @@ func newS3Config(ctx context.Context, region scw.Region, name string) (s3config, | |
if !accessExists { | ||
return s3config{}, errors.New("no access key found") | ||
} | ||
|
||
secretKey, secretExists := client.GetSecretKey() | ||
if !secretExists { | ||
return s3config{}, errors.New("no secret key found") | ||
} | ||
|
||
projectID, exists := client.GetDefaultProjectID() | ||
if !exists { | ||
return s3config{}, errors.New("no project ID found") | ||
} | ||
Comment on lines
+97
to
+100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO it should be optional |
||
|
||
config := s3config{ | ||
AccessKey: accessKey, | ||
SecretKey: secretKey, | ||
Region: region, | ||
Name: name, | ||
ctx: ctx, | ||
ProjectID: projectID, | ||
remyleone marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
return config, nil | ||
|
@@ -144,6 +153,7 @@ func (c s3config) getConfigFile(tool s3tool) (core.RawResult, error) { | |
AccessKey string `json:"accessKey"` | ||
SecretKey string `json:"secretKey"` | ||
API string `json:"api"` | ||
ProjectID string `json:"projectID"` | ||
} | ||
m := struct { | ||
Version string `json:"version"` | ||
|
@@ -153,7 +163,7 @@ func (c s3config) getConfigFile(tool s3tool) (core.RawResult, error) { | |
Hosts: map[string]hostconfig{ | ||
c.Name: { | ||
URL: "https://s3." + c.Region.String() + ".scw.cloud", | ||
AccessKey: c.AccessKey, | ||
AccessKey: c.AccessKey + "@" + c.ProjectID, | ||
SecretKey: c.SecretKey, | ||
API: "S3v4", | ||
}, | ||
|
4 changes: 2 additions & 2 deletions
4
internal/namespaces/object/v1/testdata/test-config-get-default-mc.golden
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 | ||
🟩🟩🟩 STDOUT️ 🟩🟩🟩️ | ||
{"version":"9","hosts":{"scaleway":{"url":"https://s3.fr-par.scw.cloud","accessKey":"SCWXXXXXXXXXXXXXXXXX","secretKey":"11111111-1111-1111-1111-111111111111","api":"S3v4"}}} | ||
{"version":"9","hosts":{"scaleway":{"url":"https://s3.fr-par.scw.cloud","accessKey":"SCWXXXXXXXXXXXXXXXXX@11111111-1111-1111-1111-111111111111","secretKey":"11111111-1111-1111-1111-111111111111","api":"S3v4","projectID":""}}} | ||
🟩🟩🟩 JSON STDOUT 🟩🟩🟩 | ||
{"version":"9","hosts":{"scaleway":{"url":"https://s3.fr-par.scw.cloud","accessKey":"SCWXXXXXXXXXXXXXXXXX","secretKey":"11111111-1111-1111-1111-111111111111","api":"S3v4"}}} | ||
{"version":"9","hosts":{"scaleway":{"url":"https://s3.fr-par.scw.cloud","accessKey":"SCWXXXXXXXXXXXXXXXXX@11111111-1111-1111-1111-111111111111","secretKey":"11111111-1111-1111-1111-111111111111","api":"S3v4","projectID":""}}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
internal/namespaces/object/v1/testdata/test-config-get-with-region-mc.golden
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲 | ||
🟩🟩🟩 STDOUT️ 🟩🟩🟩️ | ||
{"version":"9","hosts":{"scaleway":{"url":"https://s3.nl-ams.scw.cloud","accessKey":"SCWXXXXXXXXXXXXXXXXX","secretKey":"11111111-1111-1111-1111-111111111111","api":"S3v4"}}} | ||
{"version":"9","hosts":{"scaleway":{"url":"https://s3.nl-ams.scw.cloud","accessKey":"SCWXXXXXXXXXXXXXXXXX@11111111-1111-1111-1111-111111111111","secretKey":"11111111-1111-1111-1111-111111111111","api":"S3v4","projectID":""}}} | ||
🟩🟩🟩 JSON STDOUT 🟩🟩🟩 | ||
{"version":"9","hosts":{"scaleway":{"url":"https://s3.nl-ams.scw.cloud","accessKey":"SCWXXXXXXXXXXXXXXXXX","secretKey":"11111111-1111-1111-1111-111111111111","api":"S3v4"}}} | ||
{"version":"9","hosts":{"scaleway":{"url":"https://s3.nl-ams.scw.cloud","accessKey":"SCWXXXXXXXXXXXXXXXXX@11111111-1111-1111-1111-111111111111","secretKey":"11111111-1111-1111-1111-111111111111","api":"S3v4","projectID":""}}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.