From 31dd04b2b99266269e9ebf374860aa912a1ff43e Mon Sep 17 00:00:00 2001 From: Ace Eldeib Date: Sat, 18 Apr 2020 14:19:48 -0700 Subject: [PATCH] :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..a2ddad17b30e --- /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" + ] + } +} \ No newline at end of file