Ver código fonte

revision and target types for validate apply (#3381)

ianedwards 2 anos atrás
pai
commit
ea43585360

+ 2 - 0
go.work.sum

@@ -226,6 +226,7 @@ cloud.google.com/go/workflows v1.9.0/go.mod h1:ZGkj1aFIOd9c8Gerkjjq7OW7I5+l6cSvT
 cloud.google.com/go/workflows v1.10.0/go.mod h1:fZ8LmRmZQWacon9UCX1r/g/DfAXx5VcPALq2CxzdePw=
 github.com/Masterminds/sprig v2.22.0+incompatible h1:z4yfnGrZ7netVz+0EDJ0Wi+5VZCSYp4Z0m2dk6cEM60=
 github.com/bitly/go-simplejson v0.5.0 h1:6IH+V8/tVMab511d5bn4M7EwGXZf9Hj6i2xSwkNEM+Y=
+github.com/bufbuild/connect-go v1.5.2 h1:G4EZd5gF1U1ZhhbVJXplbuUnfKpBZ5j5izqIwu2g2W8=
 github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
 github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw=
 github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI=
@@ -263,6 +264,7 @@ github.com/tchap/go-patricia v2.2.6+incompatible h1:JvoDL7JSoIP2HDE8AbDH3zC8QBPx
 go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU=
 go.opentelemetry.io/contrib v0.20.0 h1:ubFQUn0VCZ0gPwIoJfBJVpeBlyRMxu8Mm/huKWYd9p0=
 go.opentelemetry.io/otel/exporters/otlp v0.20.0 h1:PTNgq9MRmQqqJY0REVbZFvwkYOA85vbdQU/nVfxDyqg=
+golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs=
 golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
 golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
 golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=

+ 29 - 0
internal/models/app_revision.go

@@ -0,0 +1,29 @@
+package models
+
+import (
+	"github.com/google/uuid"
+	"gorm.io/gorm"
+)
+
+// AppRevision represents the full spec for a revision of a porter app
+type AppRevision struct {
+	gorm.Model
+
+	// ID is a UUID for the AppRevision
+	ID uuid.UUID `gorm:"type:uuid;primaryKey" json:"id"`
+
+	// Base64App is the PorterApp as json encoded in base64
+	Base64App string `json:"base64_app"`
+
+	// Status is the status of the apply that happened for this revision.
+	Status string `json:"status"`
+
+	// DeploymentTargetID is the ID of the deployment target that the revision applies to.
+	DeploymentTargetID uuid.UUID `json:"deployment_target_id"`
+
+	// ProjectID is the ID of the project that the revision belongs to.
+	ProjectID int `json:"project_id"`
+
+	// PorterAppID is the ID of the PorterApp that the revision belongs to.
+	PorterAppID int `json:"porter_app_id"`
+}

+ 26 - 0
internal/models/deployment_target.go

@@ -0,0 +1,26 @@
+package models
+
+import (
+	"github.com/google/uuid"
+	"gorm.io/gorm"
+)
+
+// DeploymentTarget represents a deployment target on a given cluster
+type DeploymentTarget struct {
+	gorm.Model
+
+	// ID is a UUID for the Revision
+	ID uuid.UUID `gorm:"type:uuid;primaryKey" json:"id"`
+
+	// ClusterID is the ID of the cluster that is being targeted.
+	ClusterID int `json:"cluster_id"`
+
+	// ProjectID is the ID of the project that the target belongs to.
+	ProjectID int `json:"project_id"`
+
+	// Selector is the identifier to target.
+	Selector string `json:"selector"`
+
+	// SelectorType is the kind of selector (i.e. NAMESPACE or LABEL).
+	SelectorType string `json:"selector_type"`
+}

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

@@ -62,6 +62,8 @@ func AutoMigrate(db *gorm.DB, debug bool) error {
 		&models.AWSAssumeRoleChain{},
 		&models.PorterApp{},
 		&models.PorterAppEvent{},
+		&models.AppRevision{},
+		&models.DeploymentTarget{},
 		&ints.KubeIntegration{},
 		&ints.BasicIntegration{},
 		&ints.OIDCIntegration{},