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

🌱 Tilt fixups: Docs correction, Make label optional, infer manager name when not specified #5507

Merged
merged 3 commits into from
Oct 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ providers = {
"feature",
],
"label": "CAPI",
"manager_name": "capi-controller-manager",
},
"kubeadm-bootstrap": {
"context": "bootstrap/kubeadm",
Expand All @@ -66,7 +65,6 @@ providers = {
"../../go.sum",
],
"label": "CABPK",
"manager_name": "capi-kubeadm-bootstrap-controller-manager",
},
"kubeadm-control-plane": {
"context": "controlplane/kubeadm",
Expand All @@ -80,7 +78,6 @@ providers = {
"../../go.sum",
],
"label": "KCP",
"manager_name": "capi-kubeadm-control-plane-controller-manager",
},
"docker": {
"context": "test/infrastructure/docker",
Expand Down Expand Up @@ -166,7 +163,6 @@ COPY manager .
# 3. Runs kustomize for the provider's config/default and applies it
def enable_provider(name, debug):
p = providers.get(name)
manager_name = p.get("manager_name")
context = p.get("context")
go_main = p.get("go_main", "main.go")
label = p.get("label", name)
Expand Down Expand Up @@ -285,6 +281,8 @@ def enable_provider(name, debug):
yaml = str(kustomize_with_envsubst(context + "/config/default", True))
k8s_yaml(blob(yaml))

manager_name = find_manager(context + "/config/default")

k8s_resource(
workload = manager_name,
new_name = label.lower() + "_controller",
Expand All @@ -293,6 +291,15 @@ def enable_provider(name, debug):
links = links,
)

def find_manager(path):
randomvariable marked this conversation as resolved.
Show resolved Hide resolved
return local_output(
'{kustomize_cmd} build {path} | {yq_cmd} eval \'select(."kind"=="Deployment").metadata.name\' -'.format(
kustomize_cmd = kustomize_cmd,
path = path,
yq_cmd = yq_cmd,
),
)

# Users may define their own Tilt customizations in tilt.d. This directory is excluded from git and these files will
# not be checked in to version control.
def include_user_tilt_files():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Cluster API uses [cert-manager] to manage the certificates it needs for its webh
Before you apply Cluster API's yaml, you should [install `cert-manager`][cm-install]

[cert-manager]: https://github.com/jetstack/cert-manager
[cm-install]: https://docs.cert-manager.io/en/latest/getting-started/install/kubernetes.html
[cm-install]: https://cert-manager.io/docs/installation/

```
kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/<version>/cert-manager.yaml
Expand Down
27 changes: 13 additions & 14 deletions docs/book/src/developer/tilt.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,6 @@ for more details.
**kustomize_substitutions** (Map{String: String}, default={}): An optional map of substitutions for `${}`-style placeholders in the
provider's yaml.

{{#tabs name:"tab-tilt-kustomize-substitution" tabs:"AWS,Azure,DigitalOcean,GCP"}}
{{#tab AWS}}

For example, if the yaml contains `${AWS_B64ENCODED_CREDENTIALS}`, you could do the following:

```json
"kustomize_substitutions": {
"AWS_B64ENCODED_CREDENTIALS": "your credentials here"
}
```

**debug** (Map{string: Map} default{}): A map of named configurations for the provider. The key is the name of the provider.

Supported settings:
Expand Down Expand Up @@ -154,6 +143,17 @@ Supported settings:
configuration](https://www.jetbrains.com/help/go/attach-to-running-go-processes-with-debugger.html#step-3-create-the-remote-run-debug-configuration-on-the-client-computer)
pointing at port 30000.

{{#tabs name:"tab-tilt-kustomize-substitution" tabs:"AWS,Azure,DigitalOcean,GCP"}}
{{#tab AWS}}

For example, if the yaml contains `${AWS_B64ENCODED_CREDENTIALS}`, you could do the following:

```json
"kustomize_substitutions": {
"AWS_B64ENCODED_CREDENTIALS": "your credentials here"
}
```

{{#/tab }}
{{#tab AZURE}}

Expand Down Expand Up @@ -294,7 +294,8 @@ A provider must supply a `tilt-provider.json` file describing how to build it. H
"live_reload_deps": [
"main.go", "go.mod", "go.sum", "api", "cmd", "controllers", "pkg"
]
}
},
"label": "CAPA"
}
```

Expand Down Expand Up @@ -332,8 +333,6 @@ Set to `false` if your provider does not have a ./config folder or you do not wa
in tilt version >= v0.22.2 (see https://blog.tilt.dev/2021/08/09/resource-grouping.html); as a convention,
provider abbreviation should be used (CAPD, KCP etc.).

**manager_name** (String): If provided, it will allow tilt to move the provider controller under the above label.
randomvariable marked this conversation as resolved.
Show resolved Hide resolved

## 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