rhcos-toolbox: check for an empty RUN label
`podman` returns `<no value>` when inspecting a label that does not
exist. That string is interpreted as the presence of a RUN label, so
we try to start the container with a non-existent RUN label. Use some
go formatting to return an empty string when the label is empty.
We've somehow avoided this until it was reported in RHBZ#2048789.
Co-authored-by: Jonathan Lebon <jonathan@jlebon.com>
diff --git a/rhcos-toolbox b/rhcos-toolbox
index b1e75cb..86de840 100755
--- a/rhcos-toolbox
+++ b/rhcos-toolbox
@@ -68,9 +68,10 @@
}
image_runlabel() {
- sudo podman image inspect "$TOOLBOX_IMAGE" --format "{{.Labels.run}}"
+ sudo podman image inspect "$TOOLBOX_IMAGE" --format '{{- if index .Labels "run" -}}{{.Labels.run}}{{- end -}}'
}
+
image_pull() {
if ! sudo --preserve-env podman pull --authfile /var/lib/kubelet/config.json "$TOOLBOX_IMAGE"; then
read -r -p "Would you like to manually authenticate to registry: '${REGISTRY}' and try again? [y/N] "