Documentation
¶
Index ¶
- Variables
- func CacheConfigs(manager string, files []string) error
- func CompareAndCopy(source string, dest string, m string) bool
- func CopyFile(src string, dst string) error
- func GetConfigManager(entry string, bc *ConfigSettings) error
- func GetManagerStatus(statusFile string, manager string) bool
- func IsValidScheme(s string) bool
- func ParseConfig(config []byte) error
- func ParseMustacheSubs(pairs []string) (map[string]string, error)
- func RenderConfigMustache(f *os.File, subs map[string]string) error
- func RestoreCachedConfigs(manager string, files []string, cleanFiles bool) error
- func SetManagerStatus(statusFile string, manager string, state bool) error
- func ValidateConfig(opts *ValidateOpts) error
- func ValidateMustacheSubs(Subs map[string]string) bool
- func WriteManagerStatusFile(statusFile string, status Status) error
- type ButlerConfig
- func (bc *ButlerConfig) CheckPaths() error
- func (bc *ButlerConfig) GetCMInterval() int
- func (bc *ButlerConfig) GetCMPrevInterval() int
- func (bc *ButlerConfig) GetInterval() int
- func (bc *ButlerConfig) GetLogLevel() log.Level
- func (bc *ButlerConfig) GetManager(m string) *Manager
- func (bc *ButlerConfig) GetManagers() map[string]*Manager
- func (bc *ButlerConfig) GetPath() string
- func (bc *ButlerConfig) GetStatusFile() string
- func (bc *ButlerConfig) Handler() error
- func (bc *ButlerConfig) Init() error
- func (bc *ButlerConfig) RunCMHandler() error
- func (bc *ButlerConfig) SetCMInterval(i int) error
- func (bc *ButlerConfig) SetCMPrevInterval(i int) error
- func (bc *ButlerConfig) SetEndpoints(e []string) error
- func (bc *ButlerConfig) SetHttpAuthToken(t string) error
- func (bc *ButlerConfig) SetHttpAuthType(t string) error
- func (bc *ButlerConfig) SetHttpAuthUser(t string) error
- func (bc *ButlerConfig) SetInterval(t int) error
- func (bc *ButlerConfig) SetLogLevel(level log.Level)
- func (bc *ButlerConfig) SetPath(p string) error
- func (bc *ButlerConfig) SetRegion(r string) error
- func (bc *ButlerConfig) SetRegionAndBucket(r string, b string) error
- func (bc *ButlerConfig) SetRetries(t int) error
- func (bc *ButlerConfig) SetRetryWaitMax(t int) error
- func (bc *ButlerConfig) SetRetryWaitMin(t int) error
- func (bc *ButlerConfig) SetScheduler(s *gocron.Scheduler) error
- func (bc *ButlerConfig) SetScheme(s string) error
- func (bc *ButlerConfig) SetTimeout(t int) error
- type ChanEvent
- type ConfigChanEvent
- func (c *ConfigChanEvent) CanCopyFiles() bool
- func (c *ConfigChanEvent) CleanTmpFiles() error
- func (c *ConfigChanEvent) CopyAdditionalConfigFiles(destDir string) bool
- func (c *ConfigChanEvent) CopyPrimaryConfigFiles(opts map[string]*ManagerOpts) bool
- func (c *ConfigChanEvent) GetTmpFileMap() []TmpFile
- func (c *ConfigChanEvent) SetFailure(repo string, file string, err error) error
- func (c *ConfigChanEvent) SetSuccess(repo string, file string, err error) error
- func (c *ConfigChanEvent) SetTmpFile(repo string, file string, tmpfile string) error
- type ConfigClient
- type ConfigFileMap
- type ConfigGlobals
- type ConfigSettings
- type Manager
- type ManagerOpts
- func (bmo *ManagerOpts) AppendAdditionalConfigFile(c string) error
- func (bmo *ManagerOpts) AppendAdditionalConfigUrl(c string) error
- func (bmo *ManagerOpts) AppendPrimaryConfigFile(c string) error
- func (bmo *ManagerOpts) AppendPrimaryConfigUrl(c string) error
- func (bmo *ManagerOpts) DownloadConfigFile(file string) *os.File
- func (bmo *ManagerOpts) GetAdditionalConfigUrls() []string
- func (bmo *ManagerOpts) GetAdditionalLocalConfigFiles() []string
- func (bmo *ManagerOpts) GetAdditionalRemoteConfigFiles() []string
- func (bmo *ManagerOpts) GetPrimaryConfigUrls() []string
- func (bmo *ManagerOpts) GetPrimaryLocalConfigFiles() []string
- func (bmo *ManagerOpts) GetPrimaryRemoteConfigFiles() []string
- func (bmo *ManagerOpts) SetParentManager(c string) error
- type RepoFileEvent
- type Status
- type TmpFile
- type ValidateOpts
Constants ¶
This section is empty.
Variables ¶
var ( ConfigSchedulerInterval = 300 ValidSchemes = []string{"blob", "file", "http", "https", "s3", "S3", "etcd"} )
var (
ConfigCache map[string]map[string][]byte
)
Functions ¶
func CacheConfigs ¶
CacheConfigs takes in a string of the base directory for the config directory and a slice of config file names and caches those files into memory. It returns an error on the event of error
func CopyFile ¶
CopyFile copies the src path string to the dst path string. If there is an error, an error is returned, otherwise nil is returned.
func GetConfigManager ¶
func GetConfigManager(entry string, bc *ConfigSettings) error
func GetManagerStatus ¶
func IsValidScheme ¶
func ParseConfig ¶
func RenderConfigMustache ¶
RenderConfigMustache takes a pointer to an os.File object. It reads the file attempts to parse the mustache
func RestoreCachedConfigs ¶
RestoreCachedConfigs takes in a strint of the base directory for the config directory and a slice of config file names and restores those files from the cache back to the filesystem. It returns an error on the event of an error
func ValidateConfig ¶
func ValidateConfig(opts *ValidateOpts) error
ValidateConfig takes a pointer to an os.File object. It scans over the file and ensures that it begins with the proper header, and ends with the proper footer. If it does not begin or end with the proper header/footer, then an error is returned. If the file passes the checks, a nil is returned.
func ValidateMustacheSubs ¶
func WriteManagerStatusFile ¶
Types ¶
type ButlerConfig ¶
type ButlerConfig struct { Url *url.URL Client *ConfigClient Config *ConfigSettings FirstRun bool LogLevel log.Level PrevCMSchedulerInterval int Interval int Timeout int RawConfig []byte Retries int RetryWaitMin int RetryWaitMax int Scheduler *gocron.Scheduler // some http specific stuff HttpAuthType string HttpAuthUser string HttpAuthToken string // some s3 specific stuff S3Region string S3Bucket string Endpoints []string }
func NewButlerConfig ¶
func NewButlerConfig() *ButlerConfig
func (*ButlerConfig) CheckPaths ¶
func (bc *ButlerConfig) CheckPaths() error
func (*ButlerConfig) GetCMInterval ¶
func (bc *ButlerConfig) GetCMInterval() int
func (*ButlerConfig) GetCMPrevInterval ¶
func (bc *ButlerConfig) GetCMPrevInterval() int
func (*ButlerConfig) GetInterval ¶
func (bc *ButlerConfig) GetInterval() int
func (*ButlerConfig) GetLogLevel ¶
func (bc *ButlerConfig) GetLogLevel() log.Level
func (*ButlerConfig) GetManager ¶
func (bc *ButlerConfig) GetManager(m string) *Manager
func (*ButlerConfig) GetManagers ¶
func (bc *ButlerConfig) GetManagers() map[string]*Manager
func (*ButlerConfig) GetPath ¶
func (bc *ButlerConfig) GetPath() string
func (*ButlerConfig) GetStatusFile ¶
func (bc *ButlerConfig) GetStatusFile() string
func (*ButlerConfig) Handler ¶
func (bc *ButlerConfig) Handler() error
func (*ButlerConfig) Init ¶
func (bc *ButlerConfig) Init() error
func (*ButlerConfig) RunCMHandler ¶
func (bc *ButlerConfig) RunCMHandler() error
func (*ButlerConfig) SetCMInterval ¶
func (bc *ButlerConfig) SetCMInterval(i int) error
func (*ButlerConfig) SetCMPrevInterval ¶
func (bc *ButlerConfig) SetCMPrevInterval(i int) error
func (*ButlerConfig) SetEndpoints ¶
func (bc *ButlerConfig) SetEndpoints(e []string) error
func (*ButlerConfig) SetHttpAuthToken ¶
func (bc *ButlerConfig) SetHttpAuthToken(t string) error
func (*ButlerConfig) SetHttpAuthType ¶
func (bc *ButlerConfig) SetHttpAuthType(t string) error
func (*ButlerConfig) SetHttpAuthUser ¶
func (bc *ButlerConfig) SetHttpAuthUser(t string) error
func (*ButlerConfig) SetInterval ¶
func (bc *ButlerConfig) SetInterval(t int) error
func (*ButlerConfig) SetLogLevel ¶
func (bc *ButlerConfig) SetLogLevel(level log.Level)
func (*ButlerConfig) SetPath ¶
func (bc *ButlerConfig) SetPath(p string) error
func (*ButlerConfig) SetRegion ¶
func (bc *ButlerConfig) SetRegion(r string) error
func (*ButlerConfig) SetRegionAndBucket ¶
func (bc *ButlerConfig) SetRegionAndBucket(r string, b string) error
func (*ButlerConfig) SetRetries ¶
func (bc *ButlerConfig) SetRetries(t int) error
func (*ButlerConfig) SetRetryWaitMax ¶
func (bc *ButlerConfig) SetRetryWaitMax(t int) error
func (*ButlerConfig) SetRetryWaitMin ¶
func (bc *ButlerConfig) SetRetryWaitMin(t int) error
func (*ButlerConfig) SetScheduler ¶
func (bc *ButlerConfig) SetScheduler(s *gocron.Scheduler) error
func (*ButlerConfig) SetScheme ¶
func (bc *ButlerConfig) SetScheme(s string) error
func (*ButlerConfig) SetTimeout ¶
func (bc *ButlerConfig) SetTimeout(t int) error
type ConfigChanEvent ¶
type ConfigChanEvent struct { HasChanged bool TmpFile *os.File ConfigFile *string Manager string Repo map[string]*RepoFileEvent }
ConfigChanEvent is the object passed around in the channel which contains information on whether the file has changed, the path to the tempfile, the config name, and repository event information
func NewConfigChanEvent ¶
func NewConfigChanEvent() *ConfigChanEvent
func (*ConfigChanEvent) CanCopyFiles ¶
func (c *ConfigChanEvent) CanCopyFiles() bool
CanCopyFiles returns a boolean which tells whether or not butler is able to copy the files from the repository to the local filesystem. The assumption is that ALL files have to pass before butler attempts to copy over.
func (*ConfigChanEvent) CleanTmpFiles ¶
func (c *ConfigChanEvent) CleanTmpFiles() error
CleanTmpFiles returns an error, or not, depending on whether butler was able to delete all the tempfiles that were created during the config file retrieval from the remote repository
func (*ConfigChanEvent) CopyAdditionalConfigFiles ¶
func (c *ConfigChanEvent) CopyAdditionalConfigFiles(destDir string) bool
func (*ConfigChanEvent) CopyPrimaryConfigFiles ¶
func (c *ConfigChanEvent) CopyPrimaryConfigFiles(opts map[string]*ManagerOpts) bool
func (*ConfigChanEvent) GetTmpFileMap ¶
func (c *ConfigChanEvent) GetTmpFileMap() []TmpFile
GetTmpFileMap returns a slice of SORTED TmpFile objects which contain the names of all the temp files creted during the config file retrieval from the remote repository.
func (*ConfigChanEvent) SetFailure ¶
func (c *ConfigChanEvent) SetFailure(repo string, file string, err error) error
SetFailure sets the value for the file argument in the repo argument to false
func (*ConfigChanEvent) SetSuccess ¶
func (c *ConfigChanEvent) SetSuccess(repo string, file string, err error) error
SetSuccess sets the value for the file argument in the repo argument to true
func (*ConfigChanEvent) SetTmpFile ¶
func (c *ConfigChanEvent) SetTmpFile(repo string, file string, tmpfile string) error
type ConfigClient ¶
func NewConfigClient ¶
func NewConfigClient(scheme string) (*ConfigClient, error)
func (*ConfigClient) SetRetryMax ¶
func (c *ConfigClient) SetRetryMax(val int)
func (*ConfigClient) SetRetryWaitMax ¶
func (c *ConfigClient) SetRetryWaitMax(val int)
func (*ConfigClient) SetRetryWaitMin ¶
func (c *ConfigClient) SetRetryWaitMin(val int)
func (*ConfigClient) SetTimeout ¶
func (c *ConfigClient) SetTimeout(val int)
type ConfigFileMap ¶
type ConfigGlobals ¶
type ConfigGlobals struct { Managers []string `mapstructure:"config-managers" json:"-"` SchedulerInterval int `json:"scheduler-interval"` CfgEnableHttpLog string `mapstructure:"enable-http-log" json:"-"` EnableHttpLog bool `json:"enable-http-log"` CfgSchedulerInterval string `mapstructure:"scheduler-interval" json:"-"` CfgExitOnFailure string `mapstructure:"exit-on-config-failure" json:"-"` ExitOnFailure bool `json:"exit-on-failure"` CfgStatusFile string `mapstructure:"status-file" json:"-"` StatusFile string `json:"status-file"` CfgHttpProto string `mapstructure:"http-proto" json:"-"` HttpProto string `json:"http-proto"` CfgHttpPort string `mapstructure:"http-port" json:"-"` HttpPort int `json:"http-port"` CfgHttpTlsCert string `mapstructure:"http-tls-cert" json:"-"` HttpTlsCert string `json:"http-tls-cert"` CfgHttpTlsKey string `mapstructure:"http-tls-key" json:"-"` HttpTlsKey string `json:"http-tls-key"` }
type ConfigSettings ¶
type ConfigSettings struct { Managers map[string]*Manager `json:"managers"` Globals ConfigGlobals `json:"globals"` }
func NewConfigSettings ¶
func NewConfigSettings() *ConfigSettings
func (*ConfigSettings) GetAllConfigLocalPaths ¶
func (b *ConfigSettings) GetAllConfigLocalPaths(mgr string) []string
func (*ConfigSettings) ParseConfig ¶
func (c *ConfigSettings) ParseConfig(config []byte) error
type Manager ¶
type Manager struct { Name string `json:"name"` Repos []string `mapstructure:"repos" json:"repos"` CfgCleanFiles string `mapstructure:"clean-files" json:"-"` CleanFiles bool `json:"clean-files"` GoodCache bool `json:"good-cache"` LastRun time.Time `json:"last-run"` MustacheSubsArray []string `mapstructure:"mustache-subs" json:"-"` MustacheSubs map[string]string `json:"mustache-subs"` CfgEnableCache string `mapstructure:"enable-cache" json:"-"` EnableCache bool `json:"enable-cache"` CachePath string `mapstructure:"cache-path" json:"cache-path"` DestPath string `mapstructure:"dest-path" json:"dest-path"` PrimaryConfigName string `mapstructure:"primary-config-name" json:"primary-config-name"` CfgManagerTimeoutOk string `mapstructure:"manager-timeout-ok" json:"-"` ManagerTimeoutOk bool `json:"manager-timeout-ok"` ManagerOpts map[string]*ManagerOpts `json:"opts"` Reloader reloaders.Reloader `mapstructure:"-" json:"reloader,omitempty"` ReloadManager bool `json:"-"` }
func (*Manager) DownloadAdditionalConfigFiles ¶
func (*Manager) DownloadPrimaryConfigFiles ¶
func (*Manager) GetAllLocalPaths ¶
func (*Manager) PathCleanup ¶
PathCleanup
type ManagerOpts ¶
type ManagerOpts struct { Method string `mapstructure:"method" json:"method"` RepoPath string `mapstructure:"repo-path" json:"repo-path"` Repo string `json:"repo"` PrimaryConfig []string `mapstructure:"primary-config" json:"primary-config"` AdditionalConfig []string `mapstructure:"additional-config" json:"additional-config"` PrimaryConfigsFullUrls []string `json:"-"` AdditionalConfigsFullUrls []string `json:"-"` PrimaryConfigsFullLocalPaths []string `json:"-"` AdditionalConfigsFullLocalPaths []string `json:"-"` ContentType string `mapstructure:"content-type" json:"content-type"` Opts methods.Method `json:"opts"` // contains filtered or unexported fields }
func GetManagerOpts ¶
func GetManagerOpts(entry string, bc *ConfigSettings) (*ManagerOpts, error)
func (*ManagerOpts) AppendAdditionalConfigFile ¶
func (bmo *ManagerOpts) AppendAdditionalConfigFile(c string) error
func (*ManagerOpts) AppendAdditionalConfigUrl ¶
func (bmo *ManagerOpts) AppendAdditionalConfigUrl(c string) error
func (*ManagerOpts) AppendPrimaryConfigFile ¶
func (bmo *ManagerOpts) AppendPrimaryConfigFile(c string) error
func (*ManagerOpts) AppendPrimaryConfigUrl ¶
func (bmo *ManagerOpts) AppendPrimaryConfigUrl(c string) error
func (*ManagerOpts) DownloadConfigFile ¶
func (bmo *ManagerOpts) DownloadConfigFile(file string) *os.File
Really need to come up with a better method for this.
func (*ManagerOpts) GetAdditionalConfigUrls ¶
func (bmo *ManagerOpts) GetAdditionalConfigUrls() []string
func (*ManagerOpts) GetAdditionalLocalConfigFiles ¶
func (bmo *ManagerOpts) GetAdditionalLocalConfigFiles() []string
func (*ManagerOpts) GetAdditionalRemoteConfigFiles ¶
func (bmo *ManagerOpts) GetAdditionalRemoteConfigFiles() []string
func (*ManagerOpts) GetPrimaryConfigUrls ¶
func (bmo *ManagerOpts) GetPrimaryConfigUrls() []string
func (*ManagerOpts) GetPrimaryLocalConfigFiles ¶
func (bmo *ManagerOpts) GetPrimaryLocalConfigFiles() []string
func (*ManagerOpts) GetPrimaryRemoteConfigFiles ¶
func (bmo *ManagerOpts) GetPrimaryRemoteConfigFiles() []string
func (*ManagerOpts) SetParentManager ¶
func (bmo *ManagerOpts) SetParentManager(c string) error
type RepoFileEvent ¶
type RepoFileEvent struct { Success map[string]bool Error map[string]error TmpFile map[string]string }
func (*RepoFileEvent) SetFailure ¶
func (r *RepoFileEvent) SetFailure(file string, err error) error
func (*RepoFileEvent) SetSuccess ¶
func (r *RepoFileEvent) SetSuccess(file string, err error) error
func (*RepoFileEvent) SetTmpFile ¶
func (r *RepoFileEvent) SetTmpFile(file string, tmpfile string) error
type Status ¶
func ReadManagerStatusFile ¶
type ValidateOpts ¶
func NewValidateOpts ¶
func NewValidateOpts() *ValidateOpts
func (*ValidateOpts) WithContentType ¶
func (o *ValidateOpts) WithContentType(t string) *ValidateOpts
func (*ValidateOpts) WithData ¶
func (o *ValidateOpts) WithData(d interface{}) *ValidateOpts
func (*ValidateOpts) WithFileName ¶
func (o *ValidateOpts) WithFileName(f string) *ValidateOpts
func (*ValidateOpts) WithManager ¶
func (o *ValidateOpts) WithManager(m string) *ValidateOpts