MCPcopy
hub / github.com/docker/docker-agent / writeTempFile

Function writeTempFile

pkg/tools/mcp/gateway.go:104–122  ·  view source on GitHub ↗
(nameTemplate string, content []byte)

Source from the content-addressed store, hash-verified

102}
103
104func writeTempFile(nameTemplate string, content []byte) (string, error) {
105 f, err := os.CreateTemp("", nameTemplate)
106 if err != nil {
107 return "", fmt.Errorf("creating temp file: %w", err)
108 }
109
110 if _, err := f.Write(content); err != nil {
111 f.Close()
112 os.Remove(f.Name())
113 return "", err
114 }
115
116 if err := f.Close(); err != nil {
117 os.Remove(f.Name())
118 return "", err
119 }
120
121 return f.Name(), nil
122}

Callers 2

writeSecretsToFileFunction · 0.70
writeConfigToFileFunction · 0.70

Calls 4

CloseMethod · 0.65
NameMethod · 0.65
WriteMethod · 0.45
RemoveMethod · 0.45

Tested by

no test coverage detected