Quellcode durchsuchen

add type to status (#4172)

Feroze Mohideen vor 2 Jahren
Ursprung
Commit
0a67797341
2 geänderte Dateien mit 12 neuen und 1 gelöschten Zeilen
  1. 1 0
      internal/datastore/create.go
  2. 11 1
      internal/models/datastore.go

+ 1 - 0
internal/datastore/create.go

@@ -68,6 +68,7 @@ func CreateOrGetRecord(ctx context.Context, inp CreateOrGetRecordInput) (*models
 		Engine:                            inp.Engine,
 		CloudProvider:                     cluster.CloudProvider,
 		CloudProviderCredentialIdentifier: cluster.CloudProviderCredentialIdentifier,
+		Status:                            models.DatastoreStatus_Creating,
 	}
 
 	datastore, err = inp.DatastoreRepository.Insert(ctx, datastoreToSave)

+ 11 - 1
internal/models/datastore.go

@@ -5,6 +5,16 @@ import (
 	"gorm.io/gorm"
 )
 
+// DatastoreStatus is the status of an app revision
+type DatastoreStatus string
+
+const (
+	// DatastoreStatus_Creating is the status for a datastore that is being created
+	DatastoreStatus_Creating DatastoreStatus = "CREATING"
+	// DatastoreStatus_Available is the status for a datastore that is available
+	DatastoreStatus_Available DatastoreStatus = "AVAILABLE"
+)
+
 // Datastore is a database model that represents a Porter-provisioned datastore
 type Datastore struct {
 	gorm.Model
@@ -33,5 +43,5 @@ type Datastore struct {
 	Engine string `json:"engine"`
 
 	// Status describes the status of a datastore
-	Status string `json:"status"`
+	Status DatastoreStatus `json:"status"`
 }