-
Notifications
You must be signed in to change notification settings - Fork 199
/
default.go
57 lines (43 loc) · 1.52 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
package docker_registry
import (
"context"
"fmt"
"strings"
"github.com/werf/werf/pkg/image"
)
const DefaultImplementationName = "default"
type defaultImplementation struct {
*api
}
type defaultImplementationOptions struct {
apiOptions
}
func newDefaultImplementation(options defaultImplementationOptions) (*defaultImplementation, error) {
d := &defaultImplementation{}
d.api = newAPI(options.apiOptions)
return d, nil
}
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(_ context.Context, repoImage *image.Info, tag string) error {
return r.api.tagImage(strings.Join([]string{repoImage.Repository, repoImage.Tag}, ":"), tag)
}
func (r *defaultImplementation) DeleteRepoImage(_ context.Context, repoImage *image.Info) error {
return r.api.deleteImageByReference(strings.Join([]string{repoImage.Repository, repoImage.RepoDigest}, "@"))
}
func (r *defaultImplementation) String() string {
return DefaultImplementationName
}
func IsManifestUnknownError(err error) bool {
return (err != nil) && strings.Contains(err.Error(), "MANIFEST_UNKNOWN")
}
func IsBlobUnknownError(err error) bool {
return (err != nil) && strings.Contains(err.Error(), "BLOB_UNKNOWN")
}
func IsNameUnknownError(err error) bool {
return (err != nil) && strings.Contains(err.Error(), "NAME_UNKNOWN")
}