Documentation ¶
Index ¶
Constants ¶
const ( SubmissionVariable = "submission" // ${submission} HeaderVariable = "header" // ${header} )
Known variable names
Variables ¶
This section is empty.
Functions ¶
func IsVariable ¶
IsVariable determines if a string is a variable (e.g. of the form '${foo.bar.baz}')
Types ¶
type Condition ¶
type Condition map[string]interface{}
Condition in the policy rules DSL is a json object that determines whether a policy applies or not. It is generally of the form
{ "anyOf": [ {"equals":{"one": "two"}}, {"endsWith":{"one": "gone"}} ] }
type Context ¶
type Context struct { SubmissionURI string Headers map[string][]string PassClient PassEntityFetcher // contains filtered or unexported fields }
Context establishes a rule evaluation/resolution context.
func (*Context) Pin ¶
func (c *Context) Pin(variable, value string) VariablePinner
type DSL ¶
DSL encapsulates to a policy rules document
type PassEntityFetcher ¶
PassEntityFetcher retrieves the JSON-LD content at the given url, and un-marshals it into the provided struct.
entityPointer is expected to be a pointer to a struct or map (i.e. anything encoding/json can un-marshal into). An error will be returned otherwise.
type Policy ¶
type Policy struct { ID string `json:"policy-id"` Description string `json:"description"` Type string `json:"type"` Repositories []Repository `json:"repositories"` Conditions []Condition `json:"conditions"` }
Policy encapsulates a policy rule.
type PolicyResolver ¶ added in v0.1.0
type PolicyResolver interface {
Resolve(variables VariablePinner) ([]Policy, error)
}
type Repository ¶
func (Repository) Resolve ¶
func (r Repository) Resolve(variables VariableResolver) ([]Repository, error)
type Requirements ¶ added in v0.1.0
type Requirements struct { Required []Repository `json:"required"` OneOf [][]Repository `json:"one-of"` Optional []Repository `json:"optional"` }
Requirements encapsulates deposit requirements by sorting repositories into "required", 'oneOf', and 'optional' buckets
func AnalyzeRequirements ¶ added in v0.1.0
func AnalyzeRequirements(policies []Policy) *Requirements
AnalyzeRequirements analyzes a list of policies, and returns repository requirements
func (*Requirements) Keep ¶ added in v0.1.0
func (r *Requirements) Keep(keep []Repository) *Requirements
Keep removes any repositories that are not in the keep list) Such repositories are presumed to have been deposited to by some means outside of pass. For example, for requirements OneOf: {a, b} with keep {a}, the result is Optional {a}
func (*Requirements) TranslateURIs ¶ added in v0.1.0
func (r *Requirements) TranslateURIs(replace func(string) (string, bool)) *Requirements
TranslateURIs applies the given function to all URIs (mutating them), and returns itself
type VariablePinner ¶
type VariablePinner interface { VariableResolver Pin(variable, value string) VariablePinner // return a VariablePinner that pins a variable to the given value }
VariablePinner is a variable resolver that can pin variables to specific values
type VariableResolver ¶
VariableResolver resolves a variable (a string of form "${foo.bar.baz}"), and returns a list of values