load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def _helm_deps_impl(ctx): # 1. Read the lockfile lockfile_content = ctx.read(ctx.path(Label("//third_party/helm:chartfile.lock.json"))) lock = json.decode(lockfile_content) # 2. Iterate over charts for name, info in lock.get("charts", {}).items(): # name is like "grafana/grafana" # repo_name will be "helm_grafana_grafana" repo_name = "helm_" + name.replace("/", "_").replace("-", "_") chart_name = name.split("/")[1] http_archive( name = repo_name, url = info["url"], sha256 = info["digest"], strip_prefix = chart_name, build_file_content = """ filegroup( name = "chart", srcs = glob(["**"]), visibility = ["//visibility:public"], ) """, ) helm_deps = module_extension( implementation = _helm_deps_impl, )