Documentation
¶
Overview ¶
Package gate provides a deploy approval gate service. It creates time-limited approval requests, notifies operators via Signal, and serves a web UI for reviewing and approving deployments.
Index ¶
- Variables
- func GenerateID() (string, error)
- func GenerateToken() (string, error)
- type Approval
- type ApprovalRequest
- type ApprovalStatus
- type ApprovalStore
- type Handler
- func (h *Handler) CreateApproval(w http.ResponseWriter, r *http.Request)
- func (h *Handler) GetApproval(w http.ResponseWriter, r *http.Request)
- func (h *Handler) ProcessApproval(w http.ResponseWriter, r *http.Request)
- func (h *Handler) SendNotification(w http.ResponseWriter, r *http.Request)
- func (h *Handler) ShowApprovalPage(w http.ResponseWriter, r *http.Request)
- type SignalClient
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = axon.ErrNotFound ErrAlreadyResolved = errors.New("approval already resolved") )
Functions ¶
func GenerateID ¶
func GenerateToken ¶
Types ¶
type Approval ¶
type Approval struct {
ID string `json:"id"`
Service string `json:"service"`
Commit string `json:"commit"`
Branch string `json:"branch"`
Summary string `json:"summary"`
Agent string `json:"agent"`
Username string `json:"username"`
Token string `json:"-"`
Status ApprovalStatus `json:"status"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt time.Time `json:"expires_at"`
ResolvedAt *time.Time `json:"resolved_at"`
ResolvedBy string `json:"resolved_by,omitempty"`
}
Approval represents a deploy approval request with status tracking and expiry.
type ApprovalRequest ¶
type ApprovalRequest struct {
Service string `json:"service"`
Commit string `json:"commit"`
Branch string `json:"branch"`
Summary string `json:"summary"`
Agent string `json:"agent"`
Username string `json:"username"`
}
ApprovalRequest is the input for creating a new approval.
type ApprovalStatus ¶
type ApprovalStatus string
const ( StatusPending ApprovalStatus = "pending" StatusApproved ApprovalStatus = "approved" StatusDenied ApprovalStatus = "denied" )
type ApprovalStore ¶
type ApprovalStore interface {
Create(ctx context.Context, req ApprovalRequest) (*Approval, error)
Get(ctx context.Context, id string) (*Approval, error)
Resolve(ctx context.Context, id string, status ApprovalStatus, resolvedBy string) error
}
ApprovalStore defines the persistence interface for approvals.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves the approval API endpoints and embedded web UI.
func NewHandler ¶
func NewHandler(store ApprovalStore, signal *SignalClient, authClient *axon.AuthClient, baseURL, loginURL string) *Handler
func (*Handler) CreateApproval ¶
func (h *Handler) CreateApproval(w http.ResponseWriter, r *http.Request)
CreateApproval handles POST /api/approvals — create approval, send Signal message.
func (*Handler) GetApproval ¶
func (h *Handler) GetApproval(w http.ResponseWriter, r *http.Request)
GetApproval handles GET /api/approvals/{id} — poll approval status. Returns only the status to avoid leaking metadata to unauthenticated callers.
func (*Handler) ProcessApproval ¶
func (h *Handler) ProcessApproval(w http.ResponseWriter, r *http.Request)
ProcessApproval handles POST /approve/{id} — process approval decision.
func (*Handler) SendNotification ¶
func (h *Handler) SendNotification(w http.ResponseWriter, r *http.Request)
SendNotification handles POST /api/notifications — send informational Signal message.
func (*Handler) ShowApprovalPage ¶
func (h *Handler) ShowApprovalPage(w http.ResponseWriter, r *http.Request)
ShowApprovalPage handles GET /approve/{id} — serve approval page.
type SignalClient ¶
type SignalClient struct {
// contains filtered or unexported fields
}
SignalClient sends notifications via the Signal REST API.
func NewSignalClient ¶
func NewSignalClient(apiURL, recipient string) *SignalClient
func (*SignalClient) Send ¶
func (c *SignalClient) Send(message string) error