MCPcopy Create free account
hub / github.com/cli/cli / Create

Method Create

pkg/cmd/run/view/view.go:50–67  ·  view source on GitHub ↗
(key string, content io.Reader)

Source from the content-addressed store, hash-verified

48}
49
50func (c RunLogCache) Create(key string, content io.Reader) error {
51 if err := os.MkdirAll(c.cacheDir, 0755); err != nil {
52 return fmt.Errorf("creating cache directory: %v", err)
53 }
54
55 out, err := os.Create(c.filepath(key))
56 if err != nil {
57 return fmt.Errorf("creating cache entry: %v", err)
58 }
59 defer out.Close()
60
61 if _, err := io.Copy(out, content); err != nil {
62 return fmt.Errorf("writing cache entry: %v", err)
63
64 }
65
66 return nil
67}
68
69func (c RunLogCache) Open(key string) (*zip.ReadCloser, error) {
70 r, err := zip.OpenReader(c.filepath(key))

Callers 1

TestRunLogFunction · 0.95

Calls 6

filepathMethod · 0.95
MkdirAllMethod · 0.80
ErrorfMethod · 0.65
CreateMethod · 0.65
CloseMethod · 0.65
CopyMethod · 0.45

Tested by 1

TestRunLogFunction · 0.76