MCPcopy
hub / github.com/docker/compose / writeEnvFile

Function writeEnvFile

pkg/remote/oci.go:260–275  ·  pkg/remote/oci.go::writeEnvFile
(layer spec.Descriptor, local string, content []byte)

Source from the content-addressed store, hash-verified

258}
259
260func writeEnvFile(layer spec.Descriptor, local string, content []byte) error {
261 envfilePath, ok := layer.Annotations["com.docker.compose.envfile"]
262 if !ok {
263 return fmt.Errorf("missing annotation com.docker.compose.envfile in layer %q", layer.Digest)
264 }
265 if err := validatePathInBase(local, envfilePath); err != nil {
266 return err
267 }
268 otherFile, err := os.Create(filepath.Join(local, envfilePath))
269 if err != nil {
270 return err
271 }
272 defer func() { _ = otherFile.Close() }()
273 _, err = otherFile.Write(content)
274 return err
275}
276
277var _ loader.ResourceLoader = (*ociRemoteLoader)(nil)

Callers 1

pullComposeFilesMethod · 0.85

Calls 4

validatePathInBaseFunction · 0.85
CreateMethod · 0.65
CloseMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected