forked from aquasecurity/fanal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdaemon.go
38 lines (30 loc) · 916 Bytes
/
daemon.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
package image
import (
"github.com/aquasecurity/fanal/image/daemon"
"github.com/docker/docker/api/types"
"github.com/google/go-containerregistry/pkg/name"
v1 "github.com/google/go-containerregistry/pkg/v1"
)
func tryDockerDaemon(ref name.Reference) (v1.Image, extender, func(), error) {
img, inspect, cleanup, err := daemon.DockerImage(ref)
if err != nil {
return nil, nil, nil, err
}
return img, daemonExtender{inspect: inspect}, cleanup, nil
}
func tryPodmanDaemon(ref string) (v1.Image, extender, func(), error) {
img, inspect, cleanup, err := daemon.PodmanImage(ref)
if err != nil {
return nil, nil, nil, err
}
return img, daemonExtender{inspect: inspect}, cleanup, nil
}
type daemonExtender struct {
inspect *types.ImageInspect
}
func (e daemonExtender) RepoTags() []string {
return e.inspect.RepoTags
}
func (e daemonExtender) RepoDigests() []string {
return e.inspect.RepoDigests
}