Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🏃 allow extra args with tilt #2932

Merged
merged 10 commits into from
Apr 22, 2020
16 changes: 11 additions & 5 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ 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": {
"context": ".",
"image": "gcr.io/k8s-staging-cluster-api/cluster-api-controller",
"live_reload_deps": [
"main.go",
Expand Down Expand Up @@ -95,7 +95,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(".")
alexeldeib marked this conversation as resolved.
Show resolved Hide resolved

for repo in provider_repos:
file = repo + "/tilt-provider.json"
provider_details = read_json(file, default = {})
Expand Down Expand Up @@ -156,14 +159,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.
detiber marked this conversation as resolved.
Show resolved Hide resolved
entrypoint = ["sh", "/start.sh", "/manager"]
provider_args = extra_args.get(name)
if provider_args:
entrypoint.extend(provider_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"),
Expand Down
23 changes: 23 additions & 0 deletions docs/book/src/developer/tilt.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
alexeldeib marked this conversation as resolved.
Show resolved Hide resolved
for this provider. Each item in the array will be passed is to the manager.
alexeldeib marked this conversation as resolved.
Show resolved Hide resolved

Example:

```json
{
"name": "core",
"config": {
"context": ".",
"image": "gcr.io/k8s-staging-cluster-api/cluster-api-controller",
"extra_args": ["--feature-gates=MachinePool=true"]
detiber marked this conversation as resolved.
Show resolved Hide resolved
}
alexeldeib marked this conversation as resolved.
Show resolved Hide resolved
}
```

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
Expand Down
18 changes: 18 additions & 0 deletions tilt-provider.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
detiber marked this conversation as resolved.
Show resolved Hide resolved
"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"
]
}
}