1616from deploy_config_generator .template import Template
1717from deploy_config_generator .errors import DeployConfigError , DeployConfigGenerationError , ConfigError , VarsReplacementError
1818from deploy_config_generator .utils import yaml_dump , show_traceback
19+ from deploy_config_generator .secrets import Secrets , SecretsException
1920
2021DISPLAY = None
2122SITE_CONFIG = None
@@ -78,7 +79,7 @@ def load_vars_files(varset, vars_dir, patterns, allow_var_references=True):
7879 varset .read_vars_file (vars_file , allow_var_references = allow_var_references )
7980
8081
81- def load_output_plugins (varset , output_dir , config_version ):
82+ def load_output_plugins (varset , secrets , output_dir , config_version ):
8283 '''
8384 Find, import, and instantiate all output plugins
8485 '''
@@ -111,7 +112,7 @@ def load_output_plugins(varset, output_dir, config_version):
111112 raise Exception ('name specified in OutputPlugin class (%s) does not match file name (%s)' % (cls .NAME , name ))
112113 DISPLAY .v ('Loading plugin %s' % name )
113114 # Instantiate plugin class
114- plugins .append (cls (varset , output_dir , config_version ))
115+ plugins .append (cls (varset , secrets , output_dir , config_version ))
115116 except ConfigError as e :
116117 DISPLAY .display ('Plugin configuration error: %s: %s' % (name , str (e )))
117118 sys .exit (1 )
@@ -263,8 +264,24 @@ def main():
263264 DISPLAY .vvvv ()
264265 DISPLAY .vvvv (yaml_dump (dict (varset ), indent = 2 ))
265266
267+ secrets = Secrets ()
268+
269+ try :
270+ for f in SITE_CONFIG .secrets_files :
271+ secrets .load_secrets_file (f )
272+ except SecretsException as e :
273+ DISPLAY .display ('Error loading secrets file %s' % (e .path ,))
274+ DISPLAY .v ('Stderr:' )
275+ DISPLAY .v ()
276+ DISPLAY .v (e .stderr )
277+ sys .exit (1 )
278+
279+ DISPLAY .vvvv ('Secrets:' )
280+ DISPLAY .vvvv ()
281+ DISPLAY .vvvv (yaml_dump (dict (secrets ), indent = 2 ))
282+
266283 try :
267- deploy_config = DeployConfig (os .path .join (deploy_dir , SITE_CONFIG .deploy_config_file ), varset )
284+ deploy_config = DeployConfig (os .path .join (deploy_dir , SITE_CONFIG .deploy_config_file ), varset , secrets )
268285 deploy_config .set_config (varset .replace_vars (deploy_config .get_config ()))
269286 except DeployConfigError as e :
270287 DISPLAY .display ('Error loading deploy config: %s' % str (e ))
@@ -280,7 +297,7 @@ def main():
280297 DISPLAY .vvvv (yaml_dump (deploy_config .get_config (), indent = 2 ))
281298
282299 deploy_config_version = deploy_config .get_version () or SITE_CONFIG .default_config_version
283- output_plugins = load_output_plugins (varset , args .output_dir , deploy_config_version )
300+ output_plugins = load_output_plugins (varset , secrets , args .output_dir , deploy_config_version )
284301
285302 DISPLAY .vvv ('Available output plugins:' )
286303 DISPLAY .vvv ()
0 commit comments