MCPcopy Create free account
hub / github.com/cloudfoundry/bosh-agent / Run

Method Run

agent/script/generic_script.go:57–96  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

55func (s GenericScript) Exists() bool { return s.fs.FileExists(s.path) }
56
57func (s GenericScript) Run() error {
58 err := s.ensureContainingDir(s.stdoutLogPath)
59 if err != nil {
60 return err
61 }
62
63 err = s.ensureContainingDir(s.stderrLogPath)
64 if err != nil {
65 return err
66 }
67
68 stdoutFile, err := s.fs.OpenFile(s.stdoutLogPath, fileOpenFlag, fileOpenPerm)
69 if err != nil {
70 return err
71 }
72 defer func() {
73 _ = stdoutFile.Close() //nolint:errcheck
74 }()
75
76 stderrFile, err := s.fs.OpenFile(s.stderrLogPath, fileOpenFlag, fileOpenPerm)
77 if err != nil {
78 return err
79 }
80 defer func() {
81 _ = stderrFile.Close() //nolint:errcheck
82 }()
83
84 command := cmd.BuildCommand(s.path)
85 command.Stdout = stdoutFile
86 command.Stderr = stderrFile
87 command.SpawnWithLowerPriority = true
88
89 for key, val := range s.env {
90 command.Env[key] = val
91 }
92
93 _, _, _, err = s.runner.RunComplexCommand(command) //nolint:errcheck
94
95 return err
96}
97
98func (s GenericScript) ensureContainingDir(fullLogFilename string) error {
99 dir, _ := filepath.Split(fullLogFilename)

Callers

nothing calls this directly

Calls 4

ensureContainingDirMethod · 0.95
BuildCommandFunction · 0.92
CloseMethod · 0.65
RunComplexCommandMethod · 0.45

Tested by

no test coverage detected