server

package
v0.25.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package server provides HTTP routes and webhook handlers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeployRequest

type DeployRequest struct {
	Service        string `json:"service"`
	HeadRef        string `json:"head_ref"`
	CommitSha      string `json:"commit_sha"`
	PRAuthor       string `json:"pr_author"`
	PRURL          string `json:"pr_url"`
	PRNumber       string `json:"pr_number"`
	WorkflowRunURL string `json:"workflow_run_url"`
}

DeployRequest is the body of POST /v1/deploy. All fields are required; the server stamps timestamp from time.Now() so retries don't drift.

type DeployResponse

type DeployResponse struct {
	PreviewSlug     string   `json:"preview_slug"`
	GitOpsCommitURL string   `json:"gitops_commit_url"`
	Warnings        []string `json:"warnings,omitempty"`
}

DeployResponse is the success body. Warnings is populated when the values write succeeded but the comment fan-out had partial failures.

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

ErrorResponse is the failure body for every non-2xx response.

type Option

type Option func(*Server)

Option configures a Server built by NewServer.

func WithArgoCDToken

func WithArgoCDToken(token string) Option

WithArgoCDToken enables POST /webhooks/argocd, authenticated by the Bearer token. An empty token leaves the route unregistered.

func WithMetrics

func WithMetrics(m *metrics.Metrics) Option

WithMetrics records webhook deliveries and lifecycle outcomes in m.

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(
	webhook WebhookValidator,
	gitops gitopsAPI,
	deployToken string,
	allowedInstallationID int64,
	opts ...Option,
) *Server

func (*Server) Go

func (s *Server) Go(f func())

Go runs f in the background, tracked by WaitBackground. Unlike reconciles, f does not wait for other background jobs.

func (*Server) Handler

func (s *Server) Handler() http.Handler

func (*Server) WaitBackground

func (s *Server) WaitBackground(ctx context.Context) error

WaitBackground blocks until every background job has finished. It returns nil once they are done, or ctx.Err() when ctx expires first.

type SyncRequest added in v0.21.0

type SyncRequest struct {
	Slug *string `json:"slug"`
}

SyncRequest is the optional body of POST /v1/sync. Without a slug, every preview is synced.

type SyncResponse added in v0.21.0

type SyncResponse struct {
	Synced    []string `json:"synced"`
	Unchanged int      `json:"unchanged"`
	Failed    []string `json:"failed"`
}

SyncResponse is the success body of POST /v1/sync: the slugs rewritten, the number of previews left unchanged and the slugs that failed.

type WebhookValidator

type WebhookValidator interface {
	ValidateWebhook(r *http.Request) ([]byte, error)
	ParseEvent(eventType string, payload []byte) (any, error)
}

WebhookValidator validates GitHub webhook signatures and parses payloads into typed event structs.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL