From d83881e6bfeba5eaf5f982ac21e0e3e59ddeabd7 Mon Sep 17 00:00:00 2001 From: Ace Eldeib Date: Sat, 18 Apr 2020 14:19:48 -0700 Subject: [PATCH 1/9] :running: allow extra args with tilt --- Tiltfile | 29 ++++++++++------------------- docs/book/src/developer/tilt.md | 23 +++++++++++++++++++++++ tilt-provider.json | 18 ++++++++++++++++++ 3 files changed, 51 insertions(+), 19 deletions(-) create mode 100644 tilt-provider.json diff --git a/Tiltfile b/Tiltfile index 5adafa7ed111..c0047851c749 100644 --- a/Tiltfile +++ b/Tiltfile @@ -25,21 +25,6 @@ default_registry(settings.get("default_registry")) always_enable_providers = ["core"] providers = { - "core": { - "context": ".", - "image": "gcr.io/k8s-staging-cluster-api/cluster-api-controller", - "live_reload_deps": [ - "main.go", - "go.mod", - "go.sum", - "api", - "cmd", - "controllers", - "errors", - "third_party", - "util", - ], - }, "kubeadm-bootstrap": { "context": "bootstrap/kubeadm", "image": "gcr.io/k8s-staging-cluster-api/kubeadm-bootstrap-controller", @@ -95,7 +80,10 @@ COPY --from=tilt-helper /go/kubernetes/client/bin/kubectl /usr/bin/kubectl # } # } def load_provider_tiltfiles(): - provider_repos = settings.get("provider_repos", []) + provider_repos = settings.get("provider_repos", ["."]) + if "." not in provider_repos: + provider_repos.append(".") + for repo in provider_repos: file = repo + "/tilt-provider.json" provider_details = read_json(file, default = {}) @@ -156,14 +144,17 @@ def enable_provider(name): additional_docker_build_commands, ]) - # Set up an image build for the provider. The live update configuration syncs the output from the local_resource - # build into the container. + entrypoint = ["sh", "/start.sh", "/manager"] + extra_args = p.get("extra_args") + if extra_args: + entrypoint.extend(extra_args) + docker_build( ref = p.get("image"), context = context + "/.tiltbuild/", dockerfile_contents = dockerfile_contents, target = "tilt", - entrypoint = ["sh", "/start.sh", "/manager"], + entrypoint = entrypoint, only = "manager", live_update = [ sync(context + "/.tiltbuild/manager", "/manager"), diff --git a/docs/book/src/developer/tilt.md b/docs/book/src/developer/tilt.md index cbb6434486a6..ffb2f54be7c8 100644 --- a/docs/book/src/developer/tilt.md +++ b/docs/book/src/developer/tilt.md @@ -192,6 +192,29 @@ COPY --from=tilt-helper /usr/bin/docker /usr/bin/docker COPY --from=tilt-helper /go/kubernetes/client/bin/kubectl /usr/bin/kubectl ``` + +**extra_args** (Array, default=[]): An array of additional arguments to pass to the main binary configured +for this provider. Each item in the array will be passed is to the manager. + +Example: + +```json +{ + "name": "core", + "config": { + "context": ".", + "image": "gcr.io/k8s-staging-cluster-api/cluster-api-controller", + "extra_args": ["--feature-gates=MachinePool=true"] + } +} +``` + +With this config, the manager will be invoked with: + +```bash +manager --feature-gates=MachinePool=true +``` + ## Customizing Tilt If you need to customize Tilt's behavior, you can create files in cluster-api's `tilt.d` directory. This file is ignored diff --git a/tilt-provider.json b/tilt-provider.json new file mode 100644 index 000000000000..b5f1dab6fd6f --- /dev/null +++ b/tilt-provider.json @@ -0,0 +1,18 @@ +{ + "name": "core", + "config": { + "context": ".", + "image": "gcr.io/k8s-staging-cluster-api/cluster-api-controller", + "live_reload_deps": [ + "main.go", + "go.mod", + "go.sum", + "api", + "cmd", + "controllers", + "errors", + "third_party", + "util" + ] + } +} From 8c4e53bf7a005a767393f90de7436b6d73b2c7c1 Mon Sep 17 00:00:00 2001 From: Ace Eldeib Date: Tue, 21 Apr 2020 20:48:02 -0700 Subject: [PATCH 2/9] fix: review feedback --- Tiltfile | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Tiltfile b/Tiltfile index c0047851c749..4b06156f0d6e 100644 --- a/Tiltfile +++ b/Tiltfile @@ -23,8 +23,23 @@ allow_k8s_contexts(settings.get("allowed_contexts")) default_registry(settings.get("default_registry")) always_enable_providers = ["core"] +extra_args = settings.get("extra_args", {}) providers = { + "core": { + "image": "gcr.io/k8s-staging-cluster-api/cluster-api-controller", + "live_reload_deps": [ + "main.go", + "go.mod", + "go.sum", + "api", + "cmd", + "controllers", + "errors", + "third_party", + "util", + ], + }, "kubeadm-bootstrap": { "context": "bootstrap/kubeadm", "image": "gcr.io/k8s-staging-cluster-api/kubeadm-bootstrap-controller", @@ -145,9 +160,9 @@ def enable_provider(name): ]) entrypoint = ["sh", "/start.sh", "/manager"] - extra_args = p.get("extra_args") - if extra_args: - entrypoint.extend(extra_args) + provider_args = extra_args.get(name) + if provider_args: + entrypoint.extend(provider_args) docker_build( ref = p.get("image"), From db6840c6853f57c10e7e43350476518ea6f27b93 Mon Sep 17 00:00:00 2001 From: Ace Eldeib Date: Wed, 22 Apr 2020 09:05:47 -0700 Subject: [PATCH 3/9] :hammer_and_pick: fix extra args type Co-Authored-By: Jason DeTiberus --- docs/book/src/developer/tilt.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/book/src/developer/tilt.md b/docs/book/src/developer/tilt.md index ffb2f54be7c8..8dc685f60b70 100644 --- a/docs/book/src/developer/tilt.md +++ b/docs/book/src/developer/tilt.md @@ -193,7 +193,7 @@ COPY --from=tilt-helper /go/kubernetes/client/bin/kubectl /usr/bin/kubectl ``` -**extra_args** (Array, default=[]): An array of additional arguments to pass to the main binary configured +**extra_args** (Object, default={}): A mapping of provider to additional arguments to pass to the main binary configured for this provider. Each item in the array will be passed is to the manager. Example: From 07a65a49543c06c0f20cb065c28f56c06a7d8211 Mon Sep 17 00:00:00 2001 From: Ace Eldeib Date: Wed, 22 Apr 2020 09:06:22 -0700 Subject: [PATCH 4/9] :hammer_and_pick: add machinepool feature gate for all providers Co-Authored-By: Jason DeTiberus --- docs/book/src/developer/tilt.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/docs/book/src/developer/tilt.md b/docs/book/src/developer/tilt.md index 8dc685f60b70..297343dc0054 100644 --- a/docs/book/src/developer/tilt.md +++ b/docs/book/src/developer/tilt.md @@ -200,11 +200,10 @@ Example: ```json { - "name": "core", - "config": { - "context": ".", - "image": "gcr.io/k8s-staging-cluster-api/cluster-api-controller", - "extra_args": ["--feature-gates=MachinePool=true"] + "extra_args": { + "core": ["--feature-gates=MachinePool=true"], + "kubeadm-bootstrap": ["--feature-gates=MachinePool=true"], + "azure": ["--feature-gates=MachinePool=true"] } } ``` From 8d45780a664708cc1ffae009138106275e7b045b Mon Sep 17 00:00:00 2001 From: Ace Eldeib Date: Wed, 22 Apr 2020 09:06:52 -0700 Subject: [PATCH 5/9] :hammer_and_pick: remove extra files --- tilt-provider.json | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 tilt-provider.json diff --git a/tilt-provider.json b/tilt-provider.json deleted file mode 100644 index b5f1dab6fd6f..000000000000 --- a/tilt-provider.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "core", - "config": { - "context": ".", - "image": "gcr.io/k8s-staging-cluster-api/cluster-api-controller", - "live_reload_deps": [ - "main.go", - "go.mod", - "go.sum", - "api", - "cmd", - "controllers", - "errors", - "third_party", - "util" - ] - } -} From 5beec587b49dd36ad7c9d5c5a43c6e648182f6fa Mon Sep 17 00:00:00 2001 From: Ace Eldeib Date: Wed, 22 Apr 2020 09:08:03 -0700 Subject: [PATCH 6/9] :hammer_and_pick: don't remove helpful comments --- Tiltfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Tiltfile b/Tiltfile index 4b06156f0d6e..ebfa44485d79 100644 --- a/Tiltfile +++ b/Tiltfile @@ -95,9 +95,7 @@ COPY --from=tilt-helper /go/kubernetes/client/bin/kubectl /usr/bin/kubectl # } # } def load_provider_tiltfiles(): - provider_repos = settings.get("provider_repos", ["."]) - if "." not in provider_repos: - provider_repos.append(".") + provider_repos = settings.get("provider_repos", ["]) for repo in provider_repos: file = repo + "/tilt-provider.json" @@ -159,6 +157,8 @@ def enable_provider(name): additional_docker_build_commands, ]) + # Set up an image build for the provider. The live update configuration syncs the output from the local_resource + # build into the container. entrypoint = ["sh", "/start.sh", "/manager"] provider_args = extra_args.get(name) if provider_args: From 5bc847de1a89e4dbfea3b212dd8cdf52bf4938f0 Mon Sep 17 00:00:00 2001 From: Ace Eldeib Date: Wed, 22 Apr 2020 09:08:32 -0700 Subject: [PATCH 7/9] :bug: fix spelling typo Co-Authored-By: Jason DeTiberus --- docs/book/src/developer/tilt.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/book/src/developer/tilt.md b/docs/book/src/developer/tilt.md index 297343dc0054..37af5162e805 100644 --- a/docs/book/src/developer/tilt.md +++ b/docs/book/src/developer/tilt.md @@ -194,7 +194,7 @@ COPY --from=tilt-helper /go/kubernetes/client/bin/kubectl /usr/bin/kubectl **extra_args** (Object, default={}): A mapping of provider to additional arguments to pass to the main binary configured -for this provider. Each item in the array will be passed is to the manager. +for this provider. Each item in the array will be passed in to the manager. Example: From 83d342e4de81ab44b278907c32e4d8465914aca8 Mon Sep 17 00:00:00 2001 From: Ace Eldeib Date: Wed, 22 Apr 2020 09:11:41 -0700 Subject: [PATCH 8/9] :bug: fix missing quote --- Tiltfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tiltfile b/Tiltfile index ebfa44485d79..0beb94e9a2fb 100644 --- a/Tiltfile +++ b/Tiltfile @@ -95,7 +95,7 @@ COPY --from=tilt-helper /go/kubernetes/client/bin/kubectl /usr/bin/kubectl # } # } def load_provider_tiltfiles(): - provider_repos = settings.get("provider_repos", ["]) + provider_repos = settings.get("provider_repos", []) for repo in provider_repos: file = repo + "/tilt-provider.json" From 476434e1741288ebdda685aa6e25f1c199521641 Mon Sep 17 00:00:00 2001 From: Ace Eldeib Date: Wed, 22 Apr 2020 10:24:37 -0700 Subject: [PATCH 9/9] :bug: fix typo in tiltfile --- Tiltfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Tiltfile b/Tiltfile index 0beb94e9a2fb..219a4f4daca8 100644 --- a/Tiltfile +++ b/Tiltfile @@ -27,6 +27,7 @@ extra_args = settings.get("extra_args", {}) providers = { "core": { + "context": ".", "image": "gcr.io/k8s-staging-cluster-api/cluster-api-controller", "live_reload_deps": [ "main.go",