mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #27960 from anusha-ragunathan/plugin_teardown
Add plugin cleanup as part of standard TearDownTest.
This commit is contained in:
commit
0aefcd6ab6
2 changed files with 35 additions and 0 deletions
|
@ -49,6 +49,7 @@ func (s *DockerSuite) TearDownTest(c *check.C) {
|
|||
deleteAllImages()
|
||||
deleteAllVolumes()
|
||||
deleteAllNetworks()
|
||||
deleteAllPlugins()
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue