rdev/internal/port/git_repository.go
jordan 9226454b85
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
feat: label-based undeploy, GC reconciliation, checkout/sessions, pool status
- 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>
2026-02-09 19:11:28 -07:00

57 lines
2.4 KiB
Go

// Package port defines interfaces (ports) for external dependencies.
package port
import (
"context"
"time"
"github.com/orchard9/rdev/internal/domain"
)
// GitRepository manages git repositories via external git server (Gitea).
type GitRepository interface {
// CreateRepo creates a new git repository.
CreateRepo(ctx context.Context, name, description string, private bool) (*domain.Repo, error)
// DeleteRepo deletes a repository.
DeleteRepo(ctx context.Context, owner, name string) error
// ListRepos returns all repositories for an owner.
ListRepos(ctx context.Context, owner string) ([]*domain.Repo, error)
// GetRepo returns a single repository.
GetRepo(ctx context.Context, owner, name string) (*domain.Repo, error)
// AddCollaborator adds a user as collaborator to a repo.
// permission can be "read", "write", or "admin".
AddCollaborator(ctx context.Context, owner, repo, username string, permission string) error
// RemoveCollaborator removes a collaborator from a repo.
RemoveCollaborator(ctx context.Context, owner, repo, username string) error
// AddDeployKey adds a deploy key to a repo for read-only or read-write access.
AddDeployKey(ctx context.Context, owner, repo, title, publicKey string, readOnly bool) (*domain.DeployKey, error)
// DeleteDeployKey removes a deploy key from a repo.
DeleteDeployKey(ctx context.Context, owner, repo string, keyID int64) error
// CreateWebhook creates a webhook to trigger on specified events.
CreateWebhook(ctx context.Context, owner, repo, url, secret string, events []string) (*domain.RepoWebhook, error)
// DeleteWebhook removes a webhook from a repo.
DeleteWebhook(ctx context.Context, owner, repo string, webhookID int64) error
// ListBranches returns all branches for a repository.
ListBranches(ctx context.Context, owner, repo string) ([]*domain.GitBranch, error)
// CreateBranch creates a new branch from a reference (branch name or commit SHA).
CreateBranch(ctx context.Context, owner, repo, branchName, fromRef string) (*domain.GitBranch, error)
// CreateAccessToken creates a new personal access token for git operations.
// Returns the token value (only available once), token ID, and any error.
CreateAccessToken(ctx context.Context, name string, scopes []string, expiresAt *time.Time) (*domain.GitAccessToken, error)
// DeleteAccessToken revokes and deletes an access token.
DeleteAccessToken(ctx context.Context, tokenID int64) error
}