Skip to content

Commit 5ce8edb

Browse files
committed
🌱 Add enable_core_provider option support in tilt-settings.yaml|json file
1 parent 065f159 commit 5ce8edb

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

Tiltfile

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ if not usingLocalRegistry:
5252
if settings.get("default_registry", "") != "":
5353
default_registry(settings.get("default_registry"))
5454

55-
always_enable_providers = ["core"]
55+
core_provider_name = "core"
56+
57+
default_enable_providers = [core_provider_name]
5658

5759
providers = {
58-
"core": {
60+
core_provider_name: {
5961
"context": ".", # NOTE: this should be kept in sync with corresponding setting in tilt-prepare
6062
"image": "gcr.io/k8s-staging-cluster-api/cluster-api-controller",
6163
"live_reload_deps": [
@@ -160,7 +162,7 @@ providers = {
160162
# }
161163
# }
162164

163-
def load_provider_tiltfiles():
165+
def load_provider_tilt_files():
164166
provider_repos = settings.get("provider_repos", [])
165167

166168
for repo in provider_repos:
@@ -405,8 +407,8 @@ def find_all_objects_names(objs):
405407
# Users may define their own Tilt customizations in tilt.d. This directory is excluded from git and these files will
406408
# not be checked in to version control.
407409
def include_user_tilt_files():
408-
user_tiltfiles = listdir("tilt.d")
409-
for f in user_tiltfiles:
410+
user_tilt_files = listdir("tilt.d")
411+
for f in user_tilt_files:
410412
include(f)
411413

412414
# Enable core cluster-api plus everything listed in 'enable_providers' in tilt-settings.json
@@ -416,7 +418,10 @@ def enable_providers():
416418

417419
def get_providers():
418420
user_enable_providers = settings.get("enable_providers", [])
419-
return {k: "" for k in user_enable_providers + always_enable_providers}.keys()
421+
all_providers = set(user_enable_providers) | set(default_enable_providers)
422+
if not settings.get("enable_core_provider", True):
423+
return all_providers - set([core_provider_name])
424+
return all_providers
420425

421426
def deploy_provider_crds():
422427
# NOTE: we are applying raw yaml for clusterctl resources (vs delegating this to clusterctl methods) because
@@ -566,7 +571,7 @@ def deploy_clusterclass(clusterclass_name, label, filename, substitutions):
566571
cmd_button(
567572
clusterclass_name + ":apply",
568573
argv = ["bash", "-c", apply_clusterclass_cmd],
569-
env = dictonary_to_list_of_string(substitutions),
574+
env = dictionary_to_list_of_string(substitutions),
570575
resource = clusterclass_name,
571576
icon_name = "note_add",
572577
text = "Apply `" + clusterclass_name + "` ClusterClass",
@@ -578,7 +583,7 @@ def deploy_clusterclass(clusterclass_name, label, filename, substitutions):
578583
cmd_button(
579584
clusterclass_name + ":delete",
580585
argv = ["bash", "-c", delete_clusterclass_cmd],
581-
env = dictonary_to_list_of_string(substitutions),
586+
env = dictionary_to_list_of_string(substitutions),
582587
resource = clusterclass_name,
583588
icon_name = "delete_forever",
584589
text = "Delete `" + clusterclass_name + "` ClusterClass",
@@ -603,7 +608,7 @@ def deploy_cluster_template(template_name, label, filename, substitutions):
603608
cmd_button(
604609
template_name + ":apply",
605610
argv = ["bash", "-c", apply_cluster_template_cmd],
606-
env = dictonary_to_list_of_string(substitutions),
611+
env = dictionary_to_list_of_string(substitutions),
607612
resource = template_name,
608613
icon_name = "add_box",
609614
text = "Create `" + template_name + "` cluster",
@@ -618,7 +623,7 @@ def deploy_cluster_template(template_name, label, filename, substitutions):
618623
cmd_button(
619624
template_name + ":delete",
620625
argv = ["bash", "-c", delete_clusters_cmd],
621-
env = dictonary_to_list_of_string(substitutions),
626+
env = dictionary_to_list_of_string(substitutions),
622627
resource = template_name,
623628
icon_name = "delete_forever",
624629
text = "Delete `" + template_name + "` clusters",
@@ -630,14 +635,14 @@ def deploy_cluster_template(template_name, label, filename, substitutions):
630635
cmd_button(
631636
template_name + ":delete-all",
632637
argv = ["bash", "-c", kubectl_cmd + " delete clusters --all --wait=false"],
633-
env = dictonary_to_list_of_string(substitutions),
638+
env = dictionary_to_list_of_string(substitutions),
634639
resource = template_name,
635640
icon_name = "delete_sweep",
636641
text = "Delete all workload clusters",
637642
)
638643

639-
# A function to convert dictonary to list of strings in a format of "name=value"
640-
def dictonary_to_list_of_string(substitutions):
644+
# A function to convert dictionary to list of strings in a format of "name=value"
645+
def dictionary_to_list_of_string(substitutions):
641646
substitutions_list = []
642647
for name, value in substitutions.items():
643648
substitutions_list.append(name + "=" + value)
@@ -649,7 +654,7 @@ def dictonary_to_list_of_string(substitutions):
649654

650655
include_user_tilt_files()
651656

652-
load_provider_tiltfiles()
657+
load_provider_tilt_files()
653658

654659
prepare_all()
655660

docs/book/src/developer/core/tilt.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ NB: the default is dynamic and will be "podman" if the string "Podman Engine" is
8585
**enable_providers** (Array[]String, default=['docker']): A list of the providers to enable. See [available providers](#available-providers)
8686
for more details.
8787

88+
**enable_core_provider** (bool, default=true): By default, the `core` provider is enabled. This allows to disable it.
89+
8890
**template_dirs** (Map{String: Array[]String}, default={"docker": [
8991
"./test/infrastructure/docker/templates"]}): A map of providers to directories containing cluster templates. An example of the field is given below. See [Deploying a workload cluster](#deploying-a-workload-cluster) for how this is used.
9092

0 commit comments

Comments
 (0)