Help us shape the future of Go! Take the 2026 Go Developer Survey

policy

package
v0.2.44 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForbiddenPath

func ForbiddenPath(pattern, file string) bool

func RouteAllowed added in v0.2.38

func RouteAllowed(routes []string, connection, name string) bool

func Validate

func Validate(p Policy) error

Types

type Action

type Action string
const (
	Read    Action = "read"
	Repair  Action = "repair"
	Publish Action = "publish"
	Merge   Action = "merge"
	Deploy  Action = "deploy"
	Recover Action = "recover"
)

type Binding

type Binding struct {
	Head              string `json:"head"`
	Target            string `json:"target"`
	Tested            string `json:"tested"`
	PolicyHash        string `json:"policy_hash"`
	ProviderRules     string `json:"provider_rules"`
	CapabilityVersion string `json:"capability_version"`
	SourceSHA         string `json:"source_sha"`
	Artifact          string `json:"artifact"`
}

type Defaults

type Defaults struct {
	ConnectionID string `json:"connection_id,omitempty"`
	Model        string `json:"model,omitempty"`
	Route        string `json:"route,omitempty"`
	BranchPrefix string `json:"branch_prefix,omitempty"`
}

type Evidence

type Evidence struct {
	ID         string    `json:"id"`
	Identity   string    `json:"identity,omitempty"`
	State      string    `json:"state"`
	Approvals  int       `json:"approvals"`
	Binding    Binding   `json:"binding"`
	ObservedAt time.Time `json:"observed_at"`
	Reference  string    `json:"reference"`
}

type Input

type Input struct {
	Stage              string     `json:"stage,omitempty"`
	Action             Action     `json:"action"`
	Recipe             string     `json:"recipe"`
	Model              string     `json:"model"`
	Route              string     `json:"route"`
	MergeMethod        string     `json:"merge_method"`
	Environment        string     `json:"environment"`
	Workflow           string     `json:"workflow"`
	Paths              []string   `json:"paths"`
	Usage              Limits     `json:"usage"`
	Current            Binding    `json:"current"`
	StartingPolicyHash string     `json:"starting_policy_hash"`
	Evidence           []Evidence `json:"evidence"`
	PausedScopes       []string   `json:"paused_scopes"`
	Now                time.Time  `json:"now"`
}

type Layer

type Layer struct {
	Scope          Scope  `json:"scope"`
	VersionID      string `json:"version_id"`
	BindingVersion int64  `json:"binding_version"`
	Policy         Policy `json:"policy"`
}

type Limits

type Limits struct {
	Budget       *int64 `json:"budget,omitempty"`
	Concurrency  *int64 `json:"concurrency,omitempty"`
	Attempts     *int64 `json:"attempts,omitempty"`
	ChangedFiles *int64 `json:"changed_files,omitempty"`
	ChangedLines *int64 `json:"changed_lines,omitempty"`
	OpenChanges  *int64 `json:"open_changes,omitempty"`
}

type Lists

type Lists struct {
	Recipes      []string `json:"recipes"`
	Models       []string `json:"models"`
	Routes       []string `json:"routes"`
	MergeMethods []string `json:"merge_methods"`
	Environments []string `json:"environments"`
	Workflows    []string `json:"workflows"`
}

type Policy

type Policy struct {
	RepositorySetupRequired bool          `json:"repository_setup_required,omitempty"`
	Schema                  string        `json:"schema"`
	Allow                   Lists         `json:"allow"`
	Deny                    []Action      `json:"deny"`
	ForbiddenPaths          []string      `json:"forbidden_paths"`
	ReviewProofs            []string      `json:"review_proofs,omitempty"`
	Limits                  Limits        `json:"limits"`
	Required                []Requirement `json:"required"`
	Defaults                Defaults      `json:"defaults"`
	MaxEvidenceAgeSeconds   *int64        `json:"max_evidence_age_seconds,omitempty"`
	Paused                  bool          `json:"paused"`
}

func Parse

func Parse(data []byte) (Policy, error)

type Requirement

type Requirement struct {
	ID        string   `json:"id"`
	Identity  string   `json:"identity,omitempty"`
	Actions   []Action `json:"actions"`
	Approvals int      `json:"approvals,omitempty"`
}

type Resolved

type Resolved struct {
	Hash            string   `json:"hash"`
	Layers          []Layer  `json:"layers"`
	PrimaryTeamID   string   `json:"primary_team_id,omitempty"`
	RepositoryID    string   `json:"repository_id"`
	Paused          bool     `json:"paused"`
	Policy          Policy   `json:"policy"`
	ScopePaused     bool     `json:"scope_paused"`
	MissingDefaults []string `json:"missing_defaults"`
	Problems        []string `json:"problems"`
}

func Resolve

func Resolve(layers []Layer, repositoryID, primaryTeamID string, paused bool) Resolved

type Result

type Result struct {
	domain.Decision
	Bindings           []Layer  `json:"bindings"`
	EvidenceReferences []string `json:"evidence_references"`
	StartingPolicyHash string   `json:"starting_policy_hash"`
}

func Evaluate

func Evaluate(r Resolved, in Input) Result

type Scope

type Scope struct {
	Kind string `json:"kind"`
	ID   string `json:"id"`
}

type Service

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

func New

func New(db *store.Store, identity *auth.Service, deployment Policy) (*Service, error)

func (*Service) Activate

func (s *Service) Activate(ctx context.Context, session auth.Session, orgID, versionID, repoID, primaryTeamID string, expected int64, simulationHash, reason, requestID string) (int64, error)

func (*Service) ApplyMaintenanceTx added in v0.2.38

func (s *Service) ApplyMaintenanceTx(ctx context.Context, tx pgx.Tx, org, repo, actor, request string, p Policy, initialize bool) error

func (*Service) CreateVersion

func (s *Service) CreateVersion(ctx context.Context, session auth.Session, orgID string, scope Scope, p Policy, reason, requestID string) (Version, error)

func (*Service) EvaluateTx

func (s *Service) EvaluateTx(ctx context.Context, tx pgx.Tx, orgID, repoID string, in Input) (Result, error)

func (*Service) GetVersion

func (s *Service) GetVersion(ctx context.Context, session auth.Session, orgID, id string) (Version, error)

func (*Service) ListVersions

func (s *Service) ListVersions(ctx context.Context, session auth.Session, orgID string, scope Scope, limit int, cursor string) (domain.Page[Version], error)

func (*Service) MaintenanceTx added in v0.2.38

func (s *Service) MaintenanceTx(ctx context.Context, tx pgx.Tx, org, repo, mode, model, route, connection string, cap int64, initialize bool) (Resolved, Policy, error)

func (*Service) Resolve

func (s *Service) Resolve(ctx context.Context, session auth.Session, orgID, repoID string) (Resolved, error)

func (*Service) ResolveTx

func (s *Service) ResolveTx(ctx context.Context, tx pgx.Tx, orgID, repoID string) (Resolved, error)

func (*Service) Simulate

func (s *Service) Simulate(ctx context.Context, session auth.Session, orgID, versionID, repoID, primaryTeamID string, in Input) (Simulation, error)

type Simulation

type Simulation struct {
	Hash     string   `json:"hash"`
	Resolved Resolved `json:"resolved"`
	Decision Result   `json:"decision"`
}

type Version

type Version struct {
	ID        string    `json:"id"`
	Scope     Scope     `json:"scope"`
	Policy    Policy    `json:"policy"`
	Hash      string    `json:"hash"`
	ActorID   string    `json:"actor_id"`
	Reason    string    `json:"reason"`
	CreatedAt time.Time `json:"created_at"`
}

Jump to

Keyboard shortcuts

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