...
1 package internal
2
3 import (
4 "fmt"
5 "os"
6 "path/filepath"
7
8 "github.com/google/go-containerregistry/pkg/name"
9
10 "edge-infra.dev/pkg/f8n/warehouse/oci"
11 "edge-infra.dev/pkg/f8n/warehouse/oci/layout"
12 "edge-infra.dev/pkg/f8n/warehouse/oci/remote"
13 )
14
15
16
17
18 func ResolveArtifact(p *Packer, s string) (oci.Artifact, error) {
19
20 if _, err := os.Stat(filepath.Join(p.Config.WAREHOUSEPATH, s)); err == nil {
21 return p.Pack(s)
22 }
23
24
25
26 ref, err := name.ParseReference(s, name.StrictValidation)
27 if err == nil {
28 return remote.Get(ref)
29 }
30
31
32 tag, err := name.NewTag(s)
33 if err == nil {
34 l, err := layout.New(p.Config.Cache)
35 if err != nil {
36 return nil, err
37 }
38 return l.Get(tag)
39 }
40
41 return nil, fmt.Errorf("unable to resolve reference %s in local warehouse "+
42 "or remote registry", s)
43 }
44
View as plain text