Skip to content

Commit c99a8bc

Browse files
committed
feat: tilt flavors with b64 secrets and default pub key
1 parent b426c8f commit c99a8bc

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ bazel-*
5151
.tiltbuild
5252
/tilt.d
5353
tilt-settings.json
54+
tilt_config.json
5455

5556
# e2e output
5657
test/e2e/junit.e2e_suite.*.xml

Tiltfile

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

templates/flavors/README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ Please note your tilt-settings.json must contain at minimum the following fields
3838
"AZURE_TENANT_ID_B64": "******",
3939
"AZURE_CLIENT_SECRET_B64": "******",
4040
"AZURE_CLIENT_ID_B64": "******",
41-
"AZURE_SUBSCRIPTION_ID": "******",
42-
"AZURE_TENANT_ID": "******",
43-
"AZURE_CLIENT_ID": "******",
44-
"AZURE_CLIENT_SECRET": "******",
45-
"AZURE_SSH_PUBLIC_KEY": "********"
4641
}
4742
}
4843
```

0 commit comments

Comments
 (0)