MCPcopy
hub / github.com/slimtoolkit/slim / New

Function New

pkg/imagereader/imagereader.go:23–53  ·  view source on GitHub ↗
(imageName string)

Source from the content-addressed store, hash-verified

21}
22
23func New(imageName string) (*Instance, error) {
24 logger := log.WithFields(log.Fields{
25 "op": "imagereader.New",
26 "image.name": imageName,
27 })
28
29 logger.Trace("call")
30 defer logger.Trace("exit")
31
32 ref, err := name.ParseReference(imageName) //, name.WeakValidation)
33 if err != nil {
34 logger.WithError(err).Error("name.ParseReference")
35 return nil, err
36 }
37
38 //TODO/FUTURE: add other image source options (not just local Docker daemon)
39 //TODO/ASAP: need to pass the 'daemon' client otherwise it'll fail if the default client isn't enough
40 img, err := daemon.Image(ref)
41 if err != nil {
42 logger.WithError(err).Error("daemon.Image")
43 return nil, err
44 }
45
46 instance := &Instance{
47 imageName: imageName,
48 nameRef: ref,
49 imageRef: img,
50 }
51
52 return instance, nil
53}
54
55func (ref *Instance) ImageConfig() (*imagebuilder.ImageConfig, error) {
56 logger := log.WithFields(log.Fields{

Callers 1

OnCommandFunction · 0.92

Calls 1

ErrorMethod · 0.45

Tested by

no test coverage detected