Skip to content

Commit

Permalink
feat: allow to use a non-root S3 bucket location
Browse files Browse the repository at this point in the history
  • Loading branch information
satlank authored and woutersl committed Sep 23, 2024
1 parent d0b8eea commit fb0ebd6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
5 changes: 3 additions & 2 deletions README.docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,10 @@ This is controlled by the following configuration :
* `REGISTRY_STORAGE_TIMEOUT`: Timeout (in milli-seconds) to use when interacting with the storage, defaults to 3000
* `REGISTRY_S3_URI`: Endpoint base URI for the S3 service.
* `REGISTRY_S3_REGION`: Sub-domain for the region.
* `REGISTRY_S3_ACCESS_KEY`: The access key to use
* `REGISTRY_S3_SECRET_KEY`: The secret key to use
* `REGISTRY_S3_ACCESS_KEY`: The access key to use, set to empty string to search for existing credentials.
* `REGISTRY_S3_SECRET_KEY`: The secret key to use, set to empty string to search for existing credentials.
* `REGISTRY_S3_BUCKET`: The S3 bucket to use for storage. It will be created if it does not exist.
* `REGISTRY_S3_ROOT`: The prefix to use for storing the data in the bucket (e.g. `/cratery/`), if not set or set to empty string, data will be stored in the root of the bucket.

### Index

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,10 @@ This is controlled by the following configuration :
* `REGISTRY_STORAGE_TIMEOUT`: Timeout (in milli-seconds) to use when interacting with the storage, defaults to 3000
* `REGISTRY_S3_URI`: Endpoint base URI for the S3 service.
* `REGISTRY_S3_REGION`: Sub-domain for the region.
* `REGISTRY_S3_ACCESS_KEY`: The access key to use
* `REGISTRY_S3_SECRET_KEY`: The secret key to use
* `REGISTRY_S3_ACCESS_KEY`: The access key to use, set to empty string to search for existing credentials.
* `REGISTRY_S3_SECRET_KEY`: The secret key to use, set to empty string to search for existing credentials.
* `REGISTRY_S3_BUCKET`: The S3 bucket to use for storage. It will be created if it does not exist.
* `REGISTRY_S3_ROOT`: The prefix to use for storing the data in the bucket (e.g. `/cratery/`), if not set or set to empty string, data will be stored in the root of the bucket.

### Index

Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ services:
# REGISTRY_S3_ACCESS_KEY:
# REGISTRY_S3_SECRET_KEY:
# REGISTRY_S3_BUCKET:
# REGISTRY_S3_ROOT:
REGISTRY_OAUTH_LOGIN_URI: https://accounts.google.com/o/oauth2/v2/auth
REGISTRY_OAUTH_TOKEN_URI: https://oauth2.googleapis.com/token
REGISTRY_OAUTH_CALLBACK_URI: http://localhost/webapp/oauthcallback.html
Expand All @@ -53,4 +54,4 @@ services:
# REGISTRY_EMAIL_SMTP_PASSWORD:
# REGISTRY_EMAIL_SENDER:
# REGISTRY_EMAIL_CC:
# REGISTRY_SELF_LOCAL_NAME: localhost
# REGISTRY_SELF_LOCAL_NAME: localhost
3 changes: 3 additions & 0 deletions src/model/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ impl StorageConfig {
region: get_var("REGISTRY_S3_REGION")?,
access_key: get_var("REGISTRY_S3_ACCESS_KEY")?,
secret_key: get_var("REGISTRY_S3_SECRET_KEY")?,
root: get_var("REGISTRY_S3_ROOT").unwrap_or_default(),
},
bucket: get_var("REGISTRY_S3_BUCKET")?,
},
Expand All @@ -132,6 +133,8 @@ pub struct S3Params {
/// The account secret key
#[serde(rename = "secretKey")]
pub secret_key: String,
/// The prefix to use for the keys
pub root: String,
}

/// The configuration in the index
Expand Down
1 change: 1 addition & 0 deletions src/services/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ impl From<&Configuration> for StorageImpl {
StorageConfig::S3 { params, bucket } => {
let builder = opendal::services::S3::default()
.bucket(bucket)
.root(&params.root)
.region(&params.region)
.endpoint(&params.endpoint)
.access_key_id(&params.access_key)
Expand Down

0 comments on commit fb0ebd6

Please sign in to comment.