1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
package secrets
import (
"context"
"io"
"net/http"
"github.com/containers/podman/v3/pkg/bindings"
"github.com/containers/podman/v3/pkg/domain/entities"
)
// List returns information about existing secrets in the form of a slice.
func List(ctx context.Context, options *ListOptions) ([]*entities.SecretInfoReport, error) {
var (
secrs []*entities.SecretInfoReport
)
conn, err := bindings.GetClient(ctx)
if err != nil {
return nil, err
}
params, err := options.ToParams()
if err != nil {
return nil, err
}
response, err := conn.DoRequest(ctx, nil, http.MethodGet, "/secrets/json", params, nil)
if err != nil {
return secrs, err
}
defer response.Body.Close()
return secrs, response.Process(&secrs)
}
// Inspect returns low-level information about a secret.
func Inspect(ctx context.Context, nameOrID string, options *InspectOptions) (*entities.SecretInfoReport, error) {
var (
inspect *entities.SecretInfoReport
)
conn, err := bindings.GetClient(ctx)
if err != nil {
return nil, err
}
response, err := conn.DoRequest(ctx, nil, http.MethodGet, "/secrets/%s/json", nil, nil, nameOrID)
if err != nil {
return inspect, err
}
defer response.Body.Close()
return inspect, response.Process(&inspect)
}
// Remove removes a secret from storage
func Remove(ctx context.Context, nameOrID string) error {
conn, err := bindings.GetClient(ctx)
if err != nil {
return err
}
response, err := conn.DoRequest(ctx, nil, http.MethodDelete, "/secrets/%s", nil, nil, nameOrID)
if err != nil {
return err
}
defer response.Body.Close()
return response.Process(nil)
}
// Create creates a secret given some data
func Create(ctx context.Context, reader io.Reader, options *CreateOptions) (*entities.SecretCreateReport, error) {
var (
create *entities.SecretCreateReport
)
conn, err := bindings.GetClient(ctx)
if err != nil {
return nil, err
}
params, err := options.ToParams()
if err != nil {
return nil, err
}
response, err := conn.DoRequest(ctx, reader, http.MethodPost, "/secrets/create", params, nil)
if err != nil {
return nil, err
}
defer response.Body.Close()
return create, response.Process(&create)
}
|