@@ -100,6 +100,23 @@ def maybeMergeConfig(config, globalConfig):
100100 else :
101101 return globalConfig
102102
103+ def mergePlugin (plugin : dict , allPlugins : dict , dynamicPluginsFile : str ):
104+ package = plugin ['package' ]
105+ if not isinstance (package , str ):
106+ raise InstallException (f"content of the \' plugins.package\' field must be a string in { dynamicPluginsFile } " )
107+
108+ # if `package` already exists in `allPlugins`, then override its fields
109+ if package not in allPlugins :
110+ allPlugins [package ] = plugin
111+ return
112+
113+ # override the included plugins with fields in the main plugins list
114+ print ('\n ======= Overriding dynamic plugin configuration' , package , flush = True )
115+ for key in plugin :
116+ if key == 'package' :
117+ continue
118+ allPlugins [package ][key ] = plugin [key ]
119+
103120class OciDownloader :
104121 def __init__ (self , destination : str ):
105122 self ._skopeo = shutil .which ('skopeo' )
@@ -308,7 +325,7 @@ def main():
308325 raise InstallException (f"content of the \' plugins\' field must be a list in { include } " )
309326
310327 for plugin in includePlugins :
311- allPlugins [ plugin [ 'package' ]] = plugin
328+ mergePlugin ( plugin , allPlugins , dynamicPluginsFile )
312329
313330 if 'plugins' in content :
314331 plugins = content ['plugins' ]
@@ -319,21 +336,7 @@ def main():
319336 raise InstallException (f"content of the \' plugins\' field must be a list in { dynamicPluginsFile } " )
320337
321338 for plugin in plugins :
322- package = plugin ['package' ]
323- if not isinstance (package , str ):
324- raise InstallException (f"content of the \' plugins.package\' field must be a string in { dynamicPluginsFile } " )
325-
326- # if `package` already exists in `allPlugins`, then override its fields
327- if package not in allPlugins :
328- allPlugins [package ] = plugin
329- continue
330-
331- # override the included plugins with fields in the main plugins list
332- print ('\n ======= Overriding dynamic plugin configuration' , package , flush = True )
333- for key in plugin :
334- if key == 'package' :
335- continue
336- allPlugins [package ][key ] = plugin [key ]
339+ mergePlugin (plugin , allPlugins , dynamicPluginsFile )
337340
338341 # add a hash for each plugin configuration to detect changes
339342 for plugin in allPlugins .values ():
0 commit comments