Skip to content

Commit e10bd7b

Browse files
committed
feat: support minio credentials for datasets
Handle minio credentials for dataset operations. fixes: JuliaComputing/JuliaHub#20486
1 parent dd146f9 commit e10bd7b

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/datasets.jl

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ end
801801
function _upload_dataset(upload_config, local_path; progress::Bool)
802802
type = upload_config["upload_type"]
803803
vendor = upload_config["vendor"]
804-
if type != "S3" || vendor != "aws"
804+
if type != "S3" || !(vendor in ("aws", "minio"))
805805
throw(JuliaHubError("Unknown upload type ($type) or vendor ($vendor)"))
806806
end
807807
mktemp() do rclone_conf_path, rclone_conf_io
@@ -868,19 +868,29 @@ function _write_rclone_config(
868868
access_key_id::AbstractString,
869869
secret_access_key::AbstractString,
870870
session_token::AbstractString,
871+
provider::AbstractString="AWS",
872+
endpoint::AbstractString="",
871873
)
874+
if lowercase(provider) == "aws"
875+
provider = "AWS"
876+
elseif lowercase(provider) == "minio"
877+
provider = "Minio"
878+
else
879+
throw(JuliaHubError("Unknown storage backend $(provider)"))
880+
end
881+
872882
write(
873883
io,
874884
"""
875885
[juliahub_remote]
876886
type = s3
877-
provider = AWS
887+
provider = $provider
878888
env_auth = false
879889
access_key_id = $access_key_id
880890
secret_access_key = $secret_access_key
881891
session_token = $session_token
882892
region = $region
883-
endpoint =
893+
endpoint = $endpoint
884894
location_constraint = $region
885895
acl = private
886896
server_side_encryption =
@@ -894,7 +904,9 @@ function _write_rclone_config(io::IO, upload_config::Dict)
894904
access_key_id = upload_config["credentials"]["access_key_id"]
895905
secret_access_key = upload_config["credentials"]["secret_access_key"]
896906
session_token = upload_config["credentials"]["session_token"]
897-
_write_rclone_config(io; region, access_key_id, secret_access_key, session_token)
907+
provider = upload_config["vendor"]
908+
endpoint = get(upload_config["credentials"], "endpoint_url", "")
909+
_write_rclone_config(io; region, access_key_id, secret_access_key, session_token, provider, endpoint)
898910
end
899911

900912
function _get_dataset_credentials(auth::Authentication, dataset::Dataset)
@@ -988,9 +1000,11 @@ function download_dataset(
9881000
throw(InvalidRequestError("Dataset '$(dataset.name)' does not have version 'v$version'"))
9891001

9901002
credentials = Mocking.@mock _get_dataset_credentials(auth, dataset)
991-
credentials["vendor"] == "aws" ||
1003+
provider = credentials["vendor"]
1004+
provider in ("aws", "minio") ||
9921005
throw(JuliaHubError("Unknown 'vendor': $(credentials["vendor"])"))
9931006
credentials = credentials["credentials"]
1007+
endpoint = get(credentials, "endpoint_url", "")
9941008

9951009
bucket = dataset._storage.bucket
9961010
prefix = dataset._storage.prefix
@@ -1019,6 +1033,8 @@ function download_dataset(
10191033
access_key_id=credentials["access_key_id"],
10201034
secret_access_key=credentials["secret_access_key"],
10211035
session_token=credentials["session_token"],
1036+
provider=provider,
1037+
endpoint=endpoint,
10221038
)
10231039
close(rclone_conf_io)
10241040

0 commit comments

Comments
 (0)