MCPcopy Index your code
hub / github.com/helm/helm / writeToFile

Function writeToFile

pkg/action/install.go:720–743  ·  view source on GitHub ↗

write the to / . controls if the file is created or content will be appended

(outputDir string, name string, data string, appendData bool)

Source from the content-addressed store, hash-verified

718
719// write the <data> to <output-dir>/<name>. <appendData> controls if the file is created or content will be appended
720func writeToFile(outputDir string, name string, data string, appendData bool) error {
721 outfileName := strings.Join([]string{outputDir, name}, string(filepath.Separator))
722
723 err := ensureDirectoryForFile(outfileName)
724 if err != nil {
725 return err
726 }
727
728 f, err := createOrOpenFile(outfileName, appendData)
729 if err != nil {
730 return err
731 }
732
733 defer f.Close()
734
735 _, err = fmt.Fprintf(f, "---\n# Source: %s\n%s\n", name, data)
736
737 if err != nil {
738 return err
739 }
740
741 fmt.Printf("wrote %s\n", outfileName)
742 return nil
743}
744
745func createOrOpenFile(filename string, appendData bool) (*os.File, error) {
746 if appendData {

Callers 1

renderResourcesMethod · 0.70

Calls 3

CloseMethod · 0.80
ensureDirectoryForFileFunction · 0.70
createOrOpenFileFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…