Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
- Add UndeployAll() using label selectors to clean up monorepo components on project deletion (replaces name-based Undeploy in DeleteProject and the direct undeploy handler) - Add ResourceGC background worker that periodically finds K8s resources whose project label has no matching DB record, deletes after 1h safety window - Widen deployer client type from *kubernetes.Clientset to kubernetes.Interface for testability - UndeployAll accumulates errors via errors.Join instead of failing fast - Add checkout/checkin sidecar dev flow: temporary git tokens, branch checkout, review on checkin with cleanup workers - Add interactive sessions: pod binding, command execution, SSE streaming, ephemeral preview URLs with session cleanup workers - Add GET /workers/pool endpoint for aggregate capacity and queue depth - Add sessions:read and sessions:execute auth scopes Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
127 lines
3.5 KiB
Go
127 lines
3.5 KiB
Go
// Package domain contains pure domain models with no external dependencies.
|
|
package domain
|
|
|
|
import "time"
|
|
|
|
// CheckoutID is a strongly-typed identifier for checkouts.
|
|
type CheckoutID string
|
|
|
|
// CheckoutStatus represents the state of a checkout.
|
|
type CheckoutStatus string
|
|
|
|
const (
|
|
// CheckoutStatusActive indicates the checkout is currently in use.
|
|
CheckoutStatusActive CheckoutStatus = "active"
|
|
|
|
// CheckoutStatusCheckedIn indicates the checkout was completed via checkin.
|
|
CheckoutStatusCheckedIn CheckoutStatus = "checked_in"
|
|
|
|
// CheckoutStatusExpired indicates the checkout token expired.
|
|
CheckoutStatusExpired CheckoutStatus = "expired"
|
|
|
|
// CheckoutStatusRevoked indicates the checkout was manually revoked.
|
|
CheckoutStatusRevoked CheckoutStatus = "revoked"
|
|
)
|
|
|
|
// IsTerminal returns true if the status is a final state.
|
|
func (s CheckoutStatus) IsTerminal() bool {
|
|
return s == CheckoutStatusCheckedIn || s == CheckoutStatusExpired || s == CheckoutStatusRevoked
|
|
}
|
|
|
|
// Checkout represents a checked-out development session.
|
|
// A checkout grants temporary git access via an HTTPS token for local development.
|
|
type Checkout struct {
|
|
// ID is the unique checkout identifier.
|
|
ID CheckoutID
|
|
|
|
// ProjectID is the project being checked out.
|
|
ProjectID ProjectID
|
|
|
|
// Branch is the git branch being worked on.
|
|
Branch string
|
|
|
|
// FeatureSlug is the optional SDLC feature link.
|
|
FeatureSlug string
|
|
|
|
// GiteaTokenID is the Gitea access token ID (for revocation).
|
|
GiteaTokenID int64
|
|
|
|
// GiteaTokenName is the name of the Gitea access token.
|
|
GiteaTokenName string
|
|
|
|
// CloneURL is the base HTTPS clone URL (without token).
|
|
// Format: https://git.threesix.ai/owner/repo.git
|
|
// The authenticated URL with token is only returned once at checkout creation.
|
|
CloneURL string
|
|
|
|
// CheckedOutBy is the user or API key that created the checkout.
|
|
CheckedOutBy string
|
|
|
|
// CheckedOutAt is when the checkout was created.
|
|
CheckedOutAt time.Time
|
|
|
|
// ExpiresAt is when the checkout token expires.
|
|
ExpiresAt time.Time
|
|
|
|
// Status is the current state of the checkout.
|
|
Status CheckoutStatus
|
|
|
|
// CheckedInAt is when the checkout was completed (if checked in).
|
|
CheckedInAt *time.Time
|
|
|
|
// ReviewTaskID is the work task ID for the review (if review was triggered).
|
|
ReviewTaskID string
|
|
}
|
|
|
|
// IsActive returns true if the checkout can still be used.
|
|
func (c *Checkout) IsActive() bool {
|
|
return c.Status == CheckoutStatusActive && time.Now().Before(c.ExpiresAt)
|
|
}
|
|
|
|
// IsExpired returns true if the checkout has expired.
|
|
func (c *Checkout) IsExpired() bool {
|
|
return c.Status == CheckoutStatusActive && time.Now().After(c.ExpiresAt)
|
|
}
|
|
|
|
// GitBranch represents a git branch in a repository.
|
|
type GitBranch struct {
|
|
// Name is the branch name.
|
|
Name string
|
|
|
|
// CommitSHA is the latest commit on the branch.
|
|
CommitSHA string
|
|
|
|
// Protected indicates if the branch has protection rules.
|
|
Protected bool
|
|
}
|
|
|
|
// GitAccessToken represents a temporary git access token.
|
|
type GitAccessToken struct {
|
|
// ID is the token ID (for revocation).
|
|
ID int64
|
|
|
|
// Name is a human-readable name for the token.
|
|
Name string
|
|
|
|
// Token is the actual token value (only available on creation).
|
|
Token string
|
|
|
|
// Scopes are the permissions granted to the token.
|
|
Scopes []string
|
|
|
|
// ExpiresAt is when the token expires.
|
|
ExpiresAt *time.Time
|
|
}
|
|
|
|
// CheckoutListOptions provides filtering options for listing checkouts.
|
|
type CheckoutListOptions struct {
|
|
// Status filters by checkout status (nil = all statuses).
|
|
Status *CheckoutStatus
|
|
|
|
// Limit is the maximum number of results.
|
|
Limit int
|
|
|
|
// Offset is the number of results to skip.
|
|
Offset int
|
|
}
|