-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathoptions.go
64 lines (51 loc) · 1.89 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
package remote
import (
"time"
v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/buildpacks/imgutil"
)
// AddEmptyLayerOnSave adds an empty layer before saving if the image has no layers at all.
// This option is useful when exporting to registries that do not allow saving an image without layers,
// for example: gcr.io.
func AddEmptyLayerOnSave() func(*imgutil.ImageOptions) {
return func(o *imgutil.ImageOptions) {
o.AddEmptyLayerOnSave = true
}
}
// WithRegistrySetting registers options to use when accessing images in a registry
// in order to construct the image.
// The referenced images could include the base image, a previous image, or the image itself.
// The insecure parameter allows image references to be fetched without TLS.
func WithRegistrySetting(repository string, insecure bool) func(*imgutil.ImageOptions) {
return func(o *imgutil.ImageOptions) {
if o.RegistrySettings == nil {
o.RegistrySettings = make(map[string]imgutil.RegistrySetting)
}
o.RegistrySettings[repository] = imgutil.RegistrySetting{
Insecure: insecure,
}
}
}
// FIXME: the following functions are defined in this package for backwards compatibility,
// and should eventually be deprecated.
func FromBaseImage(name string) func(*imgutil.ImageOptions) {
return imgutil.FromBaseImage(name)
}
func WithConfig(c *v1.Config) func(*imgutil.ImageOptions) {
return imgutil.WithConfig(c)
}
func WithCreatedAt(t time.Time) func(*imgutil.ImageOptions) {
return imgutil.WithCreatedAt(t)
}
func WithDefaultPlatform(p imgutil.Platform) func(*imgutil.ImageOptions) {
return imgutil.WithDefaultPlatform(p)
}
func WithHistory() func(*imgutil.ImageOptions) {
return imgutil.WithHistory()
}
func WithMediaTypes(m imgutil.MediaTypes) func(*imgutil.ImageOptions) {
return imgutil.WithMediaTypes(m)
}
func WithPreviousImage(name string) func(*imgutil.ImageOptions) {
return imgutil.WithPreviousImage(name)
}