Skip to content

Commit 0572050

Browse files
committed
Work in review feedback
1 parent 46e2ace commit 0572050

File tree

1 file changed

+49
-49
lines changed

1 file changed

+49
-49
lines changed

helm/extensions.bzl

+49-49
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
44
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
5+
load(
6+
"//helm:defs.bzl",
7+
"helm_import_repository",
8+
)
59
load(
610
"//helm:repositories.bzl",
711
"helm_host_alias_repository",
@@ -14,25 +18,35 @@ load(
1418
"DEFAULT_HELM_VERSION",
1519
"HELM_VERSIONS",
1620
)
17-
load(
18-
"//helm:defs.bzl",
19-
"helm_import_repository",
20-
)
2121

2222
_HELM_TAR_BUILD_CONTENT = """\
2323
package(default_visibility = ["//visibility:public"])
2424
exports_files(glob(["**"]))
2525
"""
2626

2727
def _helm_impl(ctx):
28-
module = ctx.modules[0]
29-
options = module.tags.options
30-
version = options[0].version
31-
helm_url_templates = options[0].helm_url_templates
32-
plugins = options[0].plugins
28+
for mod in ctx.modules:
29+
options = mod.tags.options
30+
if len(options) > 0:
31+
version = options[0].version
32+
helm_url_templates = options[0].helm_url_templates
33+
plugins = options[0].plugins
34+
35+
_register_toolchains(version, helm_url_templates, plugins)
36+
_register_go_yaml()
3337

34-
_register_toolchains(version, helm_url_templates, plugins)
35-
_register_go_yaml()
38+
for repository in mod.tags.import_repository:
39+
if not mod.is_root:
40+
print("Ignoring import of", repository.chart_name, "from", repository.repository, "because it's not done from the root module")
41+
continue
42+
helm_import_repository(
43+
name = repository.name,
44+
chart_name = repository.chart_name,
45+
repository = repository.repository,
46+
sha256 = repository.sha256,
47+
url = repository.url,
48+
version = repository.version,
49+
)
3650

3751
def _register_toolchains(version, helm_url_templates, plugins):
3852
if not version in HELM_VERSIONS:
@@ -118,42 +132,28 @@ options = tag_class(attrs = {
118132

119133
helm = module_extension(
120134
implementation = _helm_impl,
121-
tag_classes = {"options": options},
122-
)
123-
124-
def _helm_import_impl(module_ctx):
125-
for mod in module_ctx.modules:
126-
for repository in mod.tags.repository:
127-
helm_import_repository(
128-
name = repository.name,
129-
chart_name = repository.chart_name,
130-
repository = repository.repository,
131-
sha256 = repository.sha256,
132-
url = repository.url,
133-
version = repository.version,
134-
)
135-
136-
helm_import = module_extension(
137-
implementation = _helm_import_impl,
138-
tag_classes = {"repository": tag_class(attrs = {
139-
"name": attr.string(
140-
doc = "Name for the import dependency",
141-
),
142-
"chart_name": attr.string(
143-
doc = "Chart name to import.",
144-
),
145-
"repository": attr.string(
146-
doc = "Chart repository url where to locate the requested chart.",
147-
mandatory = True,
148-
),
149-
"sha256": attr.string(
150-
doc = "The expected SHA-256 hash of the chart imported.",
151-
),
152-
"url": attr.string(
153-
doc = "The url where the chart can be directly downloaded.",
154-
),
155-
"version": attr.string(
156-
doc = "Specify a version constraint for the chart version to use.",
157-
),
158-
})},
135+
tag_classes = {
136+
"options": options,
137+
"import_repository": tag_class(attrs = {
138+
"name": attr.string(
139+
doc = "Name for the import dependency",
140+
),
141+
"chart_name": attr.string(
142+
doc = "Chart name to import.",
143+
),
144+
"repository": attr.string(
145+
doc = "Chart repository url where to locate the requested chart.",
146+
mandatory = True,
147+
),
148+
"sha256": attr.string(
149+
doc = "The expected SHA-256 hash of the chart imported.",
150+
),
151+
"url": attr.string(
152+
doc = "The url where the chart can be directly downloaded.",
153+
),
154+
"version": attr.string(
155+
doc = "Specify a version constraint for the chart version to use.",
156+
),
157+
}),
158+
},
159159
)

0 commit comments

Comments
 (0)