-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtrust.go
226 lines (191 loc) · 3.95 KB
/
trust.go
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
// Code generated by lesiw.io/ctrctl. DO NOT EDIT.
package ctrctl
import (
"fmt"
"os/exec"
)
type TrustInspectOpts struct {
// Base exec.Cmd.
Cmd *exec.Cmd
// Print usage.
Help bool
// Print the information in a human friendly format.
Pretty bool
}
// Return low-level information about keys and signatures.
func TrustInspect(opts *TrustInspectOpts, imageTag ...string) (string, error) {
if err := findCli(); err != nil {
return "", err
}
if len(imageTag) == 0 {
return "", fmt.Errorf("imageTag must have at least one value")
}
return runCtrCmd(
[]string{"trust", "inspect"},
imageTag,
opts,
-1,
)
}
type TrustKeyOpts struct {
// Base exec.Cmd.
Cmd *exec.Cmd
// Print usage.
Help bool
}
// Manage keys for signing Docker images.
func TrustKey(opts *TrustKeyOpts) (string, error) {
if err := findCli(); err != nil {
return "", err
}
return runCtrCmd(
[]string{"trust", "key"},
[]string{},
opts,
-1,
)
}
type TrustKeyGenerateOpts struct {
// Base exec.Cmd.
Cmd *exec.Cmd
// Directory to generate key in, defaults to current directory.
Dir string
// Print usage.
Help bool
}
// Generate and load a signing key-pair.
func TrustKeyGenerate(opts *TrustKeyGenerateOpts, name string) (string, error) {
if err := findCli(); err != nil {
return "", err
}
return runCtrCmd(
[]string{"trust", "key", "generate"},
[]string{name},
opts,
-1,
)
}
type TrustKeyLoadOpts struct {
// Base exec.Cmd.
Cmd *exec.Cmd
// Print usage.
Help bool
// Name for the loaded key.
Name string
}
// Load a private key file for signing.
func TrustKeyLoad(opts *TrustKeyLoadOpts, keyfile string) (string, error) {
if err := findCli(); err != nil {
return "", err
}
return runCtrCmd(
[]string{"trust", "key", "load"},
[]string{keyfile},
opts,
0,
)
}
type TrustRevokeOpts struct {
// Base exec.Cmd.
Cmd *exec.Cmd
// Print usage.
Help bool
// Do not prompt for confirmation.
Yes bool
}
// Remove trust for an image.
func TrustRevoke(opts *TrustRevokeOpts, imageTag string) (string, error) {
if err := findCli(); err != nil {
return "", err
}
return runCtrCmd(
[]string{"trust", "revoke"},
[]string{imageTag},
opts,
0,
)
}
type TrustSignOpts struct {
// Base exec.Cmd.
Cmd *exec.Cmd
// Print usage.
Help bool
// Sign a locally tagged image.
Local bool
}
// Sign an image.
func TrustSign(opts *TrustSignOpts, imageTag string) (string, error) {
if err := findCli(); err != nil {
return "", err
}
return runCtrCmd(
[]string{"trust", "sign"},
[]string{imageTag},
opts,
-1,
)
}
type TrustSignerOpts struct {
// Base exec.Cmd.
Cmd *exec.Cmd
// Print usage.
Help bool
}
// Manage entities who can sign Docker images.
func TrustSigner(opts *TrustSignerOpts) (string, error) {
if err := findCli(); err != nil {
return "", err
}
return runCtrCmd(
[]string{"trust", "signer"},
[]string{},
opts,
-1,
)
}
type TrustSignerAddOpts struct {
// Base exec.Cmd.
Cmd *exec.Cmd
// Print usage.
Help bool
// Path to the signer's public key file.
Key []string
}
// Add a signer.
func TrustSignerAdd(opts *TrustSignerAddOpts, name string, repository ...string) (string, error) {
if err := findCli(); err != nil {
return "", err
}
if len(repository) == 0 {
return "", fmt.Errorf("repository must have at least one value")
}
return runCtrCmd(
[]string{"trust", "signer", "add"},
append([]string{name}, repository...),
opts,
0,
)
}
type TrustSignerRemoveOpts struct {
// Base exec.Cmd.
Cmd *exec.Cmd
// Do not prompt for confirmation before removing the most recent signer.
Force bool
// Print usage.
Help bool
}
// Remove a signer.
func TrustSignerRemove(opts *TrustSignerRemoveOpts, name string, repository ...string) (string, error) {
if err := findCli(); err != nil {
return "", err
}
if len(repository) == 0 {
return "", fmt.Errorf("repository must have at least one value")
}
return runCtrCmd(
[]string{"trust", "signer", "remove"},
append([]string{name}, repository...),
opts,
0,
)
}