Documentation
¶
Overview ¶
Package handlers implements HTTP handlers for the ploy server API.
pull.go implements the "pull resolution" endpoints for fetching diffs. These endpoints help CLI clients resolve run identifiers needed to pull diffs from the server.
Endpoints:
- POST /v1/runs/{run_id}/pull — resolve repo metadata for a run
- POST /v1/migs/{mig_id}/pull — resolve repo for a mig (last succeeded/failed)
Index ¶
- Constants
- func RegisterRoutes(s *httpserver.Server, st store.Store, bs blobstore.Store, ...)
- type ConfigHolder
- func (h *ConfigHolder) AddBundleMapping(hash, bundleID string)
- func (h *ConfigHolder) AddConfigIn(section string, entry ConfigInEntry)
- func (h *ConfigHolder) DeleteConfigIn(section, dst string)
- func (h *ConfigHolder) DeleteGlobalEnvVar(key string, target domaintypes.GlobalEnvTarget)
- func (h *ConfigHolder) GetBundleMap() map[string]string
- func (h *ConfigHolder) GetGlobalEnvAll() map[string][]GlobalEnvVar
- func (h *ConfigHolder) GetGlobalEnvEntries(key string) []GlobalEnvVar
- func (h *ConfigHolder) GetHydraOverlays() map[string]*HydraJobConfig
- func (h *ConfigHolder) SetConfigIn(section string, entries []ConfigInEntry)
- func (h *ConfigHolder) SetGlobalEnvVar(key string, v GlobalEnvVar)
- type ConfigInEntry
- type GlobalEnvVar
- type HydraJobConfig
- type JobResourcesPayload
- type JobStatsPayload
- type RepoRunSummary
- type RepoSummary
- type RunResponse
- type WaveRunStarter
- type WaveSummary
Constants ¶
const DefaultMaxBodySize = 1 << 20
DefaultMaxBodySize is the default request body size limit (1 MiB).
Variables ¶
This section is empty.
Functions ¶
func RegisterRoutes ¶
func RegisterRoutes(s *httpserver.Server, st store.Store, bs blobstore.Store, bp *blobpersist.Service, eventsService *events.Service, configHolder *ConfigHolder, tokenSecret string, gitAuth gitauth.Options, snapshots repoSnapshotWriter)
RegisterRoutes mounts all HTTP endpoints on the given server.
Types ¶
type ConfigHolder ¶
type ConfigHolder struct {
// contains filtered or unexported fields
}
ConfigHolder provides thread-safe access to runtime configuration, including global environment variables and typed Hydra overlays. Global env is stored as key → []GlobalEnvVar to support multiple targets per key. Hydra overlays are stored per section (pre_gate, post_gate, mig). Config In entries are section-keyed and synced into hydra overlays.
func NewConfigHolder ¶
func NewConfigHolder(globalEnv map[string][]GlobalEnvVar) *ConfigHolder
NewConfigHolder creates a new config holder with an optional multi-target map of global environment variables.
func (*ConfigHolder) AddBundleMapping ¶
func (h *ConfigHolder) AddBundleMapping(hash, bundleID string)
AddBundleMapping stores a shortHash → bundleID mapping so that the claim mutator can thread server-side bundle references into spec bundle_map.
func (*ConfigHolder) AddConfigIn ¶
func (h *ConfigHolder) AddConfigIn(section string, entry ConfigInEntry)
AddConfigIn adds or replaces an in entry by destination in a section (dedup by dst, sort by dst).
func (*ConfigHolder) DeleteConfigIn ¶
func (h *ConfigHolder) DeleteConfigIn(section, dst string)
DeleteConfigIn removes an in entry by destination from a section.
func (*ConfigHolder) DeleteGlobalEnvVar ¶
func (h *ConfigHolder) DeleteGlobalEnvVar(key string, target domaintypes.GlobalEnvTarget)
DeleteGlobalEnvVar removes a global environment variable by key and target. No-op if the key+target does not exist. Persistence is the caller's responsibility.
func (*ConfigHolder) GetBundleMap ¶
func (h *ConfigHolder) GetBundleMap() map[string]string
GetBundleMap returns a copy of all shortHash → bundleID mappings.
func (*ConfigHolder) GetGlobalEnvAll ¶
func (h *ConfigHolder) GetGlobalEnvAll() map[string][]GlobalEnvVar
GetGlobalEnvAll returns a copy of all global environment entries grouped by key. Each key maps to a slice of entries (one per target).
func (*ConfigHolder) GetGlobalEnvEntries ¶
func (h *ConfigHolder) GetGlobalEnvEntries(key string) []GlobalEnvVar
GetGlobalEnvEntries retrieves all entries for a key (one per target). Returns nil if the key does not exist.
func (*ConfigHolder) GetHydraOverlays ¶
func (h *ConfigHolder) GetHydraOverlays() map[string]*HydraJobConfig
GetHydraOverlays returns a deep copy of all Hydra overlays keyed by section.
func (*ConfigHolder) SetConfigIn ¶
func (h *ConfigHolder) SetConfigIn(section string, entries []ConfigInEntry)
SetConfigIn replaces the in entry set for a section and syncs into hydra overlays.
func (*ConfigHolder) SetGlobalEnvVar ¶
func (h *ConfigHolder) SetGlobalEnvVar(key string, v GlobalEnvVar)
SetGlobalEnvVar sets or updates a global environment variable by key+target. If an entry for this key+target already exists, it is replaced. Persistence to the store is the caller's responsibility.
type ConfigInEntry ¶
type ConfigInEntry struct {
Entry string `json:"entry"`
Dst string `json:"dst"`
Section string `json:"section"`
}
ConfigInEntry represents a single global in mount entry with its section.
type GlobalEnvVar ¶
type GlobalEnvVar struct {
Value string `json:"value"`
Target domaintypes.GlobalEnvTarget `json:"target"`
Secret bool `json:"secret"`
}
GlobalEnvVar represents a single global environment variable with its metadata. Used by ConfigHolder to track global env entries in memory. The Target field uses a typed enum (GlobalEnvTarget) to prevent typo-class bugs in target routing logic.
type HydraJobConfig ¶
HydraJobConfig holds the typed Hydra overlay fields for a single job section. Used by the claim mutator pipeline to merge server-side configuration into the claim spec using per-field merge strategies.
func (*HydraJobConfig) IsEmpty ¶
func (c *HydraJobConfig) IsEmpty() bool
IsEmpty reports whether all fields are empty.
type JobResourcesPayload ¶
type JobResourcesPayload struct {
CPUConsumedNs int64 `json:"cpu_consumed_ns,omitempty"`
DiskConsumedBytes int64 `json:"disk_consumed_bytes,omitempty"`
MemConsumedBytes int64 `json:"mem_consumed_bytes,omitempty"`
}
JobResourcesPayload contains per-job container resource consumption metrics.
type JobStatsPayload ¶
type JobStatsPayload struct {
// JobMeta is the structured gate/build/mig metadata to persist in jobs.meta JSONB.
// When present, it is validated via contracts.UnmarshalJobMeta before persisting.
// Empty/null values are treated as "no job meta" (not persisted).
JobMeta json.RawMessage `json:"job_meta,omitempty"`
// Metadata contains optional string key-value pairs for run-level context.
Metadata map[string]string `json:"metadata,omitempty"`
// DurationMs is the job execution duration in milliseconds (informational).
DurationMs int64 `json:"duration_ms,omitempty"`
// Error is an optional terminal error summary provided by node runtime.
// This is populated for infrastructure/runtime failures where no structured
// job_meta is available.
Error string `json:"error,omitempty"`
// JobResources carries per-job container resource consumption metrics.
// When present, the handler persists a row in ploy.job_metrics.
JobResources *JobResourcesPayload `json:"job_resources,omitempty"`
}
JobStatsPayload is the typed structure for the stats field in job completion. This replaces untyped map[string]any decoding at the API boundary, providing schema control over incoming stats payloads.
Wire format example:
{
"job_meta": { "kind": "gate", "gate": { ... } },
"metadata": { "reason": "..." },
"duration_ms": 1234
}
The job_meta field, when present, must be valid per contracts.UnmarshalJobMeta. The metadata field contains string key-value pairs for run-level metadata merging.
func (JobStatsPayload) ErrorMessage ¶
func (p JobStatsPayload) ErrorMessage() string
ErrorMessage returns the terminal error text from stats.error when present.
func (JobStatsPayload) HasJobMeta ¶
func (p JobStatsPayload) HasJobMeta() bool
HasJobMeta returns true if job_meta is present and non-empty. Empty JSON objects ("{}") and null are treated as "no job meta".
func (JobStatsPayload) HasJobResources ¶
func (p JobStatsPayload) HasJobResources() bool
HasJobResources returns true if job_resources is present.
func (JobStatsPayload) ValidateJobMeta ¶
func (p JobStatsPayload) ValidateJobMeta() error
ValidateJobMeta validates the job_meta field using contracts.UnmarshalJobMeta. Returns nil if job_meta is absent/empty or if it passes validation. Returns an error describing the validation failure if job_meta is invalid.
func (JobStatsPayload) ValidateJobResources ¶
func (p JobStatsPayload) ValidateJobResources() error
ValidateJobResources validates non-negative job resource values.
type RepoRunSummary ¶
type RepoRunSummary struct {
RunID domaintypes.RunID `json:"run_id"`
MigID domaintypes.MigID `json:"mig_id"`
RunStatus domaintypes.RunStatus `json:"run_status"`
BaseRef string `json:"base_ref"`
Attempt int32 `json:"attempt"`
StartedAt *time.Time `json:"started_at,omitempty"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
}
RepoRunSummary is returned by GET /v1/repos/{repo_id}/runs.
type RepoSummary ¶
type RepoSummary struct {
RepoID domaintypes.RepoID `json:"repo_id"`
RepoURL string `json:"repo_url"`
LastRunAt *time.Time `json:"last_run_at,omitempty"`
LastStatus *string `json:"last_status,omitempty"`
}
RepoSummary is returned by GET /v1/repos.
type RunResponse ¶
type RunResponse struct {
RunID domaintypes.RunID `json:"run_id"`
RepoID domaintypes.RepoID `json:"repo_id"`
RepoURL string `json:"repo_url"`
BaseRef string `json:"base_ref"`
SourceCommitSHA string `json:"source_commit_sha,omitempty"`
Status domaintypes.RunStatus `json:"status"`
Attempt int32 `json:"attempt"`
LastError *string `json:"last_error,omitempty"`
CreatedAt time.Time `json:"created_at"`
StartedAt *time.Time `json:"started_at,omitempty"`
FinishedAt *time.Time `json:"finished_at,omitempty"`
}
RunResponse represents one runsitory run within a wave for API responses. Exposes repo URL, refs, attempt count, status, error, and timing fields. v1 model: runs stores one runsitory execution; repo_id refers to runs.id.
type WaveRunStarter ¶
type WaveRunStarter struct {
// contains filtered or unexported fields
}
WaveRunStarter starts execution for queued runs in waves. It implements the wavescheduler.RunStarter interface.
func NewWaveRunStarter ¶
func NewWaveRunStarter(st store.Store, bs blobstore.Store) *WaveRunStarter
NewWaveRunStarter creates a new WaveRunStarter with the given store.
func (*WaveRunStarter) StartQueuedRuns ¶
func (s *WaveRunStarter) StartQueuedRuns(ctx context.Context, waveID domaintypes.WaveID) (wavescheduler.StartQueuedRunsResult, error)
StartQueuedRuns creates (or advances) job queues for queued runs in a wave.
type WaveSummary ¶
type WaveSummary struct {
ID domaintypes.WaveID `json:"id"`
MigID domaintypes.MigID `json:"mig_id"`
SpecID domaintypes.SpecID `json:"spec_id"`
CreatedBy *string `json:"created_by,omitempty"`
Status domaintypes.WaveStatus `json:"status"`
CreatedAt string `json:"created_at"`
StartedAt *string `json:"started_at,omitempty"`
FinishedAt *string `json:"finished_at,omitempty"`
Counts *domaintypes.RunCounts `json:"run_counts,omitempty"`
}
Source Files
¶
- artifacts_download.go
- artifacts_run.go
- artifacts_shared.go
- bootstrap.go
- claim_detected_stack.go
- claim_spec_mutator_base.go
- claim_spec_mutator_hydra.go
- claim_spec_mutator_pipeline.go
- config_env.go
- config_gitlab.go
- diffs.go
- effective_source.go
- events.go
- health.go
- ingest_common.go
- jobs_artifact.go
- jobs_complete.go
- jobs_complete_cancel_chain.go
- jobs_complete_logic.go
- jobs_complete_service.go
- jobs_complete_service_meta.go
- jobs_complete_service_post_actions.go
- jobs_complete_service_types.go
- jobs_diff.go
- jobs_image_name.go
- jobs_list.go
- jobs_logs.go
- jobs_sbom.go
- jobs_status.go
- migs_archive.go
- migs_crud.go
- migs_repos.go
- migs_runs.go
- migs_spec.go
- migs_ticket.go
- nodes.go
- nodes_claim.go
- nodes_claim_response.go
- nodes_claim_service.go
- nodes_diagnostics.go
- nodes_events.go
- nodes_heartbeat.go
- nodes_logs.go
- process_group_cancel_unix.go
- pull.go
- register.go
- repo_lookup.go
- repo_sha_chain_dynamic.go
- repo_sha_seed.go
- repo_url_auth.go
- repos.go
- runs.go
- runs_batch_http.go
- runs_jobs.go
- runs_sbom.go
- runs_snapshot.go
- runs_submit.go
- runs_wave_scheduler.go
- spec_bundles.go
- specs.go
- tokens.go
- waves.go