Documentation
¶
Index ¶
- func RuleFQN(ns, policy, rule string) string
- func ShapeFQN(ns, shape string) string
- type ExportedRule
- type ExportedShape
- type Index
- func (idx *Index) AddProgram(ctx context.Context, astProgram *ast.Program) error
- func (idx *Index) Commit(ctx context.Context) error
- func (idx *Index) IsValid(ctx context.Context) error
- func (idx *Index) ResolveNamespace(ns string) (*Namespace, error)
- func (idx *Index) ResolvePolicy(ns, policy string) (*Policy, error)
- func (idx *Index) ResolveSegments(path string) (ns, policy, rule string, err error)
- func (idx *Index) ResolveShape(ns, shape string) (*Shape, error)
- func (idx *Index) SetPack(ctx context.Context, p *pack.PackFile) error
- func (idx *Index) Validate(ctx context.Context) error
- type Namespace
- type Policy
- func (p *Policy) AddFact(fact *ast.FactStatement) error
- func (p *Policy) AddLet(let *ast.VarDeclaration) error
- func (p *Policy) AddRule(rule *ast.RuleStatement) error
- func (p *Policy) AddShape(shape *ast.ShapeStatement) error
- func (p *Policy) String() string
- func (p Policy) VerifyRuleExported(rule string) error
- type PolicyTagPair
- type Program
- type Rule
- type RuleExportAttachment
- type Shape
- type ShapeModel
- type ShapeModelField
- type String
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ExportedRule ¶
type ExportedRule struct {
RuleName string
Attachments []*RuleExportAttachment // names only; values computed at runtime
}
ExportedRule captures an exported rule's name and its attachment names.
type ExportedShape ¶
type ExportedShape struct {
Statement *ast.ShapeExportStatement
Name string
}
type Index ¶
type Index struct {
Pack *pack.PackFile
Namespaces map[string]*Namespace
Programs map[string]*Program
// contains filtered or unexported fields
}
func CreateIndex ¶
func CreateIndex() *Index
func (*Index) AddProgram ¶
func (*Index) ResolvePolicy ¶
ResolvePolicy tries exact namespace match; it does not traverse parents.
func (*Index) ResolveSegments ¶
type Namespace ¶
type Namespace struct {
Statement *ast.NamespaceStatement
FQN ast.FQN // this is always the FQN
Parent *Namespace
Children []*Namespace
Policies map[string]*Policy
Shapes map[string]*Shape // namespace-level shapes
ShapeExports map[string]*ExportedShape
}
Namespace is an index of policies and shapes visible within (namespace & sub-namespaces).
func (Namespace) IsParentOf ¶
func (Namespace) VerifyShapeExported ¶
type Policy ¶
type Policy struct {
Statement *ast.PolicyStatement
Namespace *Namespace
Name string
FQN ast.FQN
FilePath string
Statements []ast.Statement
Title *string
Description *string
VersionLiteral string
Version *semver.Version
TagPairs []PolicyTagPair
// TagsByKey is derived from TagPairs for query ergonomics; map iteration order is not stable.
TagsByKey map[string][]string
Lets map[string]*ast.VarDeclaration
Facts map[string]*ast.FactStatement
Rules map[string]*Rule
RuleExports map[string]*ExportedRule
Uses map[string]*ast.UseStatement // alias -> use statement
Shapes map[string]*Shape // policy-local shapes
// contains filtered or unexported fields
}
Policy holds the AST statements and exports.
func (Policy) VerifyRuleExported ¶
VerifyRuleExported verifies that a rule is exported in its policy. Returns an error if the rule is not exported.
type PolicyTagPair ¶ added in v0.0.3
PolicyTagPair is one key/value from policy `tag` statements (order preserved in Policy.TagPairs).
type Program ¶
type Program struct {
Reference *ast.Program
Namespace *ast.NamespaceStatement
Policies []*ast.PolicyStatement
Shapes []*ast.ShapeStatement
ShapeExports []*ast.ShapeExportStatement
}
type Rule ¶
type Rule struct {
Node *ast.RuleStatement
Policy *Policy
Name string
FQN ast.FQN
Default ast.Expression
When ast.Expression
Body ast.Expression
}
type RuleExportAttachment ¶
type RuleExportAttachment struct {
Name string
Value ast.Expression
}
type Shape ¶
type ShapeModel ¶
type ShapeModel struct {
WithFQN *ast.FQN
Fields map[string]*ShapeModelField
}
type ShapeModelField ¶
Click to show internal directories.
Click to hide internal directories.