Documentation ¶
Overview ¶
Package allocator implements santa allocations
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultConfig = Config{ CanAllocateSelf: false, Timeout: time.Second * 5, }
Functions ¶
This section is empty.
Types ¶
type Allocation ¶
type Allocation struct { Aliases map[string]string `json:"aliases"` // name -> password Allocations map[string]string `json:"allocations"` // name -> name Created time.Time }
Allocation holds the aliases and allocations for a particular derangment.
func (*Allocation) PrintAliases ¶
func (a *Allocation) PrintAliases()
func (*Allocation) PrintNameToName ¶
func (a *Allocation) PrintNameToName()
func (*Allocation) PrintNameToPassword ¶
func (a *Allocation) PrintNameToPassword()
func (*Allocation) String ¶
func (a *Allocation) String() string
type AllocationStore ¶
type AllocationStore struct { Allocation string `json:"allocation"` // base64 encoded version of Allocation AllocatedPasswords map[string]string `json:"allocated_passwords"` Created time.Time `json:"created"` Name string `json:"allocation_name"` }
AllocationStore is a struct which models how marshalled allocations should be stored as to hide the specific allocation and aliases but show allocated passwords
type Allocator ¶
type Allocator struct { Names Set // using maps here to dedupe the list Passwords Set Config Config // contains filtered or unexported fields }
Allocator creates a new allocation given a particular config
func New ¶
creates a new instance of an Allocator takes a config which is used to setup the allocator
func (*Allocator) Allocate ¶
func (a *Allocator) Allocate() (*Allocation, error)
Allocate will allocate the names to a password and then the password to a name to create anonymity
func (*Allocator) OutputToFile ¶
func (a *Allocator) OutputToFile(allocation *Allocation, fileName string, fileType string) error
OutputToFile writes an instance of Allocation to fileName with either "json" or "yaml" as the fileType
type Config ¶
type Config struct { Names struct { File string `yaml:"file"` Data []string `yaml:"data"` } Passwords struct { File string `yaml:"file"` Data []string `yaml:"data"` } CanAllocateSelf bool `yaml:"canAllocateSelf"` Timeout time.Duration `yaml:"timeout,omitempty"` Rules []Rule `yaml:"rules"` Name string `yaml:"allocation_name"` }
Config is the configuration for an allocator
func LoadConfigFromYaml ¶
LoadConfigFromYaml receives yamlData and unmarshals it into a Config