MCPcopy Create free account
hub / github.com/cloudquery/cloudquery / persistSummary

Function persistSummary

cli/cmd/summary.go:47–66  ·  view source on GitHub ↗
(filename string, summary syncSummary)

Source from the content-addressed store, hash-verified

45}
46
47func persistSummary(filename string, summary syncSummary) error {
48 // if filename is not specified then we don't need to persist the summary and can return
49 if filename == "" {
50 return nil
51 }
52 err := checkFilePath(filename)
53 if err != nil {
54 return fmt.Errorf("failed to validate summary file path: %w", err)
55 }
56 dataBytes, err := json.Marshal(summary)
57 if err != nil {
58 return err
59 }
60 dataBytes = append(dataBytes, []byte("\n")...)
61 err = appendToFile(filename, dataBytes)
62 if err != nil {
63 return fmt.Errorf("failed to append summary to file: %w", err)
64 }
65 return nil
66}
67
68func appendToFile(fileName string, data []byte) error {
69 f, err := os.OpenFile(fileName, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)

Callers 1

syncConnectionV3Function · 0.85

Calls 3

checkFilePathFunction · 0.85
appendToFileFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected