diff --git a/.gitignore b/.gitignore index 6bac1bb29..9c9bc286d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# Packed binaries from github.com/shuLhan/go-bindata +bindata.go + # Binaries for programs and plugins *.exe *.exe~ diff --git a/Makefile b/Makefile index 75c8993a5..5e42bf96b 100644 --- a/Makefile +++ b/Makefile @@ -5,10 +5,11 @@ EXECUTABLE_CLI := airshipctl SCRIPTS_DIR := scripts -PLUGIN_DIR := _plugins +PLUGIN_DIR := _plugins PLUGIN_BIN := $(PLUGIN_DIR)/bin PLUGIN_INT := $(patsubst $(PLUGIN_DIR)/internal/%,$(PLUGIN_BIN)/%.so,$(wildcard $(PLUGIN_DIR)/internal/*)) PLUGIN_EXT := $(wildcard $(PLUGIN_DIR)/external/*) +BINDATA := "github.com/shuLhan/go-bindata/cmd/go-bindata" # linting LINTER_CMD := "github.com/golangci/golangci-lint/cmd/golangci-lint" run @@ -25,7 +26,7 @@ MIN_COVERAGE := 70 .PHONY: build -build: +build: plugin @go build -o $(BINDIR)/$(EXECUTABLE_CLI) .PHONY: test @@ -74,6 +75,7 @@ update-golden: .PHONY: plugin plugin: $(PLUGIN_INT) @for plugin in $(PLUGIN_EXT); do $(MAKE) -C $${plugin}; done + @go run $(BINDATA) $(PLUGIN_BIN) $(PLUGIN_BIN)/%.so: $(PLUGIN_DIR)/*/%/*.go @go build -buildmode=plugin -o $@ $^ diff --git a/go.mod b/go.mod index 61290504e..20f421b0f 100644 --- a/go.mod +++ b/go.mod @@ -13,6 +13,7 @@ require ( github.com/googleapis/gnostic v0.2.0 // indirect github.com/imdario/mergo v0.3.7 // indirect github.com/json-iterator/go v1.1.6 // indirect + github.com/shuLhan/go-bindata v3.4.0+incompatible // indirect github.com/spf13/cobra v0.0.3 github.com/spf13/pflag v1.0.3 // indirect golang.org/x/crypto v0.0.0-20190422183909-d864b10871cd // indirect diff --git a/go.sum b/go.sum index 20d3f33be..9a714f0f9 100644 --- a/go.sum +++ b/go.sum @@ -177,6 +177,8 @@ github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/ryanuber/go-glob v0.0.0-20170128012129-256dc444b735/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= github.com/shirou/gopsutil v0.0.0-20180427012116-c95755e4bcd7/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= +github.com/shuLhan/go-bindata v3.4.0+incompatible h1:xlNGW4LRRs+BPBpefnlrgSqb9x7vNF9YyzKeMuuqMpk= +github.com/shuLhan/go-bindata v3.4.0+incompatible/go.mod h1:pkcPAATLBDD2+SpAPnX5vEM90F7fcwHCvvLCMXcmw3g= github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e h1:MZM7FHLqUHYI0Y/mQAt3d2aYa0SiNms/hFqC9qJYolM= github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk= github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041 h1:llrF3Fs4018ePo4+G/HV/uQUqEI1HMDjCeOf2V6puPc= diff --git a/main.go b/main.go index 16b8d455e..7392cd4eb 100644 --- a/main.go +++ b/main.go @@ -7,5 +7,8 @@ import ( ) func main() { + if err := RestoreAssets("", "_plugins"); err != nil { + panic(err.Error()) + } cmd.Execute(os.Stdout) } diff --git a/tools/tools.go b/tools/tools.go index ad291c848..60de72fd8 100644 --- a/tools/tools.go +++ b/tools/tools.go @@ -4,5 +4,6 @@ package tools import ( _ "github.com/golangci/golangci-lint/cmd/golangci-lint" + _ "github.com/shuLahn/go-bindata/cmd/go-bindata" )