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

applimit

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package applimit decides how many apps a person may own (R-244, issue #131).

Three places may say: the person's own account, their groups, and host policy. The account wins whatever the groups say, so an administrator can make an exception for one person in either direction. Otherwise the most generous group wins, unlimited beating any number, because being in a group should only ever give somebody more. Otherwise host policy. Zero is unlimited wherever it is set; somebody who may not create apps at all is somebody without app.create.

Index

Constants

View Source
const (
	SourceUser   = "user"
	SourceGroup  = "group"
	SourcePolicy = "policy"
)

Where a limit comes from.

Variables

This section is empty.

Functions

func Refusal

func Refusal(l Limit, owned int) error

Refusal is the error for a create past the limit (R-105): the limit, where it comes from, and who can raise it. owned is what the create counted.

Types

type FactsReader

type FactsReader interface {
	Facts(ctx context.Context, userID string) (state.LimitFacts, error)
}

FactsReader reads what a limit is decided from.

type Limit

type Limit struct {
	// Limit is how many apps they may own. 0 is unlimited.
	Limit int `json:"limit"`
	// Source is where it comes from: user, group or policy.
	Source string `json:"source"`
	// GroupID and GroupName name the group, when Source is group.
	GroupID   string `json:"group_id,omitempty"`
	GroupName string `json:"group_name,omitempty"`

	// Owned is how many apps they own now.
	Owned int `json:"owned"`

	// MaxApps is the value set on their own account: null when none is.
	MaxApps *int `json:"max_apps"`
}

Limit is the limit in force for one person, and how close they are to it.

func Resolve

func Resolve(doc policy.Document, f state.LimitFacts) Limit

Resolve applies R-244's order to the facts.

type PolicyLoader

type PolicyLoader interface {
	Load(ctx context.Context) (policy.Document, error)
}

PolicyLoader reads host policy.

type Service

type Service struct {
	Store  FactsReader
	Policy PolicyLoader
}

Service decides limits.

func (*Service) For

func (s *Service) For(ctx context.Context, userID string) (Limit, error)

For is the limit in force for userID.

Jump to

Keyboard shortcuts

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