File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,17 +20,40 @@ _ATTRS = {
2020 ),
2121}
2222
23+ def _find_chart_url (repository_ctx , repo_file , chart_file ):
24+ repo_def = repository_ctx .read (repo_file )
25+ lines = repo_def .splitlines ()
26+ for l in lines :
27+ l = l .lstrip (" " )
28+ if l .startswith ("-" ) and l .endswith (chart_file ):
29+ url = l .lstrip ("-" ).lstrip (" " )
30+ if url == chart_file :
31+ return "{}/{}" .format (repository_ctx .attr .repository , url )
32+ if url .startswith ("http" ) and url .endswith ("/{}" .format (chart_file )):
33+ return url
34+ print (repo_def )
35+ fail ("cannot find {} in {}" .format (chart_file , repo_file ))
36+
2337def _impl (repository_ctx ):
38+ repo_yaml = "index.yaml"
39+
40+ repository_ctx .download (
41+ output = repo_yaml ,
42+ url = "{}/{}" .format (
43+ repository_ctx .attr .repository ,
44+ repo_yaml ,
45+ ),
46+ )
2447 file_name = "{}-{}.tgz" .format (
2548 repository_ctx .attr .chart_name ,
2649 repository_ctx .attr .version ,
2750 )
51+
52+ chart_url = _find_chart_url (repository_ctx , repo_yaml , file_name )
53+
2854 repository_ctx .download (
2955 output = file_name ,
30- url = "{}/{}" .format (
31- repository_ctx .attr .repository ,
32- file_name ,
33- ),
56+ url = chart_url ,
3457 sha256 = repository_ctx .attr .sha256 ,
3558 )
3659 repository_ctx .extract (
You can’t perform that action at this time.
0 commit comments