Kaynağa Gözat

porter app table

Justin Rhee 3 yıl önce
ebeveyn
işleme
b5a6cc2815

+ 6 - 6
api/server/shared/config/loader/loader.go

@@ -83,13 +83,13 @@ func (e *EnvConfigLoader) LoadConfig() (res *config.Config, err error) {
 	res.Logger.Info().Msg("Loaded MetadataFromConf")
 	res.DB = InstanceDB
 
-	// res.Logger.Info().Msg("Starting gorm automigrate")
-	// err = gorm.AutoMigrate(InstanceDB, sc.Debug)
+	res.Logger.Info().Msg("Starting gorm automigrate")
+	err = gorm.AutoMigrate(InstanceDB, sc.Debug)
 
-	// if err != nil {
-	// 	return nil, err
-	// }
-	// res.Logger.Info().Msg("Completed gorm automigrate")
+	if err != nil {
+		return nil, err
+	}
+	res.Logger.Info().Msg("Completed gorm automigrate")
 
 	var key [32]byte
 

+ 22 - 0
api/types/porter_app.go

@@ -0,0 +1,22 @@
+package types
+
+type PorterApp struct {
+	ID        uint `json:"id"`
+	ProjectID uint `json:"project_id"`
+	ClusterID uint `json:"cluster_id"`
+
+	Name string `json:"name"`
+
+	ImageRepoURI string `json:"image_repo_uri,omitempty"`
+
+	// Git repo information (optional)
+	GitRepoID uint   `json:"git_repo_id,omitempty"`
+	RepoName  string `json:"repo_name,omitempty"`
+	GitBranch string `json:"git_branch,omitempty"`
+
+	// Build settings (optional)
+	BuildContext string `json:"build_context,omitempty"`
+	Builder      string `json:"builder,omitempty"`
+	Buildpacks   string `json:"build_packs,omitempty"`
+	Dockerfile   string `json:"dockerfile,omitempty"`
+}

+ 47 - 0
internal/models/porter_app.go

@@ -0,0 +1,47 @@
+package models
+
+import (
+	"gorm.io/gorm"
+
+	"github.com/porter-dev/porter/api/types"
+)
+
+// PorterApp (stack) type that extends gorm.Model
+type PorterApp struct {
+	gorm.Model
+
+	ProjectID uint
+	ClusterID uint
+
+	Name string
+
+	ImageRepoURI string
+
+	// Git repo information (optional)
+	GitRepoID uint
+	RepoName  string
+	GitBranch string
+
+	BuildContext string
+	Builder      string
+	Buildpacks   string
+	Dockerfile   string
+}
+
+// ToPorterAppType generates an external types.PorterApp to be shared over REST
+func (a *PorterApp) ToPorterAppType() *types.PorterApp {
+	return &types.PorterApp{
+		ID:           a.ID,
+		ProjectID:    a.ProjectID,
+		ClusterID:    a.ClusterID,
+		Name:         a.Name,
+		ImageRepoURI: a.ImageRepoURI,
+		GitRepoID:    a.GitRepoID,
+		RepoName:     a.RepoName,
+		GitBranch:    a.GitBranch,
+		BuildContext: a.BuildContext,
+		Builder:      a.Builder,
+		Buildpacks:   a.Buildpacks,
+		Dockerfile:   a.Dockerfile,
+	}
+}

+ 1 - 0
internal/repository/gorm/migrate.go

@@ -60,6 +60,7 @@ func AutoMigrate(db *gorm.DB, debug bool) error {
 		&models.MonitorTestResult{},
 		&models.APIContractRevision{},
 		&models.AWSAssumeRoleChain{},
+		&models.PorterApp{},
 		&ints.KubeIntegration{},
 		&ints.BasicIntegration{},
 		&ints.OIDCIntegration{},