/
default.go
75 lines (58 loc) · 2.39 KB
/
default.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
package docker_registry
import (
"context"
"fmt"
"strings"
"github.com/werf/logboek"
"github.com/werf/werf/pkg/image"
)
const DefaultImplementationName = "default"
type defaultImplementation struct {
*api
Implementation string
}
type defaultImplementationOptions struct {
apiOptions
}
func newDefaultImplementation(options defaultImplementationOptions) (*defaultImplementation, error) {
return newDefaultAPIForImplementation(DefaultImplementationName, options)
}
func newDefaultAPIForImplementation(implementation string, options defaultImplementationOptions) (*defaultImplementation, error) {
d := &defaultImplementation{}
d.api = newAPI(options.apiOptions)
d.Implementation = implementation
return d, nil
}
func (r *defaultImplementation) Tags(ctx context.Context, reference string, _ ...Option) ([]string, error) {
tags, err := r.api.Tags(ctx, reference)
if err != nil {
if IsQuayTagExpiredErr(err) && r.Implementation != QuayImplementationName {
logboek.Context(ctx).Error().LogF("WARNING: Detected error specific for quay container registry implementation!\n")
logboek.Context(ctx).Error().LogF("WARNING: Use --repo-container-registry=quay option (or WERF_CONTAINER_REGISTRY env var)\n")
logboek.Context(ctx).Error().LogF("WARNING: to instruct werf to use quay driver.\n")
}
return []string{}, err
}
return tags, nil
}
func (r *defaultImplementation) IsTagExist(_ context.Context, _ string, _ ...Option) (bool, error) {
panic("not implemented")
}
func (r *defaultImplementation) TryGetRepoImage(ctx context.Context, reference string) (*image.Info, error) {
return r.tryGetRepoImage(ctx, reference, r.Implementation)
}
func (r *defaultImplementation) CreateRepo(_ context.Context, _ string) error {
return fmt.Errorf("method is not implemented")
}
func (r *defaultImplementation) DeleteRepo(_ context.Context, _ string) error {
return fmt.Errorf("method is not implemented")
}
func (r *defaultImplementation) TagRepoImage(ctx context.Context, repoImage *image.Info, tag string) error {
return r.api.tagImage(ctx, strings.Join([]string{repoImage.Repository, repoImage.Tag}, ":"), tag)
}
func (r *defaultImplementation) DeleteRepoImage(ctx context.Context, repoImage *image.Info) error {
return r.api.deleteImageByReference(ctx, strings.Join([]string{repoImage.Repository, repoImage.RepoDigest}, "@"))
}
func (r *defaultImplementation) String() string {
return DefaultImplementationName
}