MCPcopy Create free account
hub / github.com/coder/envbuilder / writeMagicImageFile

Function writeMagicImageFile

envbuilder.go:1656–1670  ·  view source on GitHub ↗
(fs billy.Filesystem, path string, v any)

Source from the content-addressed store, hash-verified

1654}
1655
1656func writeMagicImageFile(fs billy.Filesystem, path string, v any) error {
1657 file, err := fs.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o644)
1658 if err != nil {
1659 return fmt.Errorf("create magic image file: %w", err)
1660 }
1661 defer file.Close()
1662
1663 enc := json.NewEncoder(file)
1664 enc.SetIndent("", " ")
1665 if err := enc.Encode(v); err != nil {
1666 return fmt.Errorf("encode magic image file: %w", err)
1667 }
1668
1669 return nil
1670}
1671
1672func parseMagicImageFile(fs billy.Filesystem, path string, v any) error {
1673 file, err := fs.Open(path)

Callers 2

runFunction · 0.85
RunCacheProbeFunction · 0.85

Calls 2

CloseMethod · 0.80
OpenFileMethod · 0.65

Tested by

no test coverage detected