...
1 package cache
2
3 import (
4 "github.com/google/go-containerregistry/pkg/v1/remote"
5 )
6
7
8 type Option = func(*options)
9
10 type options struct {
11 memoryCacheSize int
12 recorder Recorder
13 puller *remote.Puller
14 }
15
16 func WithMemoryCacheSize(limit int) Option {
17 return func(o *options) {
18 o.memoryCacheSize = limit
19 }
20 }
21
22
23
24
25 func WithPuller(p *remote.Puller) Option {
26 return func(o *options) {
27 o.puller = p
28 }
29 }
30
31 func WithRecorder(r Recorder) Option {
32 return func(o *options) {
33 o.recorder = r
34 }
35 }
36
37 func makeOptions(opts ...Option) options {
38 o := options{}
39 for _, opt := range opts {
40 opt(&o)
41 }
42 return o
43 }
44
45
46 type GetOption = func(*getOptions)
47
48 type getOptions struct {
49 remoteOpts []remote.Option
50 resolveTag bool
51 }
52
53
54 func WithRemoteOpts(opts ...remote.Option) GetOption {
55 return func(o *getOptions) {
56 if len(opts) > 0 {
57 o.remoteOpts = opts
58 }
59 }
60 }
61
62
63
64 func ResolveTag() GetOption {
65 return func(o *getOptions) {
66 o.resolveTag = true
67 }
68 }
69
70 func makeGetOptions(opts ...GetOption) getOptions {
71 o := getOptions{}
72 for _, opt := range opts {
73 opt(&o)
74 }
75 return o
76 }
77
View as plain text