|
1 |
| -using CloudBase: CloudCredentials, AWSCredentials, AbstractStore, AWS |
| 1 | +using CloudBase: CloudBase, CloudCredentials, AbstractStore |
| 2 | +using CloudBase: AWSCredentials, AWS |
| 3 | +using CloudBase: AzureCredentials, Azure |
2 | 4 | using JSON3, HTTP, Sockets, Base64
|
3 | 5 | using RustyObjectStore: SnowflakeConfig, ClientOptions
|
4 | 6 | using Base: UUID
|
@@ -118,6 +120,31 @@ function construct_stage_info(credentials::AWSCredentials, store::AWS.Bucket, pa
|
118 | 120 | )
|
119 | 121 | end
|
120 | 122 |
|
| 123 | +function construct_stage_info(credentials::AzureCredentials, store::Azure.Container, encrypted::Bool) |
| 124 | + m = match(r"(https?://.*?)/(.*)", store.baseurl) |
| 125 | + @assert !isnothing(m) |
| 126 | + test_endpoint = m.captures[1] |
| 127 | + rest = split(HTTP.unescapeuri(m.captures[2]), "/") |
| 128 | + account = rest[1] |
| 129 | + container = rest[2] |
| 130 | + |
| 131 | + Dict( |
| 132 | + "locationType" => "AZURE", |
| 133 | + "location" => container * "/", |
| 134 | + "path" => container * "/", |
| 135 | + "region" => "westus2", |
| 136 | + "storageAccount" => account, |
| 137 | + "isClientSideEncrypted" => encrypted, |
| 138 | + "ciphers" => encrypted ? "AES_CBC" : nothing, |
| 139 | + "creds" => Dict( |
| 140 | + "AZURE_SAS_TOKEN" => "dummy-token", |
| 141 | + ), |
| 142 | + "useS3RegionalUrl" => false, |
| 143 | + "endPoint" => "blob.core.windows.net", |
| 144 | + "testEndpoint" => test_endpoint, |
| 145 | + ) |
| 146 | +end |
| 147 | + |
121 | 148 | function next_id_and_key(gw::SFGatewayMock)
|
122 | 149 | @lock gw.keys_lock begin
|
123 | 150 | key_id = gw.next_key_id
|
@@ -216,6 +243,8 @@ function start(gw::SFGatewayMock)
|
216 | 243 |
|
217 | 244 | stage_info = if isa(gw.credentials, AWSCredentials) && isa(gw.store, AWS.Bucket)
|
218 | 245 | construct_stage_info(gw.credentials, gw.store, stage_path(stage), gw.encrypted)
|
| 246 | + elseif isa(gw.credentials, AzureCredentials) && isa(gw.store, Azure.Container) |
| 247 | + construct_stage_info(gw.credentials, gw.store, gw.encrypted) |
219 | 248 | else
|
220 | 249 | error("unimplemented")
|
221 | 250 | end
|
@@ -251,18 +280,31 @@ function start(gw::SFGatewayMock)
|
251 | 280 |
|
252 | 281 | stage_info = if isa(gw.credentials, AWSCredentials) && isa(gw.store, AWS.Bucket)
|
253 | 282 | construct_stage_info(gw.credentials, gw.store, stage_path(stage), gw.encrypted)
|
| 283 | + elseif isa(gw.credentials, AzureCredentials) && isa(gw.store, Azure.Container) |
| 284 | + construct_stage_info(gw.credentials, gw.store, gw.encrypted) |
254 | 285 | else
|
255 | 286 | error("unimplemented")
|
256 | 287 | end
|
257 | 288 |
|
258 | 289 | encryption_material = if gw.encrypted
|
259 |
| - # fetch key id from s3 meta and return key |
260 |
| - response = AWS.head( |
261 |
| - stage_info["testEndpoint"] * "/" * stage_info["location"] * path; |
262 |
| - service="s3", region="us-east-1", credentials=gw.credentials |
263 |
| - ) |
264 |
| - pos = findfirst(x -> x[1] == "x-amz-meta-x-amz-matdesc", response.headers) |
265 |
| - matdesc = JSON3.read(response.headers[pos][2]) |
| 290 | + # fetch key id from blob meta and return key |
| 291 | + headers, metadata_key = if isa(gw.credentials, AWSCredentials) |
| 292 | + response = AWS.head( |
| 293 | + stage_info["testEndpoint"] * "/" * stage_info["location"] * path; |
| 294 | + service="s3", region="us-east-1", credentials=gw.credentials |
| 295 | + ) |
| 296 | + response.headers, "x-amz-meta-x-amz-matdesc" |
| 297 | + elseif isa(gw.credentials, AzureCredentials) |
| 298 | + response = Azure.head( |
| 299 | + stage_info["testEndpoint"] * "/" * stage_info["storageAccount"] * "/" * stage_info["location"] * path; |
| 300 | + service="blob", region="westus2", credentials=gw.credentials |
| 301 | + ) |
| 302 | + response.headers, "x-ms-meta-matdesc" |
| 303 | + else |
| 304 | + error("unknown credentials type: $(typeof(gw.credentials))") |
| 305 | + end |
| 306 | + pos = findfirst(x -> x[1] == metadata_key, headers) |
| 307 | + matdesc = JSON3.read(headers[pos][2]) |
266 | 308 | key_id = matdesc["queryId"]
|
267 | 309 | key = find_key_by_id(gw, key_id)
|
268 | 310 | Dict(
|
|
2 commit comments
alexrenz commentedon Nov 26, 2024
@JuliaRegistrator register
JuliaRegistrator commentedon Nov 26, 2024
Registration pull request created: JuliaRegistries/General/120189
Tip: Release Notes
Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.
To add them here just re-invoke and the PR will be updated.
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: