mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Add plugin cleanup as part of standard TearDownTest.
Signed-off-by: Anusha Ragunathan <anusha@docker.com>
This commit is contained in:
parent
4f347e2db2
commit
3e85271a64
2 changed files with 35 additions and 0 deletions
|
@ -49,6 +49,7 @@ func (s *DockerSuite) TearDownTest(c *check.C) {
|
||||||
deleteAllImages()
|
deleteAllImages()
|
||||||
deleteAllVolumes()
|
deleteAllVolumes()
|
||||||
deleteAllNetworks()
|
deleteAllNetworks()
|
||||||
|
deleteAllPlugins()
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
|
@ -303,6 +303,40 @@ func getAllNetworks() ([]types.NetworkResource, error) {
|
||||||
return networks, nil
|
return networks, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func deleteAllPlugins() error {
|
||||||
|
plugins, err := getAllPlugins()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var errors []string
|
||||||
|
for _, p := range plugins {
|
||||||
|
status, b, err := sockRequest("DELETE", "/plugins/"+p.Name+":"+p.Tag+"?force=1", nil)
|
||||||
|
if err != nil {
|
||||||
|
errors = append(errors, err.Error())
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if status != http.StatusNoContent {
|
||||||
|
errors = append(errors, fmt.Sprintf("error deleting plugin %s: %s", p.Name, string(b)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(errors) > 0 {
|
||||||
|
return fmt.Errorf(strings.Join(errors, "\n"))
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func getAllPlugins() (types.PluginsListResponse, error) {
|
||||||
|
var plugins types.PluginsListResponse
|
||||||
|
_, b, err := sockRequest("GET", "/plugins", nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := json.Unmarshal(b, &plugins); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return plugins, nil
|
||||||
|
}
|
||||||
|
|
||||||
func deleteAllVolumes() error {
|
func deleteAllVolumes() error {
|
||||||
volumes, err := getAllVolumes()
|
volumes, err := getAllVolumes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue