Skip to content

Commit

Permalink
fix: it's not necessary to download all platform versions of binary.
Browse files Browse the repository at this point in the history
  • Loading branch information
zacker330 committed Oct 21, 2023
1 parent 497fbdc commit 827c60e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
11 changes: 7 additions & 4 deletions examples/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,15 @@ go_repository(
version = "v1.1.0",
)

http_archive(
#http_archive(
# name = "io_bazel_rules_prometheus",
# sha256 = "f389ea769e8192a185c8f6216f8535a7eef3d64b619abcc61d56800f39ac62a3",
# urls = ["https://github.com/zacker330/rules_prometheus/releases/download/v0.0.2/rules_prometheus.tar.gz"],
#)
local_repository(
name = "io_bazel_rules_prometheus",
sha256 = "f389ea769e8192a185c8f6216f8535a7eef3d64b619abcc61d56800f39ac62a3",
urls = ["https://github.com/zacker330/rules_prometheus/releases/download/v0.0.2/rules_prometheus.tar.gz"],
path = "../",
)

load("@io_bazel_rules_prometheus//:deps.bzl", "rules_prometheus_dependencies", "prometheus_register_toolchains", "alertmanager_register_toolchains")
rules_prometheus_dependencies()
prometheus_register_toolchains(version = "2.43.1")
Expand Down
3 changes: 2 additions & 1 deletion internal/alertmanager/repos.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def _format_url(version, platform, url):
return whole_url

def _alertmanager_download_rule_impl(ctx):
os, arch = ctx.attr.os, ctx.attr.arch
os, arch = detect_host_platform(ctx)
# os, arch = ctx.attr.os, ctx.attr.arch
platform = os + "-" + arch

version = ctx.attr.version
Expand Down
18 changes: 9 additions & 9 deletions internal/prometheus/repos.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ load("@io_bazel_rules_prometheus//internal:platforms.bzl", "BAZEL_OS_CONSTRAINTS
def _prometheus_build_file(ctx, platform, version):
os, _, arch = platform.partition("-")


constraints = [BAZEL_OS_CONSTRAINTS[os], BAZEL_ARCH_CONSTRAINTS[arch]]

constraint_str = ",\n ".join(['"%s"' % c for c in constraints])
Expand Down Expand Up @@ -60,14 +59,15 @@ def _format_url(version, platform, url):
return whole_url

def _prometheus_download_rule_impl(ctx):
if not ctx.attr.os and not ctx.attr.arch:
os, arch = detect_host_platform(ctx)
else:
if not ctx.attr.os:
fail("arch set but os not set")
if not ctx.attr.arch:
fail("os set but arch not set")
# os, arch = ctx.attr.os, ctx.attr.arch
os, arch = detect_host_platform(ctx)
# if not ctx.attr.os and not ctx.attr.arch:
# os, arch = detect_host_platform(ctx)
# else:
# if not ctx.attr.os:
# fail("arch set but os not set")
# if not ctx.attr.arch:
# fail("os set but arch not set")
# os, arch = ctx.attr.os, ctx.attr.arch
platform = os + "-" + arch

version = ctx.attr.version
Expand Down

0 comments on commit 827c60e

Please sign in to comment.