Documentation
¶
Index ¶
- func CleanWorkspace(workspaceDir string) error
- func CloneRepository(repo *GitHubRepo, workspaceDir string) error
- func GetRepoPath(workspaceDir string) string
- func ProcessJob(ctx context.Context, job *Job, wm *WorkspaceManager) error
- func ValidateGitHubURL(u *url.URL) error
- func ValidateJobID(id string) error
- func ValidateWorkspacePath(baseDir, workspaceDir string) error
- type CheckRequest
- type CheckResponse
- type GitHubRepo
- type HealthResponse
- type Job
- type JobProcessor
- type JobQueue
- type JobResponse
- type JobStatus
- type JobStore
- func (s *JobStore) CleanupOldJobs(maxAge time.Duration) int
- func (s *JobStore) CreateJob(githubURL string, req CheckRequest, workspaceDir string) *Job
- func (s *JobStore) Delete(id string)
- func (s *JobStore) Get(id string) (*Job, bool)
- func (s *JobStore) List() []*Job
- func (s *JobStore) SetError(id string, err error)
- func (s *JobStore) SetResult(id string, result *output.JSONOutput)
- func (s *JobStore) UpdateStatus(id string, status JobStatus)
- type Server
- type WorkspaceManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanWorkspace ¶
CleanWorkspace removes the workspace directory.
func CloneRepository ¶
func CloneRepository(repo *GitHubRepo, workspaceDir string) error
CloneRepository clones a GitHub repository to the specified workspace directory. It performs a shallow clone for speed and minimal disk usage.
func GetRepoPath ¶
GetRepoPath returns the path where the repository was cloned.
func ProcessJob ¶
func ProcessJob(ctx context.Context, job *Job, wm *WorkspaceManager) error
ProcessJob processes a single check job. This is the main worker function that clones the repo and runs checks.
func ValidateGitHubURL ¶
ValidateGitHubURL performs additional validation on parsed URLs.
func ValidateJobID ¶
ValidateJobID checks if the job ID format is valid.
func ValidateWorkspacePath ¶
ValidateWorkspacePath performs security validation of a workspace path.
Types ¶
type CheckRequest ¶
type CheckRequest struct {
URL string `json:"url"` // GitHub URL (required)
Languages []string `json:"languages,omitempty"` // Override auto-detection
Profile string `json:"profile,omitempty"` // Application profile (cli, api, library, desktop)
Target string `json:"target,omitempty"` // Maturity target (poc, production)
SkipChecks []string `json:"skip_checks,omitempty"` // Checks to skip
TimeoutSecs int `json:"timeout_secs,omitempty"` // Per-check timeout (0 = no timeout)
Verbose bool `json:"verbose,omitempty"` // Show command output for failed/warning checks
}
CheckRequest is the request payload for submitting a check.
type CheckResponse ¶
type CheckResponse struct {
JobID string `json:"job_id"`
Status string `json:"status"`
Message string `json:"message"`
}
CheckResponse is the response when a check is submitted.
type GitHubRepo ¶
type GitHubRepo struct {
Owner string
Repo string
Branch string // Empty if using default branch
IsSSH bool
Original string // Original URL for reference
}
GitHubRepo represents a parsed GitHub repository URL.
func ParseGitHubURL ¶
func ParseGitHubURL(rawURL string) (*GitHubRepo, error)
ParseGitHubURL parses a GitHub URL and extracts owner, repo, and branch.
func (*GitHubRepo) CloneBranch ¶
func (gr *GitHubRepo) CloneBranch() string
CloneBranch clones a specific branch if specified, otherwise default.
func (*GitHubRepo) CloneURL ¶
func (gr *GitHubRepo) CloneURL() string
CloneURL returns the clone URL for the repo.
func (*GitHubRepo) Validate ¶
func (gr *GitHubRepo) Validate() error
Validate validates the GitHubRepo fields.
type HealthResponse ¶
type HealthResponse struct {
Status string `json:"status"`
Version string `json:"version,omitempty"`
}
HealthResponse is the response for GET /health.
type Job ¶
type Job struct {
ID string `json:"id"`
Status JobStatus `json:"status"`
GitHubURL string `json:"github_url"`
WorkspaceDir string `json:"-"` // Not exposed in JSON
Request CheckRequest `json:"request"`
SubmittedAt time.Time `json:"submitted_at"`
StartedAt *time.Time `json:"started_at,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
Result *output.JSONOutput `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}
Job represents a single check job.
func (*Job) ToJobResponse ¶
func (j *Job) ToJobResponse() JobResponse
ToJobResponse converts a Job to a JobResponse (excludes WorkspaceDir).
type JobProcessor ¶
JobProcessor is the function that processes a single job.
type JobQueue ¶
type JobQueue struct {
// contains filtered or unexported fields
}
JobQueue manages job queuing and execution with a worker pool.
func NewJobQueue ¶
NewJobQueue creates a new job queue with the specified number of workers.
func (*JobQueue) Enqueue ¶
Enqueue adds a job to the queue. Returns an error if the queue is not running.
func (*JobQueue) RunningCount ¶
RunningCount returns the approximate number of running jobs.
func (*JobQueue) Start ¶
func (q *JobQueue) Start(processor JobProcessor) error
Start starts the worker pool.
type JobResponse ¶
type JobResponse struct {
JobID string `json:"job_id"`
Status JobStatus `json:"status"`
GitHubURL string `json:"github_url"`
SubmittedAt time.Time `json:"submitted_at"`
StartedAt *time.Time `json:"started_at,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
Request CheckRequest `json:"request"`
Result *output.JSONOutput `json:"result,omitempty"`
Error string `json:"error,omitempty"`
}
JobResponse is the response for GET /api/check/{id}.
type JobStore ¶
type JobStore struct {
// contains filtered or unexported fields
}
JobStore manages job storage with thread-safe access.
func (*JobStore) CleanupOldJobs ¶
CleanupOldJobs removes jobs older than the specified duration. Returns the number of jobs cleaned up.
func (*JobStore) CreateJob ¶
func (s *JobStore) CreateJob(githubURL string, req CheckRequest, workspaceDir string) *Job
CreateJob creates a new job with a unique ID.
func (*JobStore) SetResult ¶
func (s *JobStore) SetResult(id string, result *output.JSONOutput)
SetResult sets the result of a job and marks it as completed.
func (*JobStore) UpdateStatus ¶
UpdateStatus updates the status of a job.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents the HTTP server.
func NewServer ¶
func NewServer(host string, port int, jobStore *JobStore, queue *JobQueue, workspaceDir string, cleanupAfter bool, apiToken string) *Server
NewServer creates a new HTTP server.
func (*Server) ListenAndServe ¶
ListenAndServe starts the server.
type WorkspaceManager ¶
type WorkspaceManager struct {
// contains filtered or unexported fields
}
WorkspaceManager manages temporary workspaces for cloning repositories.
func NewWorkspaceManager ¶
func NewWorkspaceManager(baseDir string, cleanupAfter bool) *WorkspaceManager
NewWorkspaceManager creates a new workspace manager.
func (*WorkspaceManager) Cleanup ¶
func (wm *WorkspaceManager) Cleanup(workspaceDir string) error
Cleanup removes a workspace directory.
func (*WorkspaceManager) CleanupOld ¶
func (wm *WorkspaceManager) CleanupOld(maxAge time.Duration) (int, error)
CleanupOld removes workspace directories older than the specified duration.
func (*WorkspaceManager) CreateWorkspace ¶
func (wm *WorkspaceManager) CreateWorkspace(jobID string) (string, error)
CreateWorkspace creates a new workspace directory for a job.