Fix http file server address for local run

- use storage port in the artifacts URL
- create bin dir for local run
This commit is contained in:
stefanprodan 2020-04-15 12:42:53 +03:00
parent 1e3bc471d5
commit 521bae36dd
1 changed files with 4 additions and 3 deletions

View File

@ -84,7 +84,7 @@ func main() {
os.Exit(1) os.Exit(1)
} }
storage := mustInitStorage(storagePath, setupLog) storage := mustInitStorage(storagePath, storageAddr, setupLog)
go startFileServer(storage.BasePath, storageAddr, setupLog) go startFileServer(storage.BasePath, storageAddr, setupLog)
@ -135,13 +135,14 @@ func startFileServer(path string, address string, l logr.Logger) {
} }
} }
func mustInitStorage(path string, l logr.Logger) *controllers.Storage { func mustInitStorage(path string, storageAddr string, l logr.Logger) *controllers.Storage {
if path == "" { if path == "" {
p, _ := os.Getwd() p, _ := os.Getwd()
path = filepath.Join(p, "bin") path = filepath.Join(p, "bin")
os.MkdirAll(path, 0777)
} }
hostname := "localhost" hostname := "localhost" + storageAddr
if os.Getenv("RUNTIME_NAMESPACE") != "" { if os.Getenv("RUNTIME_NAMESPACE") != "" {
svcParts := strings.Split(os.Getenv("HOSTNAME"), "-") svcParts := strings.Split(os.Getenv("HOSTNAME"), "-")
hostname = fmt.Sprintf("%s.%s", hostname = fmt.Sprintf("%s.%s",