@@ -76,7 +76,8 @@ def cloud_archive_download(
76
76
build_file = "" ,
77
77
build_file_contents = "" ,
78
78
profile = "" ,
79
- patch_cmds = []):
79
+ patch_cmds = [],
80
+ file_version = "" ):
80
81
""" Securely downloads and unpacks an archive from Minio, then places a
81
82
BUILD file inside. """
82
83
filename = repo_ctx .path (file_path ).basename
@@ -95,8 +96,11 @@ def cloud_archive_download(
95
96
elif provider == "s3" :
96
97
tool_path = repo_ctx .which ("aws" )
97
98
extra_flags = ["--profile" , profile ] if profile else []
98
- src_url = "s3://{}/{}" .format (bucket , file_path )
99
- cmd = [tool_path ] + extra_flags + ["s3" , "cp" , src_url , "." ]
99
+ bucket_arg = ["--bucket" , bucket ]
100
+ file_arg = ["--key" , file_path ]
101
+ file_version_arg = ["--version-id" , file_version ] if file_version else []
102
+ src_url = filename
103
+ cmd = [tool_path ] + extra_flags + ["s3api" , "get-object" ] + bucket_arg + file_arg + file_version_arg + [filename ]
100
104
elif provider == "backblaze" :
101
105
# NOTE: currently untested, as I don't have a B2 account.
102
106
tool_path = repo_ctx .which ("b2" )
@@ -168,6 +172,7 @@ def _cloud_archive_impl(ctx):
168
172
build_file_contents = ctx .attr .build_file_contents ,
169
173
profile = ctx .attr .profile if hasattr (ctx .attr , "profile" ) else "" ,
170
174
bucket = ctx .attr .bucket if hasattr (ctx .attr , "bucket" ) else "" ,
175
+ file_version = ctx .attr .file_version if hasattr (ctx .attr , "file_version" ) else "" ,
171
176
)
172
177
173
178
minio_archive = repository_rule (
@@ -210,6 +215,7 @@ s3_archive = repository_rule(
210
215
"patch_args" : attr .string_list (doc = "Arguments to use when applying patches." ),
211
216
"patch_cmds" : attr .string_list (doc = "Sequence of Bash commands to be applied after patches are applied." ),
212
217
"strip_prefix" : attr .string (doc = "Prefix to strip when archive is unpacked" ),
218
+ "file_version" : attr .string (doc = "file version id of object if bucket is versioned" ),
213
219
"_provider" : attr .string (default = "s3" ),
214
220
},
215
221
)
0 commit comments