Skip to content

commit: Add an option to nerdctl commit command for media type selection #4330

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ChengyuZhu6
Copy link

Fixes: #4329

@@ -43,6 +44,7 @@ func CommitCommand() *cobra.Command {
cmd.Flags().StringArrayP("change", "c", nil, "Apply Dockerfile instruction to the created image (supported directives: [CMD, ENTRYPOINT])")
cmd.Flags().BoolP("pause", "p", true, "Pause container during commit")
cmd.Flags().StringP("compression", "", "gzip", "commit compression algorithm (zstd or gzip)")
cmd.Flags().String("format", "docker", "Format of the committed image (docker or oci)")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -32,6 +32,7 @@ func CommitCommand() *cobra.Command {
var cmd = &cobra.Command{
Use: "commit [flags] CONTAINER REPOSITORY[:TAG]",
Short: "Create a new image from a container's changes",
Long: "Create a new image from a container's changes. Use --format to choose between docker (default) or oci image format.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This explanation seems redundant.
Already covered in the help message of --format.

@@ -385,6 +385,8 @@ type ContainerCommitOptions struct {
Pause bool
// Compression is set commit compression algorithm
Compression CompressionType
// MediaType format of the committed image (docker or oci)
MediaType MediaTypeFormat
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the OCI lingo, "MediaType" means strings like application/vnd.oci.image.index.v1+json

https://specs.opencontainers.org/image-spec/media-types/

var mediaType string

// Select media type based on format and compression
if opts.MediaType == types.MediaTypeOCI {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use switch {} for readability

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.

Add an option to nerdctl commit command for media type selection
2 participants