#60: Bugfixes for production
This commit is contained in:
+10
-7
@@ -39,7 +39,6 @@ import (
|
||||
|
||||
"github.com/go-git/go-billy/v5"
|
||||
"github.com/go-git/go-billy/v5/memfs"
|
||||
"github.com/go-git/go-billy/v5/osfs"
|
||||
"github.com/go-git/go-git/v5"
|
||||
"github.com/go-git/go-git/v5/storage/memory"
|
||||
|
||||
@@ -5794,8 +5793,9 @@ func healthCheckHandler(resp http.ResponseWriter, request *http.Request) {
|
||||
|
||||
// Creates osfs from folderpath with a basepath as directory base
|
||||
func createFs(basepath, pathname string) (billy.Filesystem, error) {
|
||||
fs := osfs.New("")
|
||||
log.Printf("base: %s, pathname: %s", basepath, pathname)
|
||||
|
||||
fs := memfs.New()
|
||||
err := filepath.Walk(pathname,
|
||||
func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
@@ -5806,7 +5806,10 @@ func createFs(basepath, pathname string) (billy.Filesystem, error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
fullpath := fmt.Sprintf("%s%s", basepath, path)
|
||||
// Fix the inner path here
|
||||
newpath := strings.ReplaceAll(path, pathname, "")
|
||||
fullpath := fmt.Sprintf("%s%s", basepath, newpath)
|
||||
log.Printf("Fullpath: %s", fullpath)
|
||||
switch mode := info.Mode(); {
|
||||
case mode.IsDir():
|
||||
err = fs.MkdirAll(fullpath, 0644)
|
||||
@@ -5845,23 +5848,23 @@ func createFs(basepath, pathname string) (billy.Filesystem, error) {
|
||||
}
|
||||
|
||||
// Hotloads new apps from a folder
|
||||
// FIXME: Not finished
|
||||
func handleAppHotload(location string) error {
|
||||
basepath := "base"
|
||||
fs, err := createFs(basepath, location)
|
||||
if err != nil {
|
||||
log.Printf("Failed making files and stuff: %s", err)
|
||||
log.Printf("Failed memfs creation - probably bad path: %s", err)
|
||||
return err
|
||||
} else {
|
||||
log.Printf("Hotloading from %s finished", location)
|
||||
log.Printf("Memfs creation from %s done", location)
|
||||
}
|
||||
|
||||
dir, err := fs.ReadDir(basepath)
|
||||
dir, err := fs.ReadDir("")
|
||||
if err != nil {
|
||||
log.Printf("Failed reading folder: %s", err)
|
||||
return err
|
||||
}
|
||||
|
||||
log.Printf("Reading app folder: %#v", dir)
|
||||
err = iterateAppGithubFolders(fs, dir, "", "")
|
||||
if err != nil {
|
||||
log.Printf("Err: %s", err)
|
||||
|
||||
+17
-12
@@ -3444,6 +3444,7 @@ func handleAppHotloadRequest(resp http.ResponseWriter, request *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
log.Printf("Hotloading from %s", location)
|
||||
err = handleAppHotload(location)
|
||||
if err != nil {
|
||||
resp.WriteHeader(500)
|
||||
@@ -3699,13 +3700,13 @@ func iterateWorkflowGithubFolders(fs billy.Filesystem, dir []os.FileInfo, extra
|
||||
dir, err := fs.ReadDir(tmpExtra)
|
||||
if err != nil {
|
||||
log.Printf("Failed to read dir: %s", err)
|
||||
break
|
||||
continue
|
||||
}
|
||||
|
||||
// Go routine? Hmm, this can be super quick I guess
|
||||
err = iterateWorkflowGithubFolders(fs, dir, tmpExtra, "")
|
||||
if err != nil {
|
||||
break
|
||||
continue
|
||||
}
|
||||
case mode.IsRegular():
|
||||
// Check the file
|
||||
@@ -3759,28 +3760,32 @@ func iterateAppGithubFolders(fs billy.Filesystem, dir []os.FileInfo, extra strin
|
||||
dir, err := fs.ReadDir(tmpExtra)
|
||||
if err != nil {
|
||||
log.Printf("Failed to read dir: %s", err)
|
||||
break
|
||||
continue
|
||||
}
|
||||
|
||||
// Go routine? Hmm, this can be super quick I guess
|
||||
err = iterateAppGithubFolders(fs, dir, tmpExtra, "")
|
||||
if err != nil {
|
||||
break
|
||||
log.Printf("Error reading folder: %s", err)
|
||||
continue
|
||||
}
|
||||
case mode.IsRegular():
|
||||
// Check the file
|
||||
filename := file.Name()
|
||||
if filename == "Dockerfile" {
|
||||
|
||||
// Quick Dockerfile check
|
||||
dockerdata, err := ioutil.ReadFile(fmt.Sprintf("%sDockerfile", extra))
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
//dockerfile := fmt.Sprintf("%sDockerfile", extra)
|
||||
//log.Printf("Handling Dockerfile %s", dockerfile)
|
||||
//dockerdata, err := ioutil.ReadFile(dockerfile)
|
||||
//if err != nil {
|
||||
// log.Printf("Failed to read dockerfile")
|
||||
// continue
|
||||
//}
|
||||
|
||||
if len(dockerdata) == 0 {
|
||||
continue
|
||||
}
|
||||
//if len(dockerdata) == 0 {
|
||||
// log.Printf("Dockerfile is empty")
|
||||
// continue
|
||||
//}
|
||||
|
||||
log.Printf("Handle Dockerfile in location %s", extra)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user