MCPcopy Index your code
hub / github.com/perkeep/perkeep / replaceRingPath

Function replaceRingPath

pkg/serverinit/serverinit_test.go:135–148  ·  view source on GitHub ↗

replaceRingPath returns the contents of the file at path with secringPlaceholder replaced with the absolute path of relativeRing.

(path string)

Source from the content-addressed store, hash-verified

133
134// replaceRingPath returns the contents of the file at path with secringPlaceholder replaced with the absolute path of relativeRing.
135func replaceRingPath(path string) ([]byte, error) {
136 secRing, err := filepath.Abs(relativeRing)
137 if err != nil {
138 return nil, fmt.Errorf("Could not get absolute path of %v: %v", relativeRing, err)
139 }
140 secRing = strings.Replace(secRing, `\`, `\\`, -1)
141 slurpBytes, err := os.ReadFile(path)
142 if err != nil {
143 return nil, err
144 }
145
146 // twice: once in search owner, and once in sighelper.
147 return bytes.Replace(slurpBytes, []byte(secringPlaceholder), []byte(secRing), 2), nil
148}
149
150// We just need to make sure that we don't match the prefix handlers too.
151var unixPathPattern = regexp.MustCompile(`"/.*/.+"`)

Callers 3

configParserFunction · 0.85
testConfigFunction · 0.85
TestGenerateClientConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected