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 JoinUrlPath(inURL, path string) string
- func LoadConfig(configFile string) ([]byte, error)
- func RunSyncSet(logger *log.Logger, source Source, destination Destination, config Config) error
- type AttributeMap
- type BatchTimer
- type ChangeResults
- type ChangeSet
- type Config
- type Destination
- type DestinationConfig
- type EmptyDestination
- type EmptySource
- type EventLogItem
- type Filter
- type Filters
- type Person
- type RuntimeConfig
- type Source
- type SourceConfig
- type SyncError
- 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 JoinUrlPath ¶
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 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, otherwise it makes the associated changes
Types ¶
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
NewBatchTimer returns a new BatchTimer with the startTime set to the current time and the endTime set to secondsPerBatch from now
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 Config) 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 Config ¶ added in v6.4.0
type Config struct { Runtime RuntimeConfig Source SourceConfig Destination DestinationConfig Alert alert.Config AttributeMap []AttributeMap SyncSets []SyncSet }
func ReadConfig ¶ added in v6.4.0
ReadConfig parses raw json config data into a Config struct
func (*Config) MaxSyncSetNameLength ¶ added in v6.4.0
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 }