-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathstorage.go
40 lines (35 loc) · 1.44 KB
/
storage.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
package registry
import (
"context"
"crypto/x509"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
orasregistry "oras.land/oras-go/v2/registry"
)
// StorageContext describes aspects of a registry.
type StorageContext struct {
host string
project string
credentialStore *CredentialStore
certificates *x509.CertPool
insecure bool
}
// NewStorageContext create registry context.
func NewStorageContext(host string, credentialStore *CredentialStore, certificates *x509.CertPool, insecure bool) StorageContext {
return StorageContext{
host: host,
credentialStore: credentialStore,
certificates: certificates,
insecure: insecure,
}
}
// StorageClient interface for general image storage client.
type StorageClient interface {
Init() error
Resolve(ctx context.Context, srcStorage orasregistry.Repository, versionedImage string) (desc ocispec.Descriptor, err error)
GetStorage(ctx context.Context, image Artifact) (repo orasregistry.Repository, err error)
SetProject(project string)
Destination(image Artifact) string
FetchBytes(ctx context.Context, srcStorage orasregistry.Repository, artifact Artifact) (ocispec.Descriptor, []byte, error)
FetchBlob(ctx context.Context, srcStorage orasregistry.Repository, descriptor ocispec.Descriptor) ([]byte, error)
CopyGraph(ctx context.Context, srcStorage orasregistry.Repository, dstStorage orasregistry.Repository, desc ocispec.Descriptor) error
}