-
Notifications
You must be signed in to change notification settings - Fork 662
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
base: main
Are you sure you want to change the base?
Conversation
Fixes: containerd#4329 Signed-off-by: ChengyuZhu6 <hudson@cyzhu.com>
@@ -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)") |
There was a problem hiding this comment.
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.", |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
var mediaType string | ||
|
||
// Select media type based on format and compression | ||
if opts.MediaType == types.MediaTypeOCI { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use switch {}
for readability
Fixes: #4329