Use Cert to write files and split go generate
package testservers
-//go:generate bash -c "../../scripts/generate-loggregator-certs no-bbs-ca && go-bindata -nocompress -pkg testservers -prefix loggregator-certs/ loggregator-certs/"
+//go:generate ../../scripts/generate-loggregator-certs no-bbs-ca
+//go:generate go-bindata -nocompress -pkg testservers -prefix loggregator-certs/ loggregator-certs/
import (
"io/ioutil"
@@ -43,6 +44,24 @@ func CACertPath() string {
return createTempFile(MustAsset("loggregator-ca.crt"))
}
+func Cert(filename string) string {
+ contents := MustAsset(filename)
+ tmpfile, err := ioutil.TempFile("", "")
+
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ if _, err := tmpfile.Write(contents); err != nil {
+ log.Fatal(err)
+ }
+ if err := tmpfile.Close(); err != nil {
+ log.Fatal(err)
+ }
+
+ return tmpfile.Name()
+}
+
func createTempFile(contents []byte) string {
tmpfile, err := ioutil.TempFile("", "")
