Documentation
¶
Index ¶
- Constants
- func GetDesiredAttributes(attrMap []AttributeMap) []string
- func InArray(needle interface{}, haystack interface{}) (exists bool, index int)
- type AppConfig
- type AttributeMap
- type BatchTimer
- type ChangeResults
- type ChangeSet
- type Destination
- type DestinationConfig
- type EmptyDestination
- type EmptySource
- type EventLogItem
- type Person
- type RuntimeConfig
- type Source
- type SourceConfig
- type SyncSet
Constants ¶
const ( DefaultConfigFile = "./config.json" DefaultVerbosity = 5 DestinationTypeGoogleGroups = "GoogleGroups" DestinationTypeGoogleUsers = "GoogleUsers" DestinationTypeWebHelpDesk = "WebHelpDesk" SourceTypeRestAPI = "RestAPI" )
const ( VerbosityLow = 0 VerbosityMedium = 5 VerbosityHigh = 10 )
Variables ¶
This section is empty.
Functions ¶
func GetDesiredAttributes ¶
func GetDesiredAttributes(attrMap []AttributeMap) []string
Types ¶
type AppConfig ¶
type AppConfig struct { Runtime RuntimeConfig Source SourceConfig Destination DestinationConfig AttributeMap []AttributeMap SyncSets []SyncSet }
func LoadConfig ¶
LoadConfig looks for a config file if one is provided. Otherwise, it looks for a config file based on the CONFIG_PATH env var. If that is not set, it gets the default config file ("./config.json").
type AttributeMap ¶
type BatchTimer ¶
type BatchTimer struct { Counter int SecondsPerBatch int BatchSize int // contains filtered or unexported fields }
BatchTimer is intended as a time limited batch enforcer To create one, call its Init method. Then, to use it call its WaitOnBatch method after every call to
the associated go routine
func NewBatchTimer ¶
func NewBatchTimer(batchSize, secondsPerBatch int) BatchTimer
Init sets the startTime to the current time,
sets the endTime based on secondsPerBatch into the future
func (*BatchTimer) Init ¶
func (b *BatchTimer) Init(batchSize, secondsPerBatch int)
Init sets the startTime to the current time,
sets the endTime based on secondsPerBatch into the future
func (*BatchTimer) WaitOnBatch ¶
func (b *BatchTimer) WaitOnBatch()
WaitOnBatch increments the Counter and then
if fewer than BatchSize have been dealt with, just returns without doing anything Otherwise, sleeps until the batch time has expired (i.e. current time is past endTime). If this last process occurs, then it ends by resetting the batch's times and counter.
type ChangeResults ¶
func SyncPeople ¶
func SyncPeople(source Source, destination Destination, config AppConfig) ChangeResults
SyncPeople calls a number of functions to do the following ...
- it gets the list of people from the source
- it remaps their attributes to match the keys used in the destination
- it gets the list of people from the destination
- it generates the lists of people to change, update and delete
- if dryRun is true, it prints those lists, but otherwise makes the associated changes
type ChangeSet ¶
func GenerateChangeSet ¶
func GenerateChangeSet(sourcePeople, destinationPeople []Person, config AppConfig, idField string) ChangeSet
GenerateChangeSet builds the three slice attributes of a ChangeSet (Create, Update and Delete) based on whether they are in the slice
of destination Person instances.
It skips all source Person instances that have DisableChanges set to true
type Destination ¶
type Destination interface { GetIDField() string ForSet(syncSetJson json.RawMessage) error ListUsers() ([]Person, error) ApplyChangeSet(changes ChangeSet, activityLog chan<- EventLogItem) ChangeResults }
type DestinationConfig ¶
type EmptyDestination ¶
type EmptyDestination struct{}
func (*EmptyDestination) ApplyChangeSet ¶
func (e *EmptyDestination) ApplyChangeSet(changes ChangeSet, eventLog chan<- EventLogItem) ChangeResults
func (*EmptyDestination) ForSet ¶
func (e *EmptyDestination) ForSet(syncSetJson json.RawMessage) error
func (*EmptyDestination) GetIDField ¶
func (e *EmptyDestination) GetIDField() string
func (*EmptyDestination) ListUsers ¶
func (e *EmptyDestination) ListUsers() ([]Person, error)
type EmptySource ¶
type EmptySource struct{}
func (*EmptySource) ForSet ¶
func (e *EmptySource) ForSet(syncSetJson json.RawMessage) error
type EventLogItem ¶
type Person ¶
type Person struct { CompareValue string ID string Attributes map[string]string DisableChanges bool }
func RemapToDestinationAttributes ¶
func RemapToDestinationAttributes(sourcePersons []Person, attributeMap []AttributeMap) ([]Person, error)
RemapToDestinationAttributes returns a slice of Person instances that each have only the desired attributes based on the destination attribute keys. If a required attribute is missing for a Person, then their disableChanges value is set to true.
type RuntimeConfig ¶
type SourceConfig ¶
type SourceConfig struct { Type string ExtraJSON json.RawMessage }
type SyncSet ¶
type SyncSet struct { Name string Source json.RawMessage Destination json.RawMessage }