Documentation
¶
Overview ¶
Package server provides the HTTP server exposing /healthz, /metrics, and the git webhook endpoint.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DiffEntry ¶
type DiffEntry struct {
JobID string `json:"job_id"`
HCLFile string `json:"hcl_file,omitempty"`
DiffType string `json:"diff_type"`
Detail string `json:"detail"`
ApplyAction string `json:"apply_action,omitempty"`
}
DiffEntry is one element of HealthResponse.Diffs.
type DiffSource ¶
type DiffSource interface {
Diffs() ([]nomad.JobDiff, time.Time, string)
SelectedJobs() ([]nomad.SelectedJob, time.Time, string)
// Updates returns a snapshot of the GitOps update queue.
Updates() []nomad.JobUpdate
// Ready reports whether at least one diff check has completed.
Ready() bool
}
DiffSource is satisfied by *nomad.Differ.
type GitStatusSource ¶
type GitStatusSource interface {
Trigger()
Status() (lastCommit string, lastUpdate time.Time)
// Ready reports whether the initial git clone has completed.
Ready() bool
}
GitStatusSource is satisfied by *gitwatch.Watcher.
type HealthResponse ¶
type HealthResponse struct {
Status string `json:"status"`
Message string `json:"message,omitempty"`
DiffCount int `json:"diff_count"`
Diffs []DiffEntry `json:"diffs"`
LastCheck string `json:"last_check,omitempty"`
GitCommit string `json:"git_commit,omitempty"`
GitUpdated string `json:"git_updated,omitempty"`
}
HealthResponse is the JSON body returned by /healthz.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server holds the HTTP mux and all dependencies.
func New ¶
func New(cfg *config.Config, diffs DiffSource, git GitStatusSource, info BuildInfo) *Server
New creates a Server that registers Prometheus metrics into the default registry.
func NewWithRegistry ¶
func NewWithRegistry(cfg *config.Config, diffs DiffSource, git GitStatusSource, info BuildInfo, reg prometheus.Registerer) *Server
NewWithRegistry creates a Server with a custom Prometheus Registerer. Useful in tests to avoid duplicate-registration panics when creating multiple servers.
Click to show internal directories.
Click to hide internal directories.