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) AddCluster() *lang.Cluster
- func (builder *PolicyBuilder) AddComponentDependency(component *lang.ServiceComponent, dependsOn *lang.ServiceComponent)
- func (builder *PolicyBuilder) AddContract(service *lang.Service, criteria *lang.Criteria) *lang.Contract
- func (builder *PolicyBuilder) AddContractMultipleContexts(service *lang.Service, criteriaArray ...*lang.Criteria) *lang.Contract
- func (builder *PolicyBuilder) AddDependency(user *lang.User, contract *lang.Contract) *lang.Dependency
- func (builder *PolicyBuilder) AddRule(criteria *lang.Criteria, actions *lang.RuleActions) *lang.Rule
- func (builder *PolicyBuilder) AddService() *lang.Service
- func (builder *PolicyBuilder) AddServiceComponent(service *lang.Service, component *lang.ServiceComponent) *lang.ServiceComponent
- 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.ServiceComponent
- func (builder *PolicyBuilder) ContractComponent(contract *lang.Contract) *lang.ServiceComponent
- 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) SwitchNamespace(namespace string)
- func (builder *PolicyBuilder) UnknownComponent() *lang.ServiceComponent
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) AddCluster ¶
func (builder *PolicyBuilder) AddCluster() *lang.Cluster
AddCluster creates a new cluster and adds it to the policy
func (*PolicyBuilder) AddComponentDependency ¶
func (builder *PolicyBuilder) AddComponentDependency(component *lang.ServiceComponent, dependsOn *lang.ServiceComponent)
AddComponentDependency adds a component dependency on another component
func (*PolicyBuilder) AddContract ¶
func (builder *PolicyBuilder) AddContract(service *lang.Service, criteria *lang.Criteria) *lang.Contract
AddContract creates a new contract for a given service and adds it to the policy
func (*PolicyBuilder) AddContractMultipleContexts ¶
func (builder *PolicyBuilder) AddContractMultipleContexts(service *lang.Service, criteriaArray ...*lang.Criteria) *lang.Contract
AddContractMultipleContexts creates contract with multiple contexts for a given service and adds it to the policy
func (*PolicyBuilder) AddDependency ¶
func (builder *PolicyBuilder) AddDependency(user *lang.User, contract *lang.Contract) *lang.Dependency
AddDependency creates a new dependency and adds it to the policy
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() *lang.Service
AddService creates a new service and adds it to the policy
func (*PolicyBuilder) AddServiceComponent ¶
func (builder *PolicyBuilder) AddServiceComponent(service *lang.Service, component *lang.ServiceComponent) *lang.ServiceComponent
AddServiceComponent adds a given service component to the service
func (*PolicyBuilder) AddUser ¶
func (builder *PolicyBuilder) AddUser() *lang.User
AddUser creates a new user who can consume services 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.ServiceComponent
CodeComponent creates a new code component for a service
func (*PolicyBuilder) ContractComponent ¶
func (builder *PolicyBuilder) ContractComponent(contract *lang.Contract) *lang.ServiceComponent
ContractComponent creates a new contract component for a service
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) 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.ServiceComponent
UnknownComponent creates an unknown component for a service (not code and not contract)