mirror of
https://github.com/jlengrand/engine.git
synced 2026-03-10 08:11:21 +00:00
fix: scaleway specify regions for bucket storage and container registry (#347)
This commit is contained in:
@@ -61,7 +61,7 @@ rusoto_iam = "0.46.0"
|
||||
digitalocean = "0.1.1"
|
||||
|
||||
# Scaleway Deps
|
||||
scaleway_api_rs = "0.1.1"
|
||||
scaleway_api_rs = "=0.1.1"
|
||||
|
||||
[dev-dependencies]
|
||||
test-utilities = { path = "test_utilities" }
|
||||
|
||||
@@ -32,7 +32,7 @@ impl ScalewayCR {
|
||||
name: &str,
|
||||
secret_token: &str,
|
||||
default_project_id: &str,
|
||||
region: Zone,
|
||||
zone: Zone,
|
||||
) -> ScalewayCR {
|
||||
ScalewayCR {
|
||||
context,
|
||||
@@ -40,7 +40,7 @@ impl ScalewayCR {
|
||||
name: name.to_string(),
|
||||
default_project_id: default_project_id.to_string(),
|
||||
secret_token: secret_token.to_string(),
|
||||
zone: region,
|
||||
zone,
|
||||
listeners: Vec::new(),
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,7 @@ impl ScalewayCR {
|
||||
// https://developers.scaleway.com/en/products/registry/api/#get-09e004
|
||||
let scaleway_registry_namespaces = match block_on(scaleway_api_rs::apis::namespaces_api::list_namespaces(
|
||||
&self.get_configuration(),
|
||||
self.zone.to_string().as_str(),
|
||||
self.zone.region().to_string().as_str(),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
@@ -101,7 +101,7 @@ impl ScalewayCR {
|
||||
// https://developers.scaleway.com/en/products/registry/api/#get-a6f1bc
|
||||
let scaleway_images = match block_on(scaleway_api_rs::apis::images_api::list_images1(
|
||||
&self.get_configuration(),
|
||||
self.zone.to_string().as_str(),
|
||||
self.zone.region().to_string().as_str(),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
@@ -147,7 +147,7 @@ impl ScalewayCR {
|
||||
|
||||
match block_on(scaleway_api_rs::apis::images_api::delete_image1(
|
||||
&self.get_configuration(),
|
||||
self.zone.to_string().as_str(),
|
||||
self.zone.region().to_string().as_str(),
|
||||
image_to_delete.id.unwrap().as_str(),
|
||||
)) {
|
||||
Ok(res) => Ok(res),
|
||||
@@ -211,7 +211,7 @@ impl ScalewayCR {
|
||||
// https://developers.scaleway.com/en/products/registry/api/#post-7a8fcc
|
||||
match block_on(scaleway_api_rs::apis::namespaces_api::create_namespace(
|
||||
&self.get_configuration(),
|
||||
self.zone.to_string().as_str(),
|
||||
self.zone.region().to_string().as_str(),
|
||||
scaleway_api_rs::models::inline_object_23::InlineObject23 {
|
||||
name: image.name.clone(),
|
||||
description: None,
|
||||
@@ -253,7 +253,7 @@ impl ScalewayCR {
|
||||
|
||||
match block_on(scaleway_api_rs::apis::namespaces_api::delete_namespace(
|
||||
&self.get_configuration(),
|
||||
self.zone.to_string().as_str(),
|
||||
self.zone.region().to_string().as_str(),
|
||||
registry_to_delete.id.unwrap().as_str(),
|
||||
)) {
|
||||
Ok(res) => Ok(res),
|
||||
@@ -287,7 +287,7 @@ impl ScalewayCR {
|
||||
base64::encode(
|
||||
format!(
|
||||
r#"{{"auths":{{"rg.{}.scw.cloud":{{"auth":"{}"}}}}}}"#,
|
||||
self.zone.as_str(),
|
||||
self.zone.region().as_str(),
|
||||
base64::encode(format!("nologin:{}", self.secret_token).as_bytes())
|
||||
)
|
||||
.as_bytes(),
|
||||
|
||||
@@ -10,8 +10,9 @@ use crate::runtime::block_on;
|
||||
use rusoto_core::{Client, HttpClient, Region as RusotoRegion};
|
||||
use rusoto_credential::StaticProvider;
|
||||
use rusoto_s3::{
|
||||
CreateBucketRequest, Delete, DeleteBucketRequest, DeleteObjectsRequest, GetObjectRequest, HeadBucketRequest,
|
||||
ListObjectsRequest, ObjectIdentifier, PutBucketVersioningRequest, PutObjectRequest, S3Client, StreamingBody, S3,
|
||||
CreateBucketConfiguration, CreateBucketRequest, Delete, DeleteBucketRequest, DeleteObjectsRequest,
|
||||
GetObjectRequest, HeadBucketRequest, ListObjectsRequest, ObjectIdentifier, PutBucketVersioningRequest,
|
||||
PutObjectRequest, S3Client, StreamingBody, S3,
|
||||
};
|
||||
use tokio::io;
|
||||
|
||||
@@ -38,7 +39,7 @@ impl ScalewayOS {
|
||||
name: String,
|
||||
access_key: String,
|
||||
secret_token: String,
|
||||
region: Zone,
|
||||
zone: Zone,
|
||||
bucket_delete_strategy: BucketDeleteStrategy,
|
||||
) -> ScalewayOS {
|
||||
ScalewayOS {
|
||||
@@ -47,14 +48,14 @@ impl ScalewayOS {
|
||||
name,
|
||||
access_key,
|
||||
secret_token,
|
||||
zone: region,
|
||||
zone,
|
||||
bucket_delete_strategy,
|
||||
}
|
||||
}
|
||||
|
||||
fn get_s3_client(&self) -> S3Client {
|
||||
let region = RusotoRegion::Custom {
|
||||
name: self.zone.to_string(),
|
||||
name: self.zone.region().to_string(),
|
||||
endpoint: self.get_endpoint_url_for_region(),
|
||||
};
|
||||
|
||||
@@ -68,7 +69,7 @@ impl ScalewayOS {
|
||||
}
|
||||
|
||||
fn get_endpoint_url_for_region(&self) -> String {
|
||||
format!("https://s3.{}.scw.cloud", self.zone.to_string())
|
||||
format!("https://s3.{}.scw.cloud", self.zone.region().to_string())
|
||||
}
|
||||
|
||||
fn is_bucket_name_valid(bucket_name: &str) -> Result<(), Option<String>> {
|
||||
@@ -196,6 +197,9 @@ impl ObjectStorage for ScalewayOS {
|
||||
|
||||
if let Err(e) = block_on(s3_client.create_bucket(CreateBucketRequest {
|
||||
bucket: bucket_name.to_string(),
|
||||
create_bucket_configuration: Some(CreateBucketConfiguration {
|
||||
location_constraint: Some(self.zone.region().to_string()),
|
||||
}),
|
||||
..Default::default()
|
||||
})) {
|
||||
let message = format!(
|
||||
|
||||
@@ -29,4 +29,4 @@ hashicorp_vault = "2.0.1"
|
||||
digitalocean = "0.1.1"
|
||||
|
||||
# Scaleway Deps
|
||||
scaleway_api_rs = "0.1.1"
|
||||
scaleway_api_rs = "=0.1.1"
|
||||
|
||||
Reference in New Issue
Block a user