Skip to content

Commit 77a15fa

Browse files
committed
Work in review feedback
1 parent 47f4ba4 commit 77a15fa

File tree

1 file changed

+35
-41
lines changed

1 file changed

+35
-41
lines changed

helm/extensions.bzl

Lines changed: 35 additions & 41 deletions
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,10 +18,6 @@ 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"])
@@ -43,6 +43,16 @@ def _helm_impl(ctx):
4343
_register_toolchains(version, helm_url_templates, plugins)
4444
_register_go_yaml()
4545

46+
for repository in module.tags.import_repository:
47+
helm_import_repository(
48+
name = repository.name,
49+
chart_name = repository.chart_name,
50+
repository = repository.repository,
51+
sha256 = repository.sha256,
52+
url = repository.url,
53+
version = repository.version,
54+
)
55+
4656
def _register_toolchains(version, helm_url_templates, plugins):
4757
if not version in HELM_VERSIONS:
4858
fail("{} is not a supported version ({})".format(version, HELM_VERSIONS.keys()))
@@ -133,42 +143,26 @@ helm = module_extension(
133143
tag_classes = {
134144
"options": _toolchain, # deprecated: use toolchain instead and remove in next major version
135145
"toolchain": _toolchain,
146+
"import_repository": tag_class(attrs = {
147+
"name": attr.string(
148+
doc = "Name for the import dependency",
149+
),
150+
"chart_name": attr.string(
151+
doc = "Chart name to import.",
152+
),
153+
"repository": attr.string(
154+
doc = "Chart repository url where to locate the requested chart.",
155+
mandatory = True,
156+
),
157+
"sha256": attr.string(
158+
doc = "The expected SHA-256 hash of the chart imported.",
159+
),
160+
"url": attr.string(
161+
doc = "The url where the chart can be directly downloaded.",
162+
),
163+
"version": attr.string(
164+
doc = "Specify a version constraint for the chart version to use.",
165+
),
166+
}),
136167
},
137168
)
138-
139-
def _helm_import_impl(module_ctx):
140-
for mod in module_ctx.modules:
141-
for repository in mod.tags.repository:
142-
helm_import_repository(
143-
name = repository.name,
144-
chart_name = repository.chart_name,
145-
repository = repository.repository,
146-
sha256 = repository.sha256,
147-
url = repository.url,
148-
version = repository.version,
149-
)
150-
151-
helm_import = module_extension(
152-
implementation = _helm_import_impl,
153-
tag_classes = {"repository": tag_class(attrs = {
154-
"name": attr.string(
155-
doc = "Name for the import dependency",
156-
),
157-
"chart_name": attr.string(
158-
doc = "Chart name to import.",
159-
),
160-
"repository": attr.string(
161-
doc = "Chart repository url where to locate the requested chart.",
162-
mandatory = True,
163-
),
164-
"sha256": attr.string(
165-
doc = "The expected SHA-256 hash of the chart imported.",
166-
),
167-
"url": attr.string(
168-
doc = "The url where the chart can be directly downloaded.",
169-
),
170-
"version": attr.string(
171-
doc = "Specify a version constraint for the chart version to use.",
172-
),
173-
})},
174-
)

0 commit comments

Comments
 (0)