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

Method ExportFilesystem

pkg/imagereader/imagereader.go:135–166  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

133}
134
135func (ref *Instance) ExportFilesystem() (string, error) {
136 logger := log.WithFields(log.Fields{
137 "op": "imagereader.Instance.ExportFilesystem",
138 "image.name": ref.imageName,
139 })
140
141 logger.Trace("call")
142 defer logger.Trace("exit")
143
144 if ref.exportedTarPath != "" {
145 return ref.exportedTarPath, nil
146 }
147
148 tarFile, err := os.CreateTemp("", "image-exported-fs-*.tar")
149 if err != nil {
150 return "", err
151 }
152
153 defer tarFile.Close()
154
155 err = crane.Export(ref.imageRef, tarFile)
156 if err != nil {
157 return "", err
158 }
159
160 if _, err := os.Stat(tarFile.Name()); err != nil {
161 return "", err
162 }
163
164 ref.exportedTarPath = tarFile.Name()
165 return ref.exportedTarPath, nil
166}
167
168func (ref *Instance) ExportedTarPath() string {
169 return ref.exportedTarPath

Callers 1

OnCommandFunction · 0.80

Calls 2

CloseMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected