github.com/abayer/test-infra@v0.0.5/test_infra.bzl (about) 1 # Copyright 2017 The Kubernetes Authors. 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 15 def _http_archive_with_pkg_path_impl(ctx): 16 """Implements the http_archive_with_pkg_path build rule.""" 17 ctx.execute(["mkdir", "-p", ctx.attr.pkg_path]) 18 ctx.download_and_extract( 19 url=ctx.attr.url, 20 sha256=ctx.attr.sha256, 21 stripPrefix=ctx.attr.strip_prefix, 22 output=ctx.attr.pkg_path) 23 ctx.file(ctx.attr.pkg_path+"/BUILD.bazel", ctx.attr.build_file_content) 24 25 # http_archive_with_pkg_path extends the built-in new_http_archive with a 26 # pkg_path field, which can be used to specify the package installation path. 27 http_archive_with_pkg_path = repository_rule( 28 attrs = { 29 "build_file_content": attr.string(mandatory = True), 30 "pkg_path": attr.string(mandatory = True), 31 "sha256": attr.string(), 32 "strip_prefix": attr.string(mandatory = True), 33 "url": attr.string(mandatory = True), 34 }, 35 implementation = _http_archive_with_pkg_path_impl, 36 )