build(chronograf): add conditional build tags for asset generation

pull/10616/head
Chris Goller 2018-09-04 17:26:40 -05:00
parent 41a0ad5364
commit ef7bfdd6d2
7 changed files with 34 additions and 26 deletions

View File

@ -50,7 +50,8 @@ UTILS := \
#
# This target sets up the dependencies to correctly build all go commands.
# Other targets must depend on this target to correctly builds CMDS.
all: vendor node_modules $(UTILS) subdirs $(CMDS)
all: GO_ARGS=-tags 'assets $(GO_TAGS)'
all: vendor node_modules $(UTILS) subdirs generate $(CMDS)
# Target to build subdirs.
# Each subdirs must support the `all` target.
@ -109,11 +110,10 @@ vendor/github.com/kevinburke/go-bindata/go-bindata/main.go: vendor
fmt: $(SOURCES_NO_VENDOR)
goimports -w $^
# generate:
# TODO: re-enable these after we decide on a strategy for building without running `go generate`.
# $(GO_GENERATE) ./chronograf/dist/...
# $(GO_GENERATE) ./chronograf/server/...
# $(GO_GENERATE) ./chronograf/canned/...
generate:
$(GO_GENERATE) ./chronograf/dist/...
$(GO_GENERATE) ./chronograf/server/...
$(GO_GENERATE) ./chronograf/canned/...
test-js: node_modules
cd chronograf/ui && yarn test --runInBand

View File

@ -1,16 +1,18 @@
// +build !assets
package canned
import "errors"
// The functions defined in this file are placeholders
// until we decide how to get the finalized Chronograf assets in platform.
var errTODO = errors.New("TODO: decide how to handle chronograf assets in platform")
// The functions defined in this file are placeholders when the binary is compiled
// without assets.
// Asset returns an error stating no assets were included in the binary.
func Asset(string) ([]byte, error) {
return nil, errTODO
return nil, errors.New("no assets included in binary")
}
// AssetNames returns nil because there are no assets included in the binary.
func AssetNames() []string {
return nil
}

View File

@ -8,7 +8,7 @@ import (
"github.com/influxdata/platform/chronograf"
)
//go:generate go-bindata -o bin_gen.go -ignore README|apps|.sh|go -pkg canned .
//go:generate go-bindata -o bin_gen.go -tags assets -ignore README|apps|.sh|go -pkg canned .
// BinLayoutsStore represents a layout store using data generated by go-bindata
type BinLayoutsStore struct {

View File

@ -1,3 +1,5 @@
// +build !assets
package dist
import (
@ -6,18 +8,21 @@ import (
)
// The functions defined in this file are placeholders
// until we decide how to get the finalized Chronograf assets in platform.
// when the binary is compiled without assets.
var errTODO = errors.New("TODO: decide how to handle chronograf assets in platform")
var errNoAssets = errors.New("no assets included in binary")
// Asset returns an error stating no assets were included in the binary.
func Asset(string) ([]byte, error) {
return nil, errTODO
return nil, errNoAssets
}
// AssetInfo returns an error stating no assets were included in the binary.
func AssetInfo(name string) (os.FileInfo, error) {
return nil, errTODO
return nil, errNoAssets
}
// AssetDir returns nil because there are no assets included in the binary.
func AssetDir(name string) ([]string, error) {
return nil, errTODO
return nil, errNoAssets
}

View File

@ -1,6 +1,6 @@
package dist
//go:generate go-bindata -o dist_gen.go -ignore 'map|go' -pkg dist ../ui/build/...
//go:generate go-bindata -o dist_gen.go -ignore 'map|go' -tags assets -pkg dist ../ui/build/...
import (
"fmt"

View File

@ -1,14 +1,15 @@
// +build !assets
package server
import (
"errors"
)
// The functions defined in this file are placeholders
// until we decide how to get the finalized Chronograf assets in platform.
var errTODO = errors.New("You didn't generate assets for the chronograf/server folder, using placeholders")
// The functions defined in this file are placeholders when the binary is compiled
// without assets.
// Asset returns an error stating no assets were included in the binary.
func Asset(string) ([]byte, error) {
return nil, errTODO
return nil, errors.New("no assets included in binary")
}

View File

@ -1,6 +1,6 @@
package server
//go:generate go-bindata -o swagger_gen.go -ignore go -nocompress -pkg server .
//go:generate go-bindata -o swagger_gen.go -tags assets -ignore go -nocompress -pkg server .
import "net/http"