MCPcopy Create free account
hub / github.com/linuxkit/linuxkit / Config

Method Config

src/cmd/linuxkit/cache/imagesource.go:58–78  ·  view source on GitHub ↗

Config return the imagespec.ImageConfig for the given source. Resolves to the architecture, if necessary.

()

Source from the content-addressed store, hash-verified

56// Config return the imagespec.ImageConfig for the given source. Resolves to the
57// architecture, if necessary.
58func (c ImageSource) Config() (imagespec.ImageConfig, error) {
59 imageName := c.ref.String()
60 image, err := c.provider.findImage(imageName, *c.platform)
61 if err != nil {
62 return imagespec.ImageConfig{}, err
63 }
64
65 configFile, err := image.ConfigFile()
66 if err != nil {
67 return imagespec.ImageConfig{}, fmt.Errorf("unable to get image OCI ConfigFile: %v", err)
68 }
69 // because the other parts expect OCI go-spec structs, not google/go-containerregistry structs,
70 // the easiest way to do this is to convert via json
71 configJSON, err := json.Marshal(configFile.Config)
72 if err != nil {
73 return imagespec.ImageConfig{}, fmt.Errorf("unable to convert image config to json: %v", err)
74 }
75 var ociConfig imagespec.ImageConfig
76 err = json.Unmarshal(configJSON, &ociConfig)
77 return ociConfig, err
78}
79
80// TarReader return an io.ReadCloser to read the filesystem contents of the image,
81// as resolved to the provided architecture.

Callers

nothing calls this directly

Calls 2

findImageMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected