chore(repo): reinitialize repository
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
package lane
|
||||
|
||||
import "fmt"
|
||||
|
||||
type Status string
|
||||
|
||||
const (
|
||||
StatusDraft Status = "draft"
|
||||
StatusReady Status = "ready"
|
||||
StatusRunning Status = "running"
|
||||
StatusBlocked Status = "blocked"
|
||||
StatusSucceeded Status = "succeeded"
|
||||
StatusFailed Status = "failed"
|
||||
StatusCancelled Status = "cancelled"
|
||||
)
|
||||
|
||||
type Record struct {
|
||||
ID string `json:"id"`
|
||||
WorkspaceID string `json:"workspace_id"`
|
||||
TopicID string `json:"topic_id"`
|
||||
Name string `json:"name"`
|
||||
Slug string `json:"slug"`
|
||||
Purpose string `json:"purpose,omitempty"`
|
||||
Status Status `json:"status"`
|
||||
BaseBranch string `json:"base_branch"`
|
||||
BranchName string `json:"branch_name"`
|
||||
HeadCommit string `json:"head_commit,omitempty"`
|
||||
WorktreePath string `json:"worktree_path"`
|
||||
ContainerName string `json:"container_name"`
|
||||
RuntimeEndpoint string `json:"runtime_endpoint"`
|
||||
CreatedByRoleName string `json:"created_by_role_name"`
|
||||
ResultSummaryMarkdown string `json:"result_summary_markdown,omitempty"`
|
||||
ErrorMessage string `json:"error_message,omitempty"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
StartedAt string `json:"started_at,omitempty"`
|
||||
CompletedAt string `json:"completed_at,omitempty"`
|
||||
}
|
||||
|
||||
func ValidateStatus(value Status) error {
|
||||
switch value {
|
||||
case StatusDraft, StatusReady, StatusRunning, StatusBlocked, StatusSucceeded, StatusFailed, StatusCancelled:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("invalid lane status %q", value)
|
||||
}
|
||||
}
|
||||
|
||||
func (r Record) Validate() error {
|
||||
if r.WorkspaceID == "" {
|
||||
return fmt.Errorf("workspace id is required")
|
||||
}
|
||||
if r.TopicID == "" {
|
||||
return fmt.Errorf("topic id is required")
|
||||
}
|
||||
if r.Name == "" {
|
||||
return fmt.Errorf("lane name is required")
|
||||
}
|
||||
if r.Slug == "" {
|
||||
return fmt.Errorf("lane slug is required")
|
||||
}
|
||||
if r.CreatedByRoleName == "" {
|
||||
return fmt.Errorf("created by role is required")
|
||||
}
|
||||
return ValidateStatus(r.Status)
|
||||
}
|
||||
Reference in New Issue
Block a user