summaryrefslogtreecommitdiff
path: root/internal/task/story.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/task/story.go')
-rw-r--r--internal/task/story.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/internal/task/story.go b/internal/task/story.go
new file mode 100644
index 0000000..536bda1
--- /dev/null
+++ b/internal/task/story.go
@@ -0,0 +1,41 @@
+package task
+
+import "time"
+
+type StoryState string
+
+const (
+ StoryPending StoryState = "PENDING"
+ StoryInProgress StoryState = "IN_PROGRESS"
+ StoryShippable StoryState = "SHIPPABLE"
+ StoryDeployed StoryState = "DEPLOYED"
+ StoryValidating StoryState = "VALIDATING"
+ StoryReviewReady StoryState = "REVIEW_READY"
+ StoryNeedsFix StoryState = "NEEDS_FIX"
+)
+
+type Story struct {
+ ID string `json:"id"`
+ Name string `json:"name"`
+ ProjectID string `json:"project_id"`
+ BranchName string `json:"branch_name"`
+ DeployConfig string `json:"deploy_config"`
+ ValidationJSON string `json:"validation_json"`
+ Status StoryState `json:"status"`
+ CreatedAt time.Time `json:"created_at"`
+ UpdatedAt time.Time `json:"updated_at"`
+}
+
+var validStoryTransitions = map[StoryState]map[StoryState]bool{
+ StoryPending: {StoryInProgress: true},
+ StoryInProgress: {StoryShippable: true, StoryNeedsFix: true},
+ StoryShippable: {StoryDeployed: true},
+ StoryDeployed: {StoryValidating: true},
+ StoryValidating: {StoryReviewReady: true, StoryNeedsFix: true},
+ StoryReviewReady: {},
+ StoryNeedsFix: {StoryInProgress: true},
+}
+
+func ValidStoryTransition(from, to StoryState) bool {
+ return validStoryTransitions[from][to]
+}