Documentation ¶
Index ¶
- Constants
- Variables
- func AddParamsToURL(inURL string, params [][2]string) (string, error)
- func AddStringToSlice(newString string, slice []string) []string
- func GetDestinationAttributes(attrMap []AttributeMap) []string
- func GetSourceAttributes(attrMap []AttributeMap) []string
- func InArray(needle interface{}, haystack interface{}) (exists bool, index int)
- func IsStringInSlice(needle string, haystack []string) bool
- func JoinUrlPath(inURL, path string) string
- func RunSyncSet(logger *log.Logger, source Source, destination Destination, config AppConfig) error
- type AppConfig
- type AttributeMap
- type BatchTimer
- type ChangeResults
- type ChangeSet
- type Destination
- type DestinationConfig
- type EmptyDestination
- type EmptySource
- type EventLogItem
- type Filter
- type Filters
- type Person
- type RuntimeConfig
- type Source
- type SourceConfig
- type SyncSet
Constants ¶
const ( DefaultConfigFile = "./config.json" DefaultVerbosity = 5 DestinationTypeGoogleContacts = "GoogleContacts" DestinationTypeGoogleGroups = "GoogleGroups" DestinationTypeGoogleSheets = "GoogleSheets" DestinationTypeGoogleUsers = "GoogleUsers" DestinationTypeRestAPI = "RestAPI" DestinationTypeWebHelpDesk = "WebHelpDesk" SourceTypeGoogleSheets = "GoogleSheets" SourceTypeRestAPI = "RestAPI" )
const ( VerbosityLow = 0 VerbosityMedium = 5 VerbosityHigh = 10 )
Variables ¶
Functions ¶
func AddParamsToURL ¶
AddParamsToURL returns the input url string if there are no params to add Otherwise, it adds each param pair to the url as `params[n][0]=params[n][1]` (in alphabetical order)
with the appropriate delimiter ("?" or "&")
func AddStringToSlice ¶
func GetDestinationAttributes ¶
func GetDestinationAttributes(attrMap []AttributeMap) []string
func GetSourceAttributes ¶
func GetSourceAttributes(attrMap []AttributeMap) []string
func InArray ¶
This function will search element inside array with any type. Will return boolean and index for matched element. True and index more than 0 if element is exist. needle is element to search, haystack is slice of value to be search.
func IsStringInSlice ¶
IsStringInSlice iterates over a slice of strings, looking for the given string. If found, true is returned. Otherwise, false is returned.
func JoinUrlPath ¶
func RunSyncSet ¶
RunSyncSet 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
Types ¶
type AppConfig ¶
type AppConfig struct { Runtime RuntimeConfig Source SourceConfig Destination DestinationConfig Alert alert.Config 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").
func (*AppConfig) MaxSyncSetNameLength ¶
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 ¶
type ChangeSet ¶
func GenerateChangeSet ¶
func GenerateChangeSet(logger *log.Logger, sourcePeople, destinationPeople []Person, config AppConfig) 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 { ForSet(syncSetJson json.RawMessage) error ListUsers(desiredAttrs []string) ([]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
type EmptySource ¶
type EmptySource struct{}
func (*EmptySource) ForSet ¶
func (e *EmptySource) ForSet(syncSetJson json.RawMessage) error
type EventLogItem ¶
func (EventLogItem) String ¶
func (l EventLogItem) String() string
type Filter ¶ added in v6.1.0
type Person ¶
type Person struct { CompareValue string ID string Attributes map[string]string DisableChanges bool }
func RemapToDestinationAttributes ¶
func RemapToDestinationAttributes(logger *log.Logger, 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 }