Skip to content

Allow setting files media type with podman artifact add #25884

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
l0rd opened this issue Apr 15, 2025 · 3 comments · Fixed by #25909
Closed

Allow setting files media type with podman artifact add #25884

l0rd opened this issue Apr 15, 2025 · 3 comments · Fixed by #25909
Assignees
Labels
kind/feature Categorizes issue or PR as related to a new feature. triaged Issue has been triaged

Comments

@l0rd
Copy link
Member

l0rd commented Apr 15, 2025

Feature request description

The media type of artifacts files is derived from the first 512 bytes of the file using go standard library net/http#DetectContentType.

The media type can be incorrect and a source of error when the artifact gets pushed to an OCI container image registry.

Consider the following example:

# run Zot (https://zotregistry.dev) on localhost:5001
podman run -d -p "127.0.0.1:5001:5000" --name zot ghcr.io/project-zot/zot-minimal-linux-amd64:latest

# create hello.yaml and an artifact hello:latest
echo "foo: bar" > hello.yaml
podman artifact add localhost:5001/hello/hello:latest ./hello.yaml

# verify that the layer's media type is `text/plain; charset=utf-8`
podman artifact inspect localhost:5001/hello/hello:latest | jq '.Manifest.layers[].mediaType'

# push it to Zot
podman artifact push docker://localhost:5001/hello/hello:latest

Pushing the artifact returns an error:

Error: invalid reference format

The media type inferred by DetectContentType (text/plain; charset=utf-8) is the issue:

Suggest potential solution

To address these cases, podman artifact add should have a flag to specify the files' media types.

@l0rd l0rd added the kind/feature Categorizes issue or PR as related to a new feature. label Apr 15, 2025
@l0rd l0rd changed the title Allow setting media type with podman artifact add Allow setting files media type with podman artifact add Apr 15, 2025
@baude baude self-assigned this Apr 15, 2025
@baude baude added the triaged Issue has been triaged label Apr 15, 2025
@l0rd
Copy link
Member Author

l0rd commented Apr 15, 2025

cc @sabre1041

@l0rd
Copy link
Member Author

l0rd commented Apr 17, 2025

@nalind @baude would it make sense to set artifacts layer's Media Type to application/vnd.oci.image.layer.v1.tar by default rather than trying to guess the type with net/http#DetectContentType? That's what ORAS does anyway.

@baude
Copy link
Member

baude commented Apr 17, 2025

I would prefer the layers media type be descriptive. I have a PR coming and we can debate it I guess.

baude added a commit to baude/podman that referenced this issue Apr 17, 2025
in containers#25884, it was pointed out that the standard detection used to
determine the artifact's file type can be wrong.  in those cases, it
would be handy for the user to be able to override the media type of the
layer.  as such, added a new option called `--file-type`, which is
optional, and allows users to do just that.

`podman artifact add --file-type text/yaml
quay.io/artifact/config:latest ./config.yaml `

Fixes: containers#25884

Signed-off-by: Brent Baude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. triaged Issue has been triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants