浏览代码

move quick start env variable

Alexander Belanger 5 年之前
父节点
当前提交
bce63f7c70
共有 3 个文件被更改,包括 8 次插入9 次删除
  1. 1 1
      dashboard/src/shared/Context.tsx
  2. 5 8
      internal/adapter/gorm.go
  3. 2 0
      internal/config/config.go

+ 1 - 1
dashboard/src/shared/Context.tsx

@@ -51,7 +51,7 @@ class ContextProvider extends Component {
   };
 
   componentDidMount() {
-    this.setState({ userId: 1 });
+    this.setState({ userId: 3 });
   }
 
   render() {

+ 5 - 8
internal/adapter/gorm.go

@@ -2,8 +2,6 @@ package gorm
 
 import (
 	"fmt"
-	"os"
-	"strconv"
 
 	"github.com/porter-dev/porter/internal/config"
 	"gorm.io/driver/postgres"
@@ -13,6 +11,10 @@ import (
 
 // New returns a new gorm database instance
 func New(conf *config.DBConf) (*gorm.DB, error) {
+	if conf.SQLLite {
+		return gorm.Open(sqlite.Open("./internal/porter.db"), &gorm.Config{})
+	}
+
 	dsn := fmt.Sprintf(
 		"user=%s password=%s port=%d host=%s sslmode=disable",
 		conf.Username,
@@ -21,10 +23,5 @@ func New(conf *config.DBConf) (*gorm.DB, error) {
 		conf.Host,
 	)
 
-	if quickstart, _ := strconv.ParseBool(os.Getenv("QUICK_START")); quickstart {
-		return gorm.Open(sqlite.Open("./internal/porter.db"), &gorm.Config{})
-	} else {
-		return gorm.Open(postgres.Open(dsn), &gorm.Config{})
-	}
-
+	return gorm.Open(postgres.Open(dsn), &gorm.Config{})
 }

+ 2 - 0
internal/config/config.go

@@ -33,6 +33,8 @@ type DBConf struct {
 	Username string `env:"DB_USER,default=porter"`
 	Password string `env:"DB_PASS,default=porter"`
 	DbName   string `env:"DB_NAME,default=porter"`
+
+	SQLLite bool `env:"QUICK_START,default=false"`
 }
 
 // K8sConf is the global configuration for the k8s agents