Parcourir la source

move gh webhook to standalone table (#3752)

ianedwards il y a 2 ans
Parent
commit
e0afbcf57a

+ 26 - 0
internal/models/github_webhook.go

@@ -0,0 +1,26 @@
+package models
+
+import (
+	"github.com/google/uuid"
+	"gorm.io/gorm"
+)
+
+// GithubWebhook represents a webhook that is created on Github which can trigger actions in Porter for the specified project/cluster
+type GithubWebhook struct {
+	gorm.Model
+
+	// ID is a UUID for the webhook
+	ID uuid.UUID `gorm:"type:uuid;primaryKey" json:"id"`
+
+	// ClusterID is the ID of the cluster that the webhook is associated with.
+	ClusterID int
+
+	// ProjectID is the ID of the project that the webhook is associated with.
+	ProjectID int
+
+	// PorterAppID is the ID of the PorterApp that the webhook is associated with.
+	PorterAppID int
+
+	// GithubWebhookID is the ID of the webhook provided by Github.
+	GithubWebhookID int64
+}

+ 3 - 4
internal/models/porter_app.go

@@ -18,10 +18,9 @@ type PorterApp struct {
 	ImageRepoURI string
 	ImageRepoURI string
 
 
 	// Git repo information (optional)
 	// Git repo information (optional)
-	GitRepoID       uint
-	RepoName        string
-	GitBranch       string
-	GithubWebhookID int64 `gorm:"-"` // do not use in read/writes. this is temporary until migrations are run
+	GitRepoID uint
+	RepoName  string
+	GitBranch string
 
 
 	BuildContext   string
 	BuildContext   string
 	Builder        string
 	Builder        string

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

@@ -65,6 +65,7 @@ func AutoMigrate(db *gorm.DB, debug bool) error {
 		&models.AppRevision{},
 		&models.AppRevision{},
 		&models.DeploymentTarget{},
 		&models.DeploymentTarget{},
 		&models.AppTemplate{},
 		&models.AppTemplate{},
+		&models.GithubWebhook{},
 		&ints.KubeIntegration{},
 		&ints.KubeIntegration{},
 		&ints.BasicIntegration{},
 		&ints.BasicIntegration{},
 		&ints.OIDCIntegration{},
 		&ints.OIDCIntegration{},