podman

Форк
0
37 строк · 912.0 Байт
1
package docker
2

3
import (
4
	"context"
5
	"encoding/json"
6
	"net/http"
7
)
8

9
// ListContainersOptions specify parameters to the ListContainers function.
10
//
11
// See https://goo.gl/kaOHGw for more details.
12
type ListContainersOptions struct {
13
	All     bool
14
	Size    bool
15
	Limit   int
16
	Since   string
17
	Before  string
18
	Filters map[string][]string
19
	Context context.Context
20
}
21

22
// ListContainers returns a slice of containers matching the given criteria.
23
//
24
// See https://goo.gl/kaOHGw for more details.
25
func (c *Client) ListContainers(opts ListContainersOptions) ([]APIContainers, error) {
26
	path := "/containers/json?" + queryString(opts)
27
	resp, err := c.do(http.MethodGet, path, doOptions{context: opts.Context})
28
	if err != nil {
29
		return nil, err
30
	}
31
	defer resp.Body.Close()
32
	var containers []APIContainers
33
	if err := json.NewDecoder(resp.Body).Decode(&containers); err != nil {
34
		return nil, err
35
	}
36
	return containers, nil
37
}
38

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.