Skip to content

fix(installer): reject invalid docker image references for --output early - #403

Open
chrisdebian wants to merge 1 commit into
mudler:masterfrom
chrisdebian:fix/360-docker-repo-image-reference-validation
Open

chrisdebian wants to merge 1 commit into
mudler:masterfrom
chrisdebian:fix/360-docker-repo-image-reference-validation

Conversation

@chrisdebian

Copy link
Copy Markdown

What

create-repo --type docker currently accepts whatever value is passed
via --output and uses it directly as a Docker image reference,
without validating it first.

Why this breaks (#360)

The generic create-repo example in the docs uses a filesystem path
for --output:

luet create-repo --name "test" --output $PWD/out --packages $PWD/out --tree $PWD/package

That's correct for the disk/http repository types. But the docs
also explain, a little further down, that the docker repository type
needs --output to be an actual docker image reference:

When specifying the docker repository type, luet will generate
final images from the build results and upload them to the docker
reference specified with --output.
(docs/content/en/docs/Concepts/Overview/repositories.md:118)

It's easy to miss that distinction and combine the generic example
with --type docker, which is exactly what #360 reports. The raw path
ends up embedded as an image tag in pushFileFromArtifact/
GenerateFinalImage, and gets rejected by Docker's own (stricter)
reference grammar deep inside a shelled-out docker load call — one
artifact at a time, with an opaque invalid reference format error
and no indication of what's actually wrong.

Fix

Validate --output as a real docker reference in
LuetSystemRepository.getGenerator, before any file walking or image
building starts, using github.com/distribution/reference (already
an indirect dependency of this module — promoted to direct here, no
new dependency added). On failure, the error now names the actual
requirement instead of surfacing a bare "invalid reference format"
from three layers down.

Testing

  • Added a regression test (Docker repository validation context in
    pkg/installer/repository_test.go) reproducing the exact broken
    input from Can't create repository following documentation example with (--type docker) #360. It needs no Docker daemon, since the new validation
    runs before any Docker interaction.
  • go build ./..., go vet ./..., and gofmt -l are clean.
  • go.mod/go.sum diff is a single dependency promoted from indirect
    to direct — no new module added.
  • Confirmed the new spec passes; the pre-existing Lchown-related
    test failures in pkg/installer reproduce identically on unmodified
    master in this sandbox (no root/CAP_CHOWN) and are unrelated to
    this change.

Fixes #360

…arly

create-repo --type docker used the value passed via --output directly
as a Docker image reference without validating it first. Since the
generic create-repo example in the docs uses a filesystem path for
--output (correct for the disk/http repository types, but not for
docker), following that example with --type docker produced an
"invalid reference format" error deep inside a shelled-out `docker
load` call, one artifact at a time, with no indication of what was
actually wrong.

Validate the image prefix as a real docker reference before any file
walking or image building starts, using the reference-parsing package
already an indirect dependency of this module, and fail with an
actionable error naming the actual requirement.

Fixes mudler#360

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't create repository following documentation example with (--type docker)

1 participant