approval

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package approval holds pending recipe runs that an OPA policy flagged as require_approval, until an authorized actor approves or denies them. The store is the mechanism; whether approval is required and who may approve is decided by policy. The default store is in-memory with a TTL; runs not decided within the TTL expire.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Record

type Record struct {
	ID        string    `json:"id"`
	Actor     string    `json:"actor"`
	Recipe    string    `json:"recipe"`
	Hosts     []string  `json:"hosts,omitempty"`
	Reason    string    `json:"reason,omitempty"`
	Status    Status    `json:"status"`
	Approver  string    `json:"approver,omitempty"`
	CreatedAt time.Time `json:"created_at"`
	DecidedAt time.Time `json:"decided_at"`
}

Record is one pending run awaiting a decision.

type Status

type Status string

Status is the lifecycle state of a pending run.

const (
	StatusPending  Status = "pending"
	StatusApproved Status = "approved"
	StatusDenied   Status = "denied"
)

Pending-run lifecycle states.

type Store

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

Store keeps pending runs in memory with a TTL. Safe for concurrent use.

func NewStore

func NewStore(ttl time.Duration) *Store

NewStore returns an in-memory store. A zero ttl disables expiry.

func (*Store) Create

func (s *Store) Create(actor, recipe string, hosts []string, reason string) *Record

Create records a new pending run and returns it.

func (*Store) Decide

func (s *Store) Decide(id, approver string, approve bool) (Record, error)

Decide marks a pending record approved or denied by approver. It errors if the record is missing or already decided.

func (*Store) Get

func (s *Store) Get(id string) (Record, bool)

Get returns a copy of the record and whether it exists (and is unexpired).

func (*Store) List

func (s *Store) List() []Record

List returns copies of all unexpired records.

Jump to

Keyboard shortcuts

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