1
0
Fork 0
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:
Anusha Ragunathan 2016-11-01 11:17:33 -07:00
parent 4f347e2db2
commit 3e85271a64
2 changed files with 35 additions and 0 deletions

View file

@ -49,6 +49,7 @@ func (s *DockerSuite) TearDownTest(c *check.C) {
deleteAllImages()
deleteAllVolumes()
deleteAllNetworks()
deleteAllPlugins()
}
func init() {

View file

@ -303,6 +303,40 @@ func getAllNetworks() ([]types.NetworkResource, error) {
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 {
volumes, err := getAllVolumes()
if err != nil {