mirror of
https://tangled.org/evan.jarrett.net/at-container-registry
synced 2026-09-10 04:06:06 +00:00
The client switcher built every command as "<client> pull <ref>". That is valid for docker, podman, buildah and nerdctl, but crane requires a destination: $ crane pull seamark.cr/user/bench8x1:v2 Error: requires at least 2 arg(s), only received 1 So selecting crane handed the user a command that cannot run. pullPrefix is a prefix-only helper, which is precisely why it could not express this; add a matching pullPostfix that returns " <image>.tar" for crane and "" for everything else, including "none" (image reference only), which must get neither prefix nor postfix. Both render paths change together, since fixing one leaves the bug visible in the other: the Go template helper paints first, and updatePullCommand in app.js re-renders when the dropdown changes. Repository names may contain slashes, so only the last path segment is used — otherwise the destination would name a subdirectory that does not exist. A name ending in "/" yields no destination at all rather than a bare ".tar", on the grounds that a visibly wrong-arity command beats silently writing a hidden file. That input is not reachable through the real repo-name path. The test asserts the whole command string rather than just the postfix, so it covers the prefix/postfix interaction and the "none" case where both vanish. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PDqoCE1j3njokkZ9b1C5n9
61 lines
3.4 KiB
HTML
61 lines
3.4 KiB
HTML
{{ define "pull-command-switcher" }}
|
|
{{/*
|
|
Pull command with inline OCI client switcher.
|
|
Expects dict with: RegistryURL, OwnerHandle, RepoName, Tag, ArtifactType, OciClient, IsLoggedIn
|
|
|
|
For helm charts, shows helm command only (no switcher).
|
|
For container images, shows a client dropdown that updates the command.
|
|
Logged-in users: saves to profile via HTMX POST.
|
|
Anonymous users: saves to localStorage.
|
|
*/}}
|
|
{{ if eq .ArtifactType "helm-chart" }}
|
|
{{/* Helm chart: small install/pull toggle. JS in app.js wires the
|
|
switcher and persists the choice in localStorage. Default = install. */}}
|
|
{{ $versionFlag := "" }}
|
|
{{ if .Tag }}{{ $versionFlag = print " --version " .Tag }}{{ end }}
|
|
{{ $ociRef := print "oci://" .RegistryURL "/" .OwnerHandle "/" .RepoName }}
|
|
<div class="space-y-2" id="helm-cmd-container"
|
|
data-registry-url="{{ .RegistryURL }}"
|
|
data-owner-handle="{{ .OwnerHandle }}"
|
|
data-repo-name="{{ .RepoName }}"
|
|
data-tag="{{ if .Tag }}{{ .Tag }}{{ end }}">
|
|
<label for="helm-cmd-switcher" class="text-sm font-medium text-base-content/70">Use this chart</label>
|
|
<div class="flex items-center gap-2">
|
|
<select id="helm-cmd-switcher" class="select select-xs select-bordered w-auto">
|
|
<option value="install" selected>helm install</option>
|
|
<option value="pull">helm pull</option>
|
|
</select>
|
|
<div id="helm-cmd-display" class="flex-1 min-w-0" aria-live="polite">
|
|
{{ template "docker-command" (print "helm install " .RepoName " " $ociRef $versionFlag) }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{{ else }}
|
|
<div class="space-y-2" id="pull-cmd-container"
|
|
data-registry-url="{{ .RegistryURL }}"
|
|
data-owner-handle="{{ .OwnerHandle }}"
|
|
data-repo-name="{{ .RepoName }}"
|
|
data-tag="{{ if .Tag }}{{ .Tag }}{{ else }}latest{{ end }}"
|
|
data-is-logged-in="{{ .IsLoggedIn }}">
|
|
<label for="oci-client-switcher" class="text-sm font-medium text-base-content/70">Pull this image</label>
|
|
<div class="flex items-center gap-2">
|
|
<select id="oci-client-switcher" class="select select-xs select-bordered w-auto">
|
|
<option value="docker"{{ if or (eq .OciClient "") (eq .OciClient "docker") }} selected{{ end }}>docker</option>
|
|
<option value="podman"{{ if eq .OciClient "podman" }} selected{{ end }}>podman</option>
|
|
<option value="nerdctl"{{ if eq .OciClient "nerdctl" }} selected{{ end }}>nerdctl</option>
|
|
<option value="buildah"{{ if eq .OciClient "buildah" }} selected{{ end }}>buildah</option>
|
|
<option value="crane"{{ if eq .OciClient "crane" }} selected{{ end }}>crane</option>
|
|
<option value="none"{{ if eq .OciClient "none" }} selected{{ end }}>image ref only</option>
|
|
</select>
|
|
<div id="pull-cmd-display" class="flex-1 min-w-0" aria-live="polite">
|
|
{{ if .Tag }}
|
|
{{ template "docker-command" (print (pullPrefix .OciClient) .RegistryURL "/" .OwnerHandle "/" .RepoName ":" .Tag (pullPostfix .OciClient .RepoName)) }}
|
|
{{ else }}
|
|
{{ template "docker-command" (print (pullPrefix .OciClient) .RegistryURL "/" .OwnerHandle "/" .RepoName ":latest" (pullPostfix .OciClient .RepoName)) }}
|
|
{{ end }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{{ end }}
|
|
{{ end }}
|