-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add podman rm --depend #12694
Add podman rm --depend #12694
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ func RemoveContainer(w http.ResponseWriter, r *http.Request) { | |
query := struct { | ||
Force bool `schema:"force"` | ||
Ignore bool `schema:"ignore"` | ||
Depend bool `schema:"depend"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we want this in the compat API, the return type won't make it clear that multiple containers were removed. Having it only in the fancy version that can already to multiple containers seems better? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is only handled in libpod not in compat. |
||
Link bool `schema:"link"` | ||
Timeout *uint `schema:"timeout"` | ||
DockerVolumes bool `schema:"v"` | ||
|
@@ -57,6 +58,7 @@ func RemoveContainer(w http.ResponseWriter, r *http.Request) { | |
if utils.IsLibpodRequest(r) { | ||
options.Volumes = query.LibpodVolumes | ||
options.Timeout = query.Timeout | ||
options.Depend = query.Depend | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this handle returns properly? As in, if we remove >1 container, we tell the server that? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it should return all of the containers. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a test to verify. |
||
} else { | ||
if query.Link { | ||
utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest, | ||
|
@@ -71,7 +73,7 @@ func RemoveContainer(w http.ResponseWriter, r *http.Request) { | |
// code. | ||
containerEngine := abi.ContainerEngine{Libpod: runtime} | ||
name := utils.GetName(r) | ||
report, err := containerEngine.ContainerRm(r.Context(), []string{name}, options) | ||
reports, err := containerEngine.ContainerRm(r.Context(), []string{name}, options) | ||
if err != nil { | ||
if errors.Cause(err) == define.ErrNoSuchCtr { | ||
utils.ContainerNotFound(w, name, err) | ||
|
@@ -81,16 +83,19 @@ func RemoveContainer(w http.ResponseWriter, r *http.Request) { | |
utils.InternalServerError(w, err) | ||
return | ||
} | ||
if len(report) > 0 && report[0].Err != nil { | ||
err = report[0].Err | ||
if len(reports) > 0 && reports[0].Err != nil { | ||
err = reports[0].Err | ||
if errors.Cause(err) == define.ErrNoSuchCtr { | ||
utils.ContainerNotFound(w, name, err) | ||
return | ||
} | ||
utils.InternalServerError(w, err) | ||
return | ||
} | ||
|
||
if utils.IsLibpodRequest(r) { | ||
utils.WriteResponse(w, http.StatusOK, reports) | ||
return | ||
} | ||
utils.WriteResponse(w, http.StatusNoContent, nil) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,6 +138,7 @@ type PruneOptions struct { | |
//go:generate go run ../generator/generator.go RemoveOptions | ||
// RemoveOptions are optional options for removing containers | ||
type RemoveOptions struct { | ||
Depend *bool | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also needs changes for the handlers and swagger. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
Ignore *bool | ||
Force *bool | ||
Volumes *bool | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Does this print every container that was removed? I got a little concerned because there are no changes to cmd/podman
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.
Yes, the container is added to the reports list when being removed in the API. The Podman client just walks the list.
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.
Added a test to verify.