1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
25 func generate() error {
26 outfn := "generated_config.go"
27 tmpfile, err := ioutil.TempFile(".", "."+outfn+".")
31 defer os.Remove(tmpfile.Name())
33 gofmt := exec.Command("gofmt", "-s")
34 gofmt.Stdout = tmpfile
35 gofmt.Stderr = os.Stderr
36 w, err := gofmt.StdinPipe()
42 // copyright header: same as this file
43 cmd := exec.Command("head", "-n", "4", "generate.go")
45 cmd.Stderr = os.Stderr
51 data, err := ioutil.ReadFile("config.default.yml")
55 _, err = fmt.Fprintf(w, "package config\nvar DefaultYAML = []byte(`%s`)", bytes.Replace(data, []byte{'`'}, []byte("`+\"`\"+`"), -1))
71 return os.Rename(tmpfile.Name(), outfn)