diff --git a/integration-cli/check_test.go b/integration-cli/check_test.go index a2e74173e0..81f458f5ae 100644 --- a/integration-cli/check_test.go +++ b/integration-cli/check_test.go @@ -49,6 +49,7 @@ func (s *DockerSuite) TearDownTest(c *check.C) { deleteAllImages() deleteAllVolumes() deleteAllNetworks() + deleteAllPlugins() } func init() { diff --git a/integration-cli/docker_utils.go b/integration-cli/docker_utils.go index 91dc88647b..4e1c2bca17 100644 --- a/integration-cli/docker_utils.go +++ b/integration-cli/docker_utils.go @@ -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 {