mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #18369 from LK4D4/misleading_rm
daemon/delete.go: use less confusing naming of functions
This commit is contained in:
commit
f8364c013d
1 changed files with 34 additions and 28 deletions
|
@ -41,6 +41,23 @@ func (daemon *Daemon) ContainerRm(name string, config *ContainerRmConfig) error
|
|||
}
|
||||
|
||||
if config.RemoveLink {
|
||||
return daemon.rmLink(name)
|
||||
}
|
||||
|
||||
if err := daemon.cleanupContainer(container, config.ForceRemove); err != nil {
|
||||
// return derr.ErrorCodeCantDestroy.WithArgs(name, utils.GetErrorMessage(err))
|
||||
return err
|
||||
}
|
||||
|
||||
if err := daemon.removeMountPoints(container, config.RemoveVolume); err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// rmLink removes link by name from other containers
|
||||
func (daemon *Daemon) rmLink(name string) error {
|
||||
name, err := GetFullContainerName(name)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -68,20 +85,9 @@ func (daemon *Daemon) ContainerRm(name string, config *ContainerRmConfig) error
|
|||
return nil
|
||||
}
|
||||
|
||||
if err := daemon.rm(container, config.ForceRemove); err != nil {
|
||||
// return derr.ErrorCodeCantDestroy.WithArgs(name, utils.GetErrorMessage(err))
|
||||
return err
|
||||
}
|
||||
|
||||
if err := daemon.removeMountPoints(container, config.RemoveVolume); err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Destroy unregisters a container from the daemon and cleanly removes its contents from the filesystem.
|
||||
func (daemon *Daemon) rm(container *Container, forceRemove bool) (err error) {
|
||||
// cleanupContainer unregisters a container from the daemon, stops stats
|
||||
// collection and cleanly removes contents and metadata from the filesystem.
|
||||
func (daemon *Daemon) cleanupContainer(container *Container, forceRemove bool) (err error) {
|
||||
if container.IsRunning() {
|
||||
if !forceRemove {
|
||||
return derr.ErrorCodeRmRunning
|
||||
|
|
Loading…
Add table
Reference in a new issue