mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-30 07:59:40 -08:00
3581377e5d
Looking at https://tech.townsourced.com/post/embedding-static-files-in-go/ (which was mentioned in the issue), vfsgen has all the needed features. In particular: - Reproducible builds (no issue with timestamping). - Well maintained and relatively popular. - Integration with go generate. - Self-contained (no external dependency). * [WIP] Replace go-bindata by vfsgen Signed-off-by: Simon Pasquier <spasquie@redhat.com> * Add license + remove doc.go Signed-off-by: Simon Pasquier <spasquie@redhat.com> * Generate templates assets Signed-off-by: Simon Pasquier <spasquie@redhat.com> * Use new templates assets Signed-off-by: Simon Pasquier <spasquie@redhat.com> * split static assets Signed-off-by: Simon Pasquier <spasquie@redhat.com> * Idempotent make assets Signed-off-by: Simon Pasquier <spasquie@redhat.com> * Update vendor/ Signed-off-by: Simon Pasquier <spasquie@redhat.com> * vendor vfsgendev Signed-off-by: Simon Pasquier <spasquie@redhat.com> * Update README.md Signed-off-by: Simon Pasquier <spasquie@redhat.com> * Simplify assets generation Signed-off-by: Simon Pasquier <spasquie@redhat.com> * Fix README.md Signed-off-by: Simon Pasquier <spasquie@redhat.com> * Use generate helper program instead of vfsgen This avoids installing vfsgendev in the target environment. Signed-off-by: Simon Pasquier <spasquie@redhat.com> * Remove unused vfsgen package Signed-off-by: Simon Pasquier <spasquie@redhat.com> * Fix Makefile Signed-off-by: Simon Pasquier <spasquie@redhat.com> * vendoring shurcooL/vfsgen Signed-off-by: Simon Pasquier <spasquie@redhat.com> * Fix go generate command Signed-off-by: Simon Pasquier <spasquie@redhat.com> * Sync web/ui/assets_vfsdata.go Signed-off-by: Simon Pasquier <spasquie@redhat.com>
46 lines
1.4 KiB
Go
46 lines
1.4 KiB
Go
package vfsgen
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// Options for vfsgen code generation.
|
|
type Options struct {
|
|
// Filename of the generated Go code output (including extension).
|
|
// If left empty, it defaults to "{{toLower .VariableName}}_vfsdata.go".
|
|
Filename string
|
|
|
|
// PackageName is the name of the package in the generated code.
|
|
// If left empty, it defaults to "main".
|
|
PackageName string
|
|
|
|
// BuildTags are the optional build tags in the generated code.
|
|
// The build tags syntax is specified by the go tool.
|
|
BuildTags string
|
|
|
|
// VariableName is the name of the http.FileSystem variable in the generated code.
|
|
// If left empty, it defaults to "assets".
|
|
VariableName string
|
|
|
|
// VariableComment is the comment of the http.FileSystem variable in the generated code.
|
|
// If left empty, it defaults to "{{.VariableName}} statically implements the virtual filesystem provided to vfsgen.".
|
|
VariableComment string
|
|
}
|
|
|
|
// fillMissing sets default values for mandatory options that are left empty.
|
|
func (opt *Options) fillMissing() {
|
|
if opt.PackageName == "" {
|
|
opt.PackageName = "main"
|
|
}
|
|
if opt.VariableName == "" {
|
|
opt.VariableName = "assets"
|
|
}
|
|
if opt.Filename == "" {
|
|
opt.Filename = fmt.Sprintf("%s_vfsdata.go", strings.ToLower(opt.VariableName))
|
|
}
|
|
if opt.VariableComment == "" {
|
|
opt.VariableComment = fmt.Sprintf("%s statically implements the virtual filesystem provided to vfsgen.", opt.VariableName)
|
|
}
|
|
}
|