func getContainerInfoRequest(body io.ReadCloser) (*info.ContainerInfoRequest, error) { var query info.ContainerInfoRequest // Default stats and samples is 64. query.NumStats = 64 decoder := json.NewDecoder(body) err := decoder.Decode(&query) if err != nil && err != io.EOF { return nil, fmt.Errorf("unable to decode the json value: %s", err) } return &query, nil }
func getContainerInfo(client *client.Client, container string) (containerInfo info.ContainerInfo, err error) { query := info.ContainerInfoRequest{} query.NumStats = 1 cinfos, err := client.SubcontainersInfo("/", &query) if err != nil { return info.ContainerInfo{}, err } tempContainer := "/" + container for _, cinfo := range cinfos { if strings.HasSuffix(cinfo.Name, tempContainer) { return cinfo, nil } } return info.ContainerInfo{}, errors.New("not find container " + container) }
func GetAllContainer(client *client.Client) ([]info.ContainerInfo, error) { query := info.ContainerInfoRequest{} query.NumStats = 1 cinfos, err := client.SubcontainersInfo("/", &query) return cinfos, err }