Documentation ¶
Index ¶
- Variables
- func AddLoadCallback(f func())
- func AddReconcileCallback(f func())
- func AddSyncCallback(f func())
- func Debug(v ...interface{})
- func FindStringInSlice(slice []string, val string) int
- func GetJSONString(key string, value string) []byte
- func GetKubeClient() (*kubernetes.Clientset, error)
- func GetOrCreateConfigmap(client *kubernetes.Clientset, name string) (*v1.ConfigMap, error)
- func ListenForShutdown(shutdown <-chan bool)
- func Load()
- func Log(v ...interface{})
- func Reconcile()
- func Start()
- func Stop()
- func Sync()
- func SyncSharedWork()
- func SyncWorkToConfigmap(w *Work) error
- func UpdateConfigmap(client *kubernetes.Clientset, cm *v1.ConfigMap, key string, value string) *v1.ConfigMap
- func UpdateWorkCache(w *Work)
- func UpdateWorkCacheIfNew(w *Work)
- type Configuration
- func (c *Configuration) Add(name string, defaultValue string)
- func (c *Configuration) Connect()
- func (c *Configuration) Get(name string) string
- func (c *Configuration) Refresh()
- func (c *Configuration) RefreshWorkShared()
- func (c *Configuration) Require(key string)
- func (c *Configuration) RequireKube()
- func (c *Configuration) RequireWorkCache()
- func (c *Configuration) RequireWorkShared()
- type Work
- type WorkStatus
Constants ¶
This section is empty.
Variables ¶
var ( // Callbacks holds the function calls for load, reconcile, and sync Callbacks *callbacks // Config holds the configuration for the assistant Config *Configuration // Shutdown is the channel that tells every routine to stop Shutdown chan bool )
var ( // Ready is when a configuration is initialized and ready to be used Ready sync.WaitGroup )
Functions ¶
func AddLoadCallback ¶
func AddLoadCallback(f func())
AddLoadCallback stores a function to call starting on the next load cycle
func AddReconcileCallback ¶
func AddReconcileCallback(f func())
AddReconcileCallback stores a function to call starting on the next reconcile cycle
func AddSyncCallback ¶
func AddSyncCallback(f func())
AddSyncCallback stores a function to call starting on the next sync cycle
func Debug ¶ added in v2.5.1
func Debug(v ...interface{})
Debug will print a message to the log if the Config.Debug boolean is true
func FindStringInSlice ¶
FindStringInSlice returns the index of a string in a slice, or -1 if it doesn't exist
func GetJSONString ¶
GetJSONString generates a byte array of JSON to be used with updating a configmap
func GetKubeClient ¶
func GetKubeClient() (*kubernetes.Clientset, error)
GetKubeClient returns an in-cluster kubernetes client
func GetOrCreateConfigmap ¶
GetOrCreateConfigmap gets an existing ConfigMap by name if it exists, or creates it if it does not exist
func ListenForShutdown ¶
func ListenForShutdown(shutdown <-chan bool)
ListenForShutdown handles when the shutdown channel receives true
func Reconcile ¶
func Reconcile()
Reconcile calls the reconcile callbacks and waits for a number of seconds to repeat
func SyncSharedWork ¶
func SyncSharedWork()
SyncSharedWork pulls the latest configmap data to the local object
func SyncWorkToConfigmap ¶
SyncWorkToConfigmap updates a configmap with a serialized representation of a work object
func UpdateConfigmap ¶
func UpdateConfigmap(client *kubernetes.Clientset, cm *v1.ConfigMap, key string, value string) *v1.ConfigMap
UpdateConfigmap sets one key and value in a Configmap
func UpdateWorkCache ¶
func UpdateWorkCache(w *Work)
UpdateWorkCache takes a work object as w and adds to the cache or updates an existing entry
func UpdateWorkCacheIfNew ¶
func UpdateWorkCacheIfNew(w *Work)
UpdateWorkCacheIfNew adds a new Work item to the cache. If it already exists, nothing is done.
Types ¶
type Configuration ¶
type Configuration struct { // Path is the directory that holds the config setting files Path string // Settings holds the user defined key-value pairs Settings map[string]string // Kube holds the in-cluster kubernetes connection Kube *kubernetes.Clientset WorkShared *v1.ConfigMap // WorkCache is a local cache of Work objects WorkCache map[string]*Work // WorkConfigmapName is the name of the config map that shares work WorkConfigmapName string // Local disables any kubernetes connections Local bool // Debug will print debug messages Debug bool // contains filtered or unexported fields }
Configuration holds the key-value pairs used by the assistant
func NewConfiguration ¶
func NewConfiguration(configPath string) *Configuration
NewConfiguration generates a configuration with the required settings. Path to the configuration settings is allowed, but defaults to /config if you pass an empty string
func (*Configuration) Add ¶
func (c *Configuration) Add(name string, defaultValue string)
Add a config value and watch for updates
func (*Configuration) Connect ¶
func (c *Configuration) Connect()
Connect tries to connect to the Kubernetes cluster and load the WorkShared configmap
func (*Configuration) Get ¶
func (c *Configuration) Get(name string) string
Get a value for a given key
func (*Configuration) Refresh ¶
func (c *Configuration) Refresh()
Refresh loads all config key-value pairs from the corresponding files
func (*Configuration) RefreshWorkShared ¶
func (c *Configuration) RefreshWorkShared()
RefreshWorkShared pulls the latest config map to the local copy
func (*Configuration) Require ¶
func (c *Configuration) Require(key string)
Require will block until a setting has a value
func (*Configuration) RequireKube ¶
func (c *Configuration) RequireKube()
RequireKube will block until the cluster is connected
func (*Configuration) RequireWorkCache ¶
func (c *Configuration) RequireWorkCache()
RequireWorkCache will block until the Work Cache has been created
func (*Configuration) RequireWorkShared ¶
func (c *Configuration) RequireWorkShared()
RequireWorkShared will block until the Work Configmap has been loaded
type Work ¶
type Work struct { ID string Title string From string Status WorkStatus URL string Description string Updated bool }
Work is something that needs to be done
func DeserializeString ¶
DeserializeString returns a one line string representing this object to be saved as a value in a configmap
func (*Work) SerializeString ¶
SerializeString returns a one line string representing this object to be saved as a value in a configmap
type WorkStatus ¶
type WorkStatus int
WorkStatus defines the states that Work can be in
const ( // Open work item Open WorkStatus = iota // Waiting on someone else Waiting // Closed work item Closed // None allows a work item to have no status None )
func (WorkStatus) String ¶
func (w WorkStatus) String() string