Documentation ¶
Overview ¶
Package builder provides simple and easy-to-use way to construct Aptomi Policy in the source code, primarily for unit tests.
Index ¶
- type PolicyBuilder
- func (builder *PolicyBuilder) AddBundle() *lang.Bundle
- func (builder *PolicyBuilder) AddBundleComponent(bundle *lang.Bundle, component *lang.BundleComponent) *lang.BundleComponent
- func (builder *PolicyBuilder) AddClaim(user *lang.User, service *lang.Service) *lang.Claim
- func (builder *PolicyBuilder) AddCluster() *lang.Cluster
- func (builder *PolicyBuilder) AddComponentClaim(component *lang.BundleComponent, dependsOn *lang.BundleComponent)
- func (builder *PolicyBuilder) AddRule(criteria *lang.Criteria, actions *lang.RuleActions) *lang.Rule
- func (builder *PolicyBuilder) AddService(bundle *lang.Bundle, criteria *lang.Criteria) *lang.Service
- func (builder *PolicyBuilder) AddServiceMultipleContexts(bundle *lang.Bundle, criteriaArray ...*lang.Criteria) *lang.Service
- func (builder *PolicyBuilder) AddUser() *lang.User
- func (builder *PolicyBuilder) AddUserDomainAdmin() *lang.User
- func (builder *PolicyBuilder) AllocationKeys(key ...string) []string
- func (builder *PolicyBuilder) CodeComponent(codeParams util.NestedParameterMap, discoveryParams util.NestedParameterMap) *lang.BundleComponent
- func (builder *PolicyBuilder) Criteria(all string, any string, none string) *lang.Criteria
- func (builder *PolicyBuilder) CriteriaTrue() *lang.Criteria
- func (builder *PolicyBuilder) External() *external.Data
- func (builder *PolicyBuilder) Namespace() string
- func (builder *PolicyBuilder) PanicWhenLoadingUsers()
- func (builder *PolicyBuilder) Policy() *lang.Policy
- func (builder *PolicyBuilder) RuleActions(labelOps lang.LabelOperations) *lang.RuleActions
- func (builder *PolicyBuilder) ServiceComponent(service *lang.Service) *lang.BundleComponent
- func (builder *PolicyBuilder) SwitchNamespace(namespace string)
- func (builder *PolicyBuilder) UnknownComponent() *lang.BundleComponent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PolicyBuilder ¶
type PolicyBuilder struct {
// contains filtered or unexported fields
}
PolicyBuilder provides simple and easy-to-use way to construct a complete Policy for Aptomi in the source code. It is primarily used in unit tests. When objects are created/added by the policy builder, they get created in the specified namespace with randomly generated IDs/names, so that a user doesn't have to specify them.
func NewPolicyBuilder ¶
func NewPolicyBuilder() *PolicyBuilder
NewPolicyBuilder creates a new PolicyBuilder with a default "main" namespace
func NewPolicyBuilderWithNS ¶
func NewPolicyBuilderWithNS(namespace string) *PolicyBuilder
NewPolicyBuilderWithNS creates a new PolicyBuilder
func (*PolicyBuilder) AddBundle ¶ added in v0.1.15
func (builder *PolicyBuilder) AddBundle() *lang.Bundle
AddBundle creates a new bundle and adds it to the policy
func (*PolicyBuilder) AddBundleComponent ¶ added in v0.1.15
func (builder *PolicyBuilder) AddBundleComponent(bundle *lang.Bundle, component *lang.BundleComponent) *lang.BundleComponent
AddBundleComponent adds a given bundle component to the bundle
func (*PolicyBuilder) AddClaim ¶ added in v0.1.15
AddClaim creates a new claim and adds it to the policy
func (*PolicyBuilder) AddCluster ¶
func (builder *PolicyBuilder) AddCluster() *lang.Cluster
AddCluster creates a new cluster and adds it to the policy
func (*PolicyBuilder) AddComponentClaim ¶ added in v0.1.15
func (builder *PolicyBuilder) AddComponentClaim(component *lang.BundleComponent, dependsOn *lang.BundleComponent)
AddComponentClaim adds a component claim on another component
func (*PolicyBuilder) AddRule ¶
func (builder *PolicyBuilder) AddRule(criteria *lang.Criteria, actions *lang.RuleActions) *lang.Rule
AddRule creates a new rule and adds it to the policy
func (*PolicyBuilder) AddService ¶
func (builder *PolicyBuilder) AddService(bundle *lang.Bundle, criteria *lang.Criteria) *lang.Service
AddService creates a new service for a given bundle and adds it to the policy
func (*PolicyBuilder) AddServiceMultipleContexts ¶ added in v0.1.15
func (builder *PolicyBuilder) AddServiceMultipleContexts(bundle *lang.Bundle, criteriaArray ...*lang.Criteria) *lang.Service
AddServiceMultipleContexts creates service with multiple contexts for a given bundle and adds it to the policy
func (*PolicyBuilder) AddUser ¶
func (builder *PolicyBuilder) AddUser() *lang.User
AddUser creates a new user who can consume bundles from the 'main' namespace and adds it to the policy
func (*PolicyBuilder) AddUserDomainAdmin ¶
func (builder *PolicyBuilder) AddUserDomainAdmin() *lang.User
AddUserDomainAdmin creates a new user who is a domain admin and adds it to the policy
func (*PolicyBuilder) AllocationKeys ¶
func (builder *PolicyBuilder) AllocationKeys(key ...string) []string
AllocationKeys creates allocation keys
func (*PolicyBuilder) CodeComponent ¶
func (builder *PolicyBuilder) CodeComponent(codeParams util.NestedParameterMap, discoveryParams util.NestedParameterMap) *lang.BundleComponent
CodeComponent creates a new code component for a bundle
func (*PolicyBuilder) Criteria ¶
Criteria creates a criteria with one require-all, one require-any, and one require-none
func (*PolicyBuilder) CriteriaTrue ¶
func (builder *PolicyBuilder) CriteriaTrue() *lang.Criteria
CriteriaTrue creates a criteria which always evaluates to true
func (*PolicyBuilder) External ¶
func (builder *PolicyBuilder) External() *external.Data
External returns the generated external data
func (*PolicyBuilder) Namespace ¶
func (builder *PolicyBuilder) Namespace() string
Namespace returns the current namespace
func (*PolicyBuilder) PanicWhenLoadingUsers ¶ added in v0.1.2
func (builder *PolicyBuilder) PanicWhenLoadingUsers()
PanicWhenLoadingUsers tells mock user loader to start panicking when loading users
func (*PolicyBuilder) Policy ¶
func (builder *PolicyBuilder) Policy() *lang.Policy
Policy returns the generated policy
func (*PolicyBuilder) RuleActions ¶
func (builder *PolicyBuilder) RuleActions(labelOps lang.LabelOperations) *lang.RuleActions
RuleActions creates a new RuleActions object
func (*PolicyBuilder) ServiceComponent ¶ added in v0.1.15
func (builder *PolicyBuilder) ServiceComponent(service *lang.Service) *lang.BundleComponent
ServiceComponent creates a new service component for a bundle
func (*PolicyBuilder) SwitchNamespace ¶
func (builder *PolicyBuilder) SwitchNamespace(namespace string)
SwitchNamespace switches the current namespace where objects will be generated
func (*PolicyBuilder) UnknownComponent ¶
func (builder *PolicyBuilder) UnknownComponent() *lang.BundleComponent
UnknownComponent creates an unknown component for a bundle (not code and not service)