Skip to content

Commit ab2f3dc

Browse files
authored
Merge pull request #8930 from fabriziopandini/protect-well-known-registry-during-tilt-up
🌱 Protect well know registry from accidental push during tilt up
2 parents 40bf333 + cb5f429 commit ab2f3dc

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Tiltfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,16 @@ os_arch = str(local("go env GOARCH")).rstrip("\n")
4141
if settings.get("trigger_mode") == "manual":
4242
trigger_mode(TRIGGER_MODE_MANUAL)
4343

44-
if settings.get("default_registry") != "":
44+
usingLocalRegistry = str(local(kubectl_cmd + " get cm -n kube-public local-registry-hosting || true", quiet = True))
45+
if not usingLocalRegistry:
46+
if settings.get("default_registry", "") == "":
47+
fail("default_registry is required when not using a local registry, please add it to your tilt-settings.yaml/json")
48+
49+
protectedRegistries = ["gcr.io/k8s-staging-cluster-api"]
50+
if settings.get("default_registry") in protectedRegistries:
51+
fail("current default_registry '{}' is protected, tilt cannot push images to it. Please select another default_registry in your tilt-settings.yaml/json".format(settings.get("default_registry")))
52+
53+
if settings.get("default_registry", "") != "":
4554
default_registry(settings.get("default_registry"))
4655

4756
always_enable_providers = ["core"]

docs/book/src/developer/tilt.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ If you prefer JSON, you can create a `tilt-settings.json` file instead. YAML wil
6969
**allowed_contexts** (Array, default=[]): A list of kubeconfig contexts Tilt is allowed to use. See the Tilt documentation on
7070
[allow_k8s_contexts](https://docs.tilt.dev/api.html#api.allow_k8s_contexts) for more details.
7171

72-
**default_registry** (String, default=""): The image registry to use if you need to push images. See the [Tilt
72+
**default_registry** (String, default=[]): The image registry to use if you need to push images. See the [Tilt
7373
documentation](https://docs.tilt.dev/api.html#api.default_registry) for more details.
74+
Please note that, in case you are not using a local registry, this value is required; additionally, the Cluster API
75+
Tiltfile protects you from accidental push on `gcr.io/k8s-staging-cluster-api`.
7476

7577
**build_engine** (String, default="docker"): The engine used to build images. Can either be `docker` or `podman`.
7678
NB: the default is dynamic and will be "podman" if the string "Podman Engine" is found in `docker version` (or in `podman version` if the command fails).

0 commit comments

Comments
 (0)