2
2
3
3
load ("@bazel_tools//tools/build_defs/repo:http.bzl" , "http_archive" )
4
4
load ("@bazel_tools//tools/build_defs/repo:utils.bzl" , "maybe" )
5
+ load (
6
+ "//helm:defs.bzl" ,
7
+ "helm_import_repository" ,
8
+ )
5
9
load (
6
10
"//helm:repositories.bzl" ,
7
11
"helm_host_alias_repository" ,
@@ -14,25 +18,35 @@ load(
14
18
"DEFAULT_HELM_VERSION" ,
15
19
"HELM_VERSIONS" ,
16
20
)
17
- load (
18
- "//helm:defs.bzl" ,
19
- "helm_import_repository" ,
20
- )
21
21
22
22
_HELM_TAR_BUILD_CONTENT = """\
23
23
package(default_visibility = ["//visibility:public"])
24
24
exports_files(glob(["**"]))
25
25
"""
26
26
27
27
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 ()
33
37
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
+ )
36
50
37
51
def _register_toolchains (version , helm_url_templates , plugins ):
38
52
if not version in HELM_VERSIONS :
@@ -118,42 +132,28 @@ options = tag_class(attrs = {
118
132
119
133
helm = module_extension (
120
134
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
+ },
159
159
)
0 commit comments