@@ -201,21 +201,27 @@ def flavors():
201201 config .define_string_list ("worker-flavors" )
202202 cfg = config .parse ()
203203 worker_templates = cfg .get ('templates-to-run' , [])
204+
205+ substitutions = settings .get ("kustomize_substitutions" , {})
206+ for key in keys :
207+ decode_blob = local ("echo {} | base64 --decode -" .format (substitutions [key ]), quiet = True )
208+ substitutions [key [:- 4 ]] = str (decode_blob )
209+
210+ ssh_pub_key = "AZURE_SSH_PUBLIC_KEY"
211+ ssh_pub_key_path = "~/.ssh/id_rsa.pub"
212+ if not substitutions .get (ssh_pub_key ):
213+ print ("{} was not specified in tilt_config.json, attempting to load {}" .format (ssh_pub_key , ssh_pub_key_path ))
214+ pub_key_data = local ("cat {} | tr -d '\n ' | base64 - | tr -d '\n '" .format (ssh_pub_key_path ), quiet = True )
215+ substitutions [ssh_pub_key ] = str (pub_key_data )
216+
204217 for flavor in cfg .get ("worker-flavors" , []):
205218 if flavor not in worker_templates :
206219 worker_templates .append (flavor )
207220 for flavor in worker_templates :
208- deploy_worker_templates (flavor )
221+ deploy_worker_templates (flavor , substitutions )
209222
210223
211- def deploy_worker_templates (flavor ):
212- # validate required metadata
213- required_metadata = ["AZURE_SUBSCRIPTION_ID" ,"AZURE_TENANT_ID" ,"AZURE_CLIENT_ID" ,"AZURE_CLIENT_SECRET" , "AZURE_SSH_PUBLIC_KEY" ]
214- metadata = settings .get ("kustomize_substitutions" , {})
215- missing = [k for k in required_metadata if k not in metadata ]
216- if missing :
217- fail ("missing kustomize_substitutions keys {} in tilt-setting.json" .format (missing ))
218-
224+ def deploy_worker_templates (flavor , substitutions ):
219225 # validate flavor exists
220226 if flavor == "default" :
221227 yaml_file = "./templates/cluster-template.yaml"
@@ -225,9 +231,7 @@ def deploy_worker_templates(flavor):
225231 fail (yaml_file + " not found" )
226232
227233 yaml = str (read_file (yaml_file ))
228-
229234 # azure account information replacements
230- substitutions = settings .get ("kustomize_substitutions" , {})
231235 for substitution in substitutions :
232236 value = substitutions [substitution ]
233237 yaml = yaml .replace ("${" + substitution + "}" , value )
0 commit comments