fix(installer): reject invalid docker image references for --output early - #403
Open
chrisdebian wants to merge 1 commit into
Open
chrisdebian wants to merge 1 commit into
chrisdebian wants to merge 1 commit into
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
create-repo --type dockercurrently accepts whatever value is passedvia
--outputand uses it directly as a Docker image reference,without validating it first.
Why this breaks (#360)
The generic
create-repoexample in the docs uses a filesystem pathfor
--output:That's correct for the
disk/httprepository types. But the docsalso explain, a little further down, that the
dockerrepository typeneeds
--outputto be an actual docker image reference:It's easy to miss that distinction and combine the generic example
with
--type docker, which is exactly what #360 reports. The raw pathends 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 loadcall — oneartifact at a time, with an opaque
invalid reference formaterrorand no indication of what's actually wrong.
Fix
Validate
--outputas a real docker reference inLuetSystemRepository.getGenerator, before any file walking or imagebuilding starts, using
github.com/distribution/reference(alreadyan 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
Docker repository validationcontext inpkg/installer/repository_test.go) reproducing the exact brokeninput from Can't create repository following documentation example with (
--type docker) #360. It needs no Docker daemon, since the new validationruns before any Docker interaction.
go build ./...,go vet ./..., andgofmt -lare clean.go.mod/go.sumdiff is a single dependency promoted from indirectto direct — no new module added.
Lchown-relatedtest failures in
pkg/installerreproduce identically on unmodifiedmasterin this sandbox (no root/CAP_CHOWN) and are unrelated tothis change.
Fixes #360