Alpine base image and some dependencies upgraded
Details in the reweave CHANGELOG
This commit is contained in:
1 parent
1ceeca80e6
commit
0d58e17954
368 files changed
+23406
-9163
No files matched your search
+40
@@ -0,0 +1,40 @@
|
||||
package docker
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// TopResult represents the list of processes running in a container, as
|
||||
// returned by /containers/<id>/top.
|
||||
//
|
||||
// See https://goo.gl/FLwpPl for more details.
|
||||
type TopResult struct {
|
||||
Titles []string
|
||||
Processes [][]string
|
||||
}
|
||||
|
||||
// TopContainer returns processes running inside a container
|
||||
//
|
||||
// See https://goo.gl/FLwpPl for more details.
|
||||
func (c *Client) TopContainer(id string, psArgs string) (TopResult, error) {
|
||||
var args string
|
||||
var result TopResult
|
||||
if psArgs != "" {
|
||||
args = fmt.Sprintf("?ps_args=%s", psArgs)
|
||||
}
|
||||
path := fmt.Sprintf("/containers/%s/top%s", id, args)
|
||||
resp, err := c.do(http.MethodGet, path, doOptions{})
|
||||
if err != nil {
|
||||
var e *Error
|
||||
if errors.As(err, &e) && e.Status == http.StatusNotFound {
|
||||
return result, &NoSuchContainer{ID: id}
|
||||
}
|
||||
return result, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
err = json.NewDecoder(resp.Body).Decode(&result)
|
||||
return result, err
|
||||
}
|
||||
Reference in new issue
Block a user