-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoptions.go
92 lines (80 loc) · 2.57 KB
/
options.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
package imo
import (
"io"
"github.com/containers/image/v5/copy"
"github.com/containers/image/v5/types"
)
// Option is a functional option for the Incremental type.
type Option func(*Incremental)
// WithReportWriter sets the report writer for the Incremental type. By default the
// report writer is io.Discard.
func WithReporterWriter(reporter io.Writer) Option {
return func(inc *Incremental) {
inc.report = reporter
}
}
// WithBaseAuth sets the authentication for the registry from where we are going to
// pull the "base" image. If we are comparing images v1 and v2 this is the auth for
// v1 registry.
func WithBaseAuth(user, pass string) Option {
return func(inc *Incremental) {
inc.auths.BaseAuth = &types.DockerAuthConfig{
Username: user,
Password: pass,
}
}
}
// WithPushAuth sets the authentication for the registry where we are going to push
// the incremental difference. If we have previously compared images v1 and v2 and
// we are going to push the difference to v3 this is the auth for v3 registry.
func WithPushAuth(user, pass string) Option {
return func(inc *Incremental) {
inc.auths.PushAuth = &types.DockerAuthConfig{
Username: user,
Password: pass,
}
}
}
// WithFinalAuth sets the authentication for the registry from where we are going to
// pull the "latest" image. If we are comparing images v1 and v2 this is the auth for
// v2 registry.
func WithFinalAuth(user, pass string) Option {
return func(inc *Incremental) {
inc.auths.FinalAuth = &types.DockerAuthConfig{
Username: user,
Password: pass,
}
}
}
// WithTempDir sets the temporary directory where we are going to store the diff while
// the user decides what to do with it. By default this is os.TempDir().
func WithTempDir(dir string) Option {
return func(inc *Incremental) {
inc.tmpdir = dir
}
}
// WithInsecurePull sets the pull operation to skip TLS verification.
func WithInsecurePull() Option {
return func(inc *Incremental) {
inc.insecurePull = types.OptionalBoolTrue
}
}
// WithInsecurePush sets the push operation to skip TLS verification.
func WithInsecurePush() Option {
return func(inc *Incremental) {
inc.insecurePush = types.OptionalBoolTrue
}
}
// WithInsecure sets both the pull and push operations to skip TLS verification.
func WithInsecure() Option {
return func(inc *Incremental) {
inc.insecurePull = types.OptionalBoolTrue
inc.insecurePush = types.OptionalBoolTrue
}
}
// WithAllArchitectures sets the selection to include all the architectures.
func WithAllArchitectures() Option {
return func(inc *Incremental) {
inc.selection = copy.CopyAllImages
}
}