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

Function trafikFiles

cli/dockercompose/compose.go:201–232  ·  view source on GitHub ↗
(dotnhostfolder string)

Source from the content-addressed store, hash-verified

199}
200
201func trafikFiles(dotnhostfolder string) error {
202 if err := os.MkdirAll(
203 filepath.Join(dotnhostfolder, "traefik", "certs"),
204 0o755, //nolint:mnd
205 ); err != nil {
206 return fmt.Errorf("failed to create traefik folder: %w", err)
207 }
208
209 if err := dumpCert(ssl.LocalCertFile, ssl.LocalKeyFile, "local", dotnhostfolder); err != nil {
210 return fmt.Errorf("failed to dump local cert: %w", err)
211 }
212
213 if err := dumpCert(ssl.SubCertFile, ssl.SubKeyFile, "sub", dotnhostfolder); err != nil {
214 return fmt.Errorf("failed to dump sub cert: %w", err)
215 }
216
217 f, err := os.OpenFile(
218 filepath.Join(dotnhostfolder, "traefik", "traefik.yaml"),
219 os.O_TRUNC|os.O_CREATE|os.O_WRONLY,
220 0o644, //nolint:mnd
221 )
222 if err != nil {
223 return fmt.Errorf("failed to open traefik.yaml: %w", err)
224 }
225 defer f.Close()
226
227 if _, err := f.WriteString(traefikConfig); err != nil {
228 return fmt.Errorf("failed to write traefik.yaml: %w", err)
229 }
230
231 return nil
232}
233
234func getDockerHost() (*url.URL, error) {
235 socket, ok := os.LookupEnv("DOCKER_HOST")

Callers 1

traefikFunction · 0.85

Calls 4

dumpCertFunction · 0.85
ErrorfMethod · 0.80
CloseMethod · 0.65
WriteStringMethod · 0.45

Tested by

no test coverage detected