@@ -107,6 +107,10 @@ def _add_create_image_config_args(
107107 for key , value in labels .items ():
108108 args .add ("-labels" , "{}={}" .format (key , value ))
109109
110+ for label_file in ctx .files .label_files :
111+ args .add ("-labelFile" , label_file )
112+ inputs += ctx .files .label_files
113+
110114 for key , value in env .items ():
111115 args .add ("-env" , "%s" % "=" .join ([
112116 ctx .expand_make_variables ("env" , key , {}),
@@ -121,8 +125,8 @@ def _add_create_image_config_args(
121125 inputs += layer_names
122126 args .add_all (layer_names , before_each = "-layerDigestFile" , format_each = "@%s" )
123127
124- if ctx .attr .label_files :
125- inputs += ctx .files .label_files
128+ if ctx .attr .label_file_deps :
129+ inputs += ctx .files .label_file_deps
126130
127131 if base_config :
128132 args .add ("-baseConfig" , base_config )
@@ -178,7 +182,7 @@ def _image_config(
178182 manifest = ctx .actions .declare_file (name + "." + layer_name + ".manifest" )
179183
180184 label_file_dict = _string_to_label (
181- ctx .files .label_files ,
185+ ctx .files .label_file_deps ,
182186 ctx .attr .label_file_strings ,
183187 )
184188
@@ -640,7 +644,7 @@ _attrs = dicts.add(_layer.attrs, {
640644 ),
641645 "label_file_strings" : attr .string_list (),
642646 # Implicit/Undocumented dependencies.
643- "label_files " : attr .label_list (
647+ "label_file_deps " : attr .label_list (
644648 allow_files = True ,
645649 ),
646650 "labels" : attr .string_dict (
@@ -661,6 +665,20 @@ _attrs = dicts.add(_layer.attrs, {
661665
662666 The values of this field support stamp variables.""" ,
663667 ),
668+ "label_files" : attr .label_list (
669+ doc = """List of JSON files contains simple string-to-string dictionary with
670+ labels.
671+
672+ Example of file content:
673+
674+ {
675+ "com.example.foo": "bar",
676+ "com.example.baz": "@metadata.json"
677+ }
678+
679+ The values of this field support stamp variables.""" ,
680+ allow_files = True ,
681+ ),
664682 "launcher" : attr .label (
665683 allow_single_file = True ,
666684 doc = """If present, prefix the image's ENTRYPOINT with this file.
@@ -1006,7 +1024,7 @@ def container_image(**kwargs):
10061024 )
10071025
10081026 reserved_attrs = [
1009- "label_files " ,
1027+ "label_file_deps " ,
10101028 "label_file_strings" ,
10111029 "null_cmd" ,
10121030 "null_entrypoint" ,
@@ -1018,7 +1036,7 @@ def container_image(**kwargs):
10181036
10191037 if "labels" in kwargs :
10201038 files = sorted ({v [1 :]: None for v in kwargs ["labels" ].values () if v [0 ] == "@" }.keys ())
1021- kwargs ["label_files " ] = files
1039+ kwargs ["label_file_deps " ] = files
10221040 kwargs ["label_file_strings" ] = files
10231041
10241042 # If cmd is set but set to None, [] or "",
0 commit comments