* Add template api endpoints Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com> * Added template bypass Pools and scale sets will automatically migrate to the new template system for runner install scripts. If a pool or a scale set cannot be migrate, it is left alone. It is expected that users set a runner install template manually for scenarios we don't yet have a template for (windows on gitea for example). Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com> * Integrate templates with pool create/update Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com> * Add webapp integration with templates Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com> * Add unit tests Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com> * Populate all relevant context fields Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com> * Update dependencies Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com> * Fix lint Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com> * Validate uint Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com> * Add CLI template management Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com> * Some editor improvements and bugfixes Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com> * Fix scale set return values post create Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com> * Fix template websocket events filter Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com> --------- Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
42 lines
753 B
Go
42 lines
753 B
Go
package cache
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/cloudbase/garm/params"
|
|
)
|
|
|
|
var garmControllerCache *ControllerCache
|
|
|
|
func init() {
|
|
ctrlCache := &ControllerCache{}
|
|
garmControllerCache = ctrlCache
|
|
}
|
|
|
|
type ControllerCache struct {
|
|
controllerInfo params.ControllerInfo
|
|
|
|
mux sync.Mutex
|
|
}
|
|
|
|
func (c *ControllerCache) SetControllerCache(ctrl params.ControllerInfo) {
|
|
c.mux.Lock()
|
|
defer c.mux.Unlock()
|
|
|
|
c.controllerInfo = ctrl
|
|
}
|
|
|
|
func (c *ControllerCache) ControllerInfo() params.ControllerInfo {
|
|
c.mux.Lock()
|
|
defer c.mux.Unlock()
|
|
|
|
return c.controllerInfo
|
|
}
|
|
|
|
func ControllerInfo() params.ControllerInfo {
|
|
return garmControllerCache.ControllerInfo()
|
|
}
|
|
|
|
func SetControllerCache(ctrl params.ControllerInfo) {
|
|
garmControllerCache.SetControllerCache(ctrl)
|
|
}
|