Skip to content

Commit 1c864e0

Browse files
authored
Merge pull request #11879 from dmvolod/disable-core-in-tiltfile-option
🌱 Add enable_core_provider option support in tilt-settings.yaml|json file
2 parents acfdc09 + 5ce8edb commit 1c864e0

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": [
@@ -147,7 +149,7 @@ providers = {
147149
# }
148150
# }
149151

150-
def load_provider_tiltfiles():
152+
def load_provider_tilt_files():
151153
provider_repos = settings.get("provider_repos", [])
152154

153155
for repo in provider_repos:
@@ -392,8 +394,8 @@ def find_all_objects_names(objs):
392394
# Users may define their own Tilt customizations in tilt.d. This directory is excluded from git and these files will
393395
# not be checked in to version control.
394396
def include_user_tilt_files():
395-
user_tiltfiles = listdir("tilt.d")
396-
for f in user_tiltfiles:
397+
user_tilt_files = listdir("tilt.d")
398+
for f in user_tilt_files:
397399
include(f)
398400

399401
# Enable core cluster-api plus everything listed in 'enable_providers' in tilt-settings.json
@@ -403,7 +405,10 @@ def enable_providers():
403405

404406
def get_providers():
405407
user_enable_providers = settings.get("enable_providers", [])
406-
return {k: "" for k in user_enable_providers + always_enable_providers}.keys()
408+
all_providers = set(user_enable_providers) | set(default_enable_providers)
409+
if not settings.get("enable_core_provider", True):
410+
return all_providers - set([core_provider_name])
411+
return all_providers
407412

408413
def deploy_provider_crds():
409414
# NOTE: we are applying raw yaml for clusterctl resources (vs delegating this to clusterctl methods) because
@@ -552,7 +557,7 @@ def deploy_clusterclass(clusterclass_name, label, filename, substitutions):
552557
cmd_button(
553558
clusterclass_name + ".clusterclass:apply",
554559
argv = ["bash", "-c", apply_clusterclass_cmd],
555-
env = dictonary_to_list_of_string(substitutions),
560+
env = dictionary_to_list_of_string(substitutions),
556561
resource = clusterclass_name,
557562
icon_name = "note_add",
558563
text = "Apply `" + clusterclass_name + "` ClusterClass",
@@ -564,7 +569,7 @@ def deploy_clusterclass(clusterclass_name, label, filename, substitutions):
564569
cmd_button(
565570
clusterclass_name + ".clusterclass:delete",
566571
argv = ["bash", "-c", delete_clusterclass_cmd],
567-
env = dictonary_to_list_of_string(substitutions),
572+
env = dictionary_to_list_of_string(substitutions),
568573
resource = clusterclass_name,
569574
icon_name = "delete_forever",
570575
text = "Delete `" + clusterclass_name + "` ClusterClass",
@@ -589,7 +594,7 @@ def deploy_cluster_template(template_name, label, filename, substitutions):
589594
cmd_button(
590595
template_name + ":apply",
591596
argv = ["bash", "-c", apply_cluster_template_cmd],
592-
env = dictonary_to_list_of_string(substitutions),
597+
env = dictionary_to_list_of_string(substitutions),
593598
resource = template_name,
594599
icon_name = "add_box",
595600
text = "Create `" + template_name + "` cluster",
@@ -604,7 +609,7 @@ def deploy_cluster_template(template_name, label, filename, substitutions):
604609
cmd_button(
605610
template_name + ":delete",
606611
argv = ["bash", "-c", delete_clusters_cmd],
607-
env = dictonary_to_list_of_string(substitutions),
612+
env = dictionary_to_list_of_string(substitutions),
608613
resource = template_name,
609614
icon_name = "delete_forever",
610615
text = "Delete `" + template_name + "` clusters",
@@ -616,14 +621,14 @@ def deploy_cluster_template(template_name, label, filename, substitutions):
616621
cmd_button(
617622
template_name + ":delete-all",
618623
argv = ["bash", "-c", kubectl_cmd + " delete clusters --all --wait=false"],
619-
env = dictonary_to_list_of_string(substitutions),
624+
env = dictionary_to_list_of_string(substitutions),
620625
resource = template_name,
621626
icon_name = "delete_sweep",
622627
text = "Delete all workload clusters",
623628
)
624629

625-
# A function to convert dictonary to list of strings in a format of "name=value"
626-
def dictonary_to_list_of_string(substitutions):
630+
# A function to convert dictionary to list of strings in a format of "name=value"
631+
def dictionary_to_list_of_string(substitutions):
627632
substitutions_list = []
628633
for name, value in substitutions.items():
629634
substitutions_list.append(name + "=" + value)
@@ -635,7 +640,7 @@ def dictonary_to_list_of_string(substitutions):
635640

636641
include_user_tilt_files()
637642

638-
load_provider_tiltfiles()
643+
load_provider_tilt_files()
639644

640645
prepare_all()
641646

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)