binctr/generate.go
Jess Frazelle 3cf304f3e1 updates
Signed-off-by: Jess Frazelle <jess@mesosphere.com>
2016-04-15 21:53:49 -07:00

36 lines
727 B
Go

// +build ignore
package main
import (
"encoding/base64"
"io/ioutil"
"os"
"path/filepath"
)
// Reads static/index.html and saves as a constant in static.go
func main() {
wd, err := os.Getwd()
if err != nil {
panic(err)
}
out, err := os.Create(filepath.Join(wd, "rootfs.go"))
if err != nil {
panic(err)
}
tarPath := filepath.Join(wd, "image.tar")
out.Write([]byte("// This file is autogenerated; DO NOT EDIT DIRECTLY\n// See generate.go for more info\npackage main\n\nconst (\n"))
out.Write([]byte("\tDATA = `"))
f, err := ioutil.ReadFile(tarPath)
if err != nil {
panic(err)
}
tar := base64.StdEncoding.EncodeToString(f)
out.Write([]byte(tar))
out.Write([]byte("`\n"))
out.Write([]byte(")\n"))
}