MCPcopy Create free account
hub / github.com/nhost/nhost / dumpCert

Function dumpCert

cli/dockercompose/compose.go:164–199  ·  view source on GitHub ↗
(
	cert []byte,
	key []byte,
	dstName string,
	dotnhostfolder string,
)

Source from the content-addressed store, hash-verified

162`
163
164func dumpCert(
165 cert []byte,
166 key []byte,
167 dstName string,
168 dotnhostfolder string,
169) error {
170 f1, err := os.OpenFile(
171 filepath.Join(dotnhostfolder, "traefik", "certs", dstName+".crt"),
172 os.O_TRUNC|os.O_CREATE|os.O_WRONLY,
173 0o644, //nolint:mnd
174 )
175 if err != nil {
176 return fmt.Errorf("failed to open local.crt: %w", err)
177 }
178 defer f1.Close()
179
180 if _, err := f1.Write(cert); err != nil {
181 return fmt.Errorf("failed to write local.crt: %w", err)
182 }
183
184 f2, err := os.OpenFile(
185 filepath.Join(dotnhostfolder, "traefik", "certs", dstName+".key"),
186 os.O_TRUNC|os.O_CREATE|os.O_WRONLY,
187 0o644, //nolint:mnd
188 )
189 if err != nil {
190 return fmt.Errorf("failed to open local.key: %w", err)
191 }
192 defer f2.Close()
193
194 if _, err := f2.Write(key); err != nil {
195 return fmt.Errorf("failed to write local.cert: %w", err)
196 }
197
198 return nil
199}
200
201func trafikFiles(dotnhostfolder string) error {
202 if err := os.MkdirAll(

Callers 1

trafikFilesFunction · 0.85

Calls 3

ErrorfMethod · 0.80
CloseMethod · 0.65
WriteMethod · 0.65

Tested by

no test coverage detected