1010
1111from himl .config_generator import ConfigProcessor
1212
13- from ops import Executor
13+ from ops import Executor , display
1414import logging
1515import os
1616
@@ -86,7 +86,7 @@ def generate_files(self, config_path, composition_path, composition):
8686 def generate_provider_config (self , config_path , composition_path ):
8787 output_file = "{}provider.tf.json" .format (composition_path )
8888 logger .info ('Generating terraform config %s' , output_file )
89- self .generator . process ( path = config_path ,
89+ self .generate_config ( config_path = config_path ,
9090 filters = ["provider" , "terraform" ],
9191 output_format = "json" ,
9292 output_file = output_file ,
@@ -95,22 +95,30 @@ def generate_provider_config(self, config_path, composition_path):
9595 def generate_variables_config (self , config_path , composition_path ):
9696 output_file = "{}variables.tfvars.json" .format (composition_path )
9797 logger .info ('Generating terraform config %s' , output_file )
98- self .generator .process (path = config_path ,
99- exclude_keys = ["helm" , "provider" ],
100- enclosing_key = "config" ,
101- output_format = "json" ,
102- output_file = output_file ,
103- print_data = True )
98+
99+ excluded_keys = ["helm" , "provider" ]
100+ if "composition=account" in config_path :
101+ excluded_keys .append ("remote_states" )
102+
103+ self .generate_config (config_path = config_path ,
104+ exclude_keys = excluded_keys ,
105+ enclosing_key = "config" ,
106+ output_format = "json" ,
107+ output_file = output_file ,
108+ print_data = True )
104109
105110 def generate_config (self , config_path , filters = (), exclude_keys = (), enclosing_key = None , output_format = "yaml" ,
106111 print_data = False , output_file = None ):
107- print self .get_sh_command (config_path , filters , exclude_keys , enclosing_key , output_format , print_data , output_file )
112+ cmd = self .get_sh_command (config_path , filters , exclude_keys , enclosing_key , output_format , print_data ,
113+ output_file )
114+ display (cmd , color = "yellow" )
108115 self .generator .process (path = config_path ,
109- exclude_keys = ["helm" , "provider" ],
110- enclosing_key = "config" ,
111- output_format = "json" ,
116+ filters = filters ,
117+ exclude_keys = exclude_keys ,
118+ enclosing_key = enclosing_key ,
119+ output_format = output_format ,
112120 output_file = output_file ,
113- print_data = True )
121+ print_data = print_data )
114122
115123 @staticmethod
116124 def get_sh_command (config_path , filters = (), exclude_keys = (), enclosing_key = None , output_format = "yaml" ,
0 commit comments