diff --git a/.gitignore b/.gitignore
index 4303094d9..7e5bd38d9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,4 @@
gin-bin
-util/bindata.go
build/
public/js/bundle.js
public/css/semaphore.css
@@ -9,4 +8,5 @@ node_modules
.idea/
caddyfile
-cli/semaphore_*
\ No newline at end of file
+cli/semaphore_*
+*-packr.go
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index adfeeba47..311162cc6 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -33,7 +33,7 @@ git clone --recursive git@github.com:ansible-semaphore/semaphore.git && cd semap
3) Install dev dependencies
```
-go get ./... github.com/cespare/reflex github.com/jteeuwen/go-bindata/... github.com/mitchellh/gox
+go get ./... github.com/cespare/reflex github.com/gobuffalo/packr/... github.com/mitchellh/gox
npm install async
npm install -g nodemon pug-cli less
```
diff --git a/api/router.go b/api/router.go
index 2194e77aa..3d2e64faf 100644
--- a/api/router.go
+++ b/api/router.go
@@ -9,10 +9,13 @@ import (
"github.com/ansible-semaphore/semaphore/api/tasks"
"github.com/ansible-semaphore/semaphore/util"
"github.com/castawaylabs/mulekick"
+ "github.com/gobuffalo/packr"
"github.com/gorilla/mux"
"github.com/russross/blackfriday"
)
+var publicAssets = packr.NewBox("../public")
+
// Declare all routes
func Route() mulekick.Router {
r := mulekick.New(mux.NewRouter(), mulekick.CorsMiddleware)
@@ -123,21 +126,21 @@ func servePublic(w http.ResponseWriter, r *http.Request) {
return
}
- path = "/public/html/index.html"
+ path = "/html/index.html"
}
- path = strings.Replace(path, "/", "", 1)
+ path = strings.Replace(path, "/public/", "", 1)
split := strings.Split(path, ".")
suffix := split[len(split)-1]
- res, err := util.Asset(path)
+ res, err := publicAssets.MustBytes(path)
if err != nil {
mulekick.NotFoundHandler(w, r)
return
}
// replace base path
- if util.WebHostURL != nil && path == "public/html/index.html" {
+ if util.WebHostURL != nil && path == "html/index.html" {
res = []byte(strings.Replace(string(res),
"",
"",
diff --git a/circle.yml b/circle.yml
index 481214130..b14507b32 100644
--- a/circle.yml
+++ b/circle.yml
@@ -10,7 +10,7 @@ dependencies:
- git submodule update --init --recursive
- npm i -g less pug-cli
- npm i async
- - go get github.com/jteeuwen/go-bindata/...
+ - go get github.com/gobuffalo/packr/...
- go get github.com/mitchellh/gox
override:
diff --git a/db/migrations.go b/db/migrations.go
index 6f0f8d8ca..0bd4a00c1 100644
--- a/db/migrations.go
+++ b/db/migrations.go
@@ -4,10 +4,12 @@ import (
"fmt"
"time"
- "github.com/ansible-semaphore/semaphore/util"
"github.com/go-sql-driver/mysql"
+ "github.com/gobuffalo/packr"
)
+var dbAssets = packr.NewBox("./migrations")
+
func (version *DBVersion) CheckExists() (bool, error) {
exists, err := Mysql.SelectInt("select count(1) as ex from migrations where version=?", version.VersionString())
@@ -69,7 +71,8 @@ func (version *DBVersion) Run() error {
func (version *DBVersion) TryRollback() {
fmt.Printf("Rolling back %s (time: %v)...\n", version.HumanoidVersion(), time.Now())
- if _, err := util.Asset(version.GetErrPath()); err != nil {
+ data := dbAssets.Bytes(version.GetErrPath())
+ if len(data) == 0 {
fmt.Println("Rollback SQL does not exist.")
fmt.Println()
return
diff --git a/db/versionHistory.go b/db/versionHistory.go
index e47872f43..9ea085203 100644
--- a/db/versionHistory.go
+++ b/db/versionHistory.go
@@ -4,8 +4,6 @@ import (
"fmt"
"strings"
"time"
-
- "github.com/ansible-semaphore/semaphore/util"
)
type DBVersion struct {
@@ -41,15 +39,18 @@ func (version *DBVersion) HumanoidVersion() string {
}
func (version *DBVersion) GetPath() string {
- return "db/migrations/v" + version.VersionString() + ".sql"
+ return "v" + version.VersionString() + ".sql"
}
func (version *DBVersion) GetErrPath() string {
- return "db/migrations/v" + version.VersionString() + ".err.sql"
+ return "v" + version.VersionString() + ".err.sql"
}
func (version *DBVersion) GetSQL(path string) []string {
- sql := util.MustAsset(path)
- return strings.Split(string(sql), ";\n")
+ sql, err := dbAssets.MustString(path)
+ if err != nil {
+ panic(err)
+ }
+ return strings.Split(sql, ";\n")
}
func init() {
diff --git a/make.sh b/make.sh
index ac8d697a0..302f054e9 100755
--- a/make.sh
+++ b/make.sh
@@ -1,15 +1,6 @@
#!/bin/bash
set -e
-BINDATA_ARGS="-o util/bindata.go -pkg util"
-
-if [ "$1" == "watch" ]; then
- BINDATA_ARGS="-debug ${BINDATA_ARGS}"
- echo "Creating util/bindata.go with file proxy"
-else
- echo "Creating util/bindata.go"
-fi
-
if [ "$1" == "ci_test" ]; then
echo "Creating CI Test config.json"
@@ -63,7 +54,7 @@ HEREDOC
github-release release --draft -u ansible-semaphore -r semaphore -t "v$VERSION" -d "## Special thanks to\n\n## Installation\n\nFollow [wiki/Installation](https://github.com/ansible-semaphore/semaphore/wiki/Installation)\n\n## Changelog"
fi
-go-bindata $BINDATA_ARGS db/migrations/ $(find public/* -type d -print)
+packr
if [ "$1" == "ci_test" ]; then
exit 0