Moving config from containers module
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
For better encapsulation
This commit is contained in:
parent
e58d6462a9
commit
d43529fbb8
@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
func TestGetProcesses(t *testing.T) {
|
func TestGetProcesses(t *testing.T) {
|
||||||
driver := Driver{
|
driver := Driver{
|
||||||
DockerSock: "/run/user/1000/podman/podman.sock",
|
DockerSock: "unix:///run/user/1000/podman/podman.sock",
|
||||||
BindIPHTTP: "127.0.0.1",
|
BindIPHTTP: "127.0.0.1",
|
||||||
BindIPSSH: "127.0.0.1",
|
BindIPSSH: "127.0.0.1",
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/rosti-cz/node-api/apps"
|
"github.com/rosti-cz/node-api/apps"
|
||||||
"github.com/rosti-cz/node-api/common"
|
|
||||||
"github.com/rosti-cz/node-api/detector"
|
"github.com/rosti-cz/node-api/detector"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -24,22 +23,24 @@ type Process struct {
|
|||||||
// Container extends App struct from App
|
// Container extends App struct from App
|
||||||
type Container struct {
|
type Container struct {
|
||||||
App *apps.App `json:"app"`
|
App *apps.App `json:"app"`
|
||||||
|
DockerSock string `json:"-"`
|
||||||
|
BindIPHTTP string `json:"-"`
|
||||||
|
BindIPSSH string `json:"-"`
|
||||||
|
AppsPath string `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Container) getDriver() *Driver {
|
func (c *Container) getDriver() *Driver {
|
||||||
config := common.GetConfig()
|
|
||||||
driver := &Driver{
|
driver := &Driver{
|
||||||
DockerSock: config.DockerSocket,
|
DockerSock: c.DockerSock,
|
||||||
BindIPHTTP: config.AppsBindIPHTTP,
|
BindIPHTTP: c.BindIPHTTP,
|
||||||
BindIPSSH: config.AppsBindIPSSH,
|
BindIPSSH: c.BindIPSSH,
|
||||||
}
|
}
|
||||||
return driver
|
return driver
|
||||||
}
|
}
|
||||||
|
|
||||||
// volumeHostPath each container has one volume mounted into it,
|
// volumeHostPath each container has one volume mounted into it,
|
||||||
func (c *Container) volumeHostPath() string {
|
func (c *Container) volumeHostPath() string {
|
||||||
config := common.GetConfig()
|
return path.Join(c.AppsPath, c.App.Name)
|
||||||
return path.Join(config.AppsPath, c.App.Name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRawResourceStats returns RAW CPU and memory usage directly from Docker API
|
// GetRawResourceStats returns RAW CPU and memory usage directly from Docker API
|
||||||
@ -96,11 +97,6 @@ func (c *Container) GetState() (*apps.AppState, error) {
|
|||||||
func (c *Container) Status() (string, error) {
|
func (c *Container) Status() (string, error) {
|
||||||
status := "unknown"
|
status := "unknown"
|
||||||
|
|
||||||
// config := common.GetConfig()
|
|
||||||
// if _, err := os.Stat(path.Join(config.AppsPath, c.App.Name)); !os.IsNotExist(err) {
|
|
||||||
// status = "data-only"
|
|
||||||
// }
|
|
||||||
|
|
||||||
driver := c.getDriver()
|
driver := c.getDriver()
|
||||||
containerStatus, err := driver.Status(c.App.Name)
|
containerStatus, err := driver.Status(c.App.Name)
|
||||||
if err != nil && err.Error() == "no container found" {
|
if err != nil && err.Error() == "no container found" {
|
||||||
@ -200,8 +196,7 @@ func (c *Container) Delete() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config := common.GetConfig()
|
volumePath := path.Join(c.AppsPath, c.App.Name)
|
||||||
volumePath := path.Join(config.AppsPath, c.App.Name)
|
|
||||||
err = removeDirectory(volumePath)
|
err = removeDirectory(volumePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
|
@ -21,6 +21,10 @@ type Processor struct {
|
|||||||
DB *gorm.DB
|
DB *gorm.DB
|
||||||
SnapshotProcessor *apps.SnapshotProcessor
|
SnapshotProcessor *apps.SnapshotProcessor
|
||||||
WaitForAppLoops uint // each loop is five seconds
|
WaitForAppLoops uint // each loop is five seconds
|
||||||
|
DockerSock string
|
||||||
|
BindIPHTTP string
|
||||||
|
BindIPSSH string
|
||||||
|
AppsPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return prepared Container instance
|
// Return prepared Container instance
|
||||||
@ -37,6 +41,10 @@ func (p *Processor) getContainer() (containers.Container, error) {
|
|||||||
|
|
||||||
container = docker.Container{
|
container = docker.Container{
|
||||||
App: &app,
|
App: &app,
|
||||||
|
DockerSock: p.DockerSock,
|
||||||
|
BindIPHTTP: p.BindIPHTTP,
|
||||||
|
BindIPSSH: p.BindIPSSH,
|
||||||
|
AppsPath: p.AppsPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
return container, nil
|
return container, nil
|
||||||
|
68
handlers.go
68
handlers.go
@ -23,6 +23,10 @@ func homeHandler(c echo.Context) error {
|
|||||||
func listAppsHandler(c echo.Context) error {
|
func listAppsHandler(c echo.Context) error {
|
||||||
processor := glue.Processor{
|
processor := glue.Processor{
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
applications, err := processor.List()
|
applications, err := processor.List()
|
||||||
@ -40,6 +44,10 @@ func getAppHandler(c echo.Context) error {
|
|||||||
processor := glue.Processor{
|
processor := glue.Processor{
|
||||||
AppName: name,
|
AppName: name,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
app, err := processor.Get()
|
app, err := processor.Get()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -63,6 +71,10 @@ func createAppHandler(c echo.Context) error {
|
|||||||
processor := glue.Processor{
|
processor := glue.Processor{
|
||||||
AppName: appTemplate.Name,
|
AppName: appTemplate.Name,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
if registerOnly {
|
if registerOnly {
|
||||||
@ -97,6 +109,10 @@ func updateAppHandler(c echo.Context) error {
|
|||||||
processor := glue.Processor{
|
processor := glue.Processor{
|
||||||
AppName: name,
|
AppName: name,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
err = processor.Update(appTemplate)
|
err = processor.Update(appTemplate)
|
||||||
if err != nil && strings.Contains(err.Error(), "validation error") {
|
if err != nil && strings.Contains(err.Error(), "validation error") {
|
||||||
@ -115,6 +131,10 @@ func stopAppHandler(c echo.Context) error {
|
|||||||
processor := glue.Processor{
|
processor := glue.Processor{
|
||||||
AppName: name,
|
AppName: name,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
err := processor.Stop()
|
err := processor.Stop()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -131,6 +151,10 @@ func startAppHandler(c echo.Context) error {
|
|||||||
processor := glue.Processor{
|
processor := glue.Processor{
|
||||||
AppName: name,
|
AppName: name,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
err := processor.Start()
|
err := processor.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -147,6 +171,10 @@ func restartAppHandler(c echo.Context) error {
|
|||||||
processor := glue.Processor{
|
processor := glue.Processor{
|
||||||
AppName: name,
|
AppName: name,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
err := processor.Restart()
|
err := processor.Restart()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -169,6 +197,10 @@ func setPasswordHandler(c echo.Context) error {
|
|||||||
processor := glue.Processor{
|
processor := glue.Processor{
|
||||||
AppName: name,
|
AppName: name,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
err = processor.SetPassword(password.Password)
|
err = processor.SetPassword(password.Password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -190,6 +222,10 @@ func setKeysHandler(c echo.Context) error {
|
|||||||
processor := glue.Processor{
|
processor := glue.Processor{
|
||||||
AppName: name,
|
AppName: name,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
err = processor.UpdateKeys(string(body) + "\n")
|
err = processor.UpdateKeys(string(body) + "\n")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -211,6 +247,10 @@ func setServicesHandler(c echo.Context) error {
|
|||||||
processor := glue.Processor{
|
processor := glue.Processor{
|
||||||
AppName: name,
|
AppName: name,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
err = processor.EnableTech(tech.Name, tech.Version)
|
err = processor.EnableTech(tech.Name, tech.Version)
|
||||||
@ -228,6 +268,10 @@ func rebuildAppHandler(c echo.Context) error {
|
|||||||
processor := glue.Processor{
|
processor := glue.Processor{
|
||||||
AppName: name,
|
AppName: name,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
err := processor.Rebuild()
|
err := processor.Rebuild()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -250,6 +294,10 @@ func addLabelHandler(c echo.Context) error {
|
|||||||
processor := glue.Processor{
|
processor := glue.Processor{
|
||||||
AppName: name,
|
AppName: name,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
err = processor.AddLabel(label.Value)
|
err = processor.AddLabel(label.Value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -272,6 +320,10 @@ func deleteLabelHandler(c echo.Context) error {
|
|||||||
processor := glue.Processor{
|
processor := glue.Processor{
|
||||||
AppName: name,
|
AppName: name,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
err = processor.RemoveLabel(label.Value)
|
err = processor.RemoveLabel(label.Value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -290,6 +342,10 @@ func deleteAppHandler(c echo.Context) error {
|
|||||||
processor := glue.Processor{
|
processor := glue.Processor{
|
||||||
AppName: name,
|
AppName: name,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
err := processor.Delete()
|
err := processor.Delete()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -309,6 +365,10 @@ func getOrphansHander(c echo.Context) error {
|
|||||||
func getNodeInfoHandler(c echo.Context) error {
|
func getNodeInfoHandler(c echo.Context) error {
|
||||||
processor := glue.Processor{
|
processor := glue.Processor{
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
node, err := processor.GetNode()
|
node, err := processor.GetNode()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -325,6 +385,10 @@ func getAppProcessesHandler(c echo.Context) error {
|
|||||||
processor := glue.Processor{
|
processor := glue.Processor{
|
||||||
AppName: name,
|
AppName: name,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
processes, err := processor.Processes()
|
processes, err := processor.Processes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -341,6 +405,10 @@ func metricsHandler(c echo.Context) error {
|
|||||||
// Node indexes
|
// Node indexes
|
||||||
processor := glue.Processor{
|
processor := glue.Processor{
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
node, err := processor.GetNode()
|
node, err := processor.GetNode()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
100
handlers_nats.go
100
handlers_nats.go
@ -95,6 +95,10 @@ func listEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||||||
processor := glue.Processor{
|
processor := glue.Processor{
|
||||||
AppName: message.AppName,
|
AppName: message.AppName,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
applications, err := processor.List()
|
applications, err := processor.List()
|
||||||
@ -165,6 +169,10 @@ func createEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||||||
AppName: message.AppName,
|
AppName: message.AppName,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
SnapshotProcessor: &snapshotProcessor,
|
SnapshotProcessor: &snapshotProcessor,
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
err = processor.Create(appTemplate)
|
err = processor.Create(appTemplate)
|
||||||
if err != nil && strings.Contains(err.Error(), "validation error") {
|
if err != nil && strings.Contains(err.Error(), "validation error") {
|
||||||
@ -197,6 +205,10 @@ func registerEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||||||
AppName: message.AppName,
|
AppName: message.AppName,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
SnapshotProcessor: &snapshotProcessor,
|
SnapshotProcessor: &snapshotProcessor,
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
err = processor.Create(appTemplate)
|
err = processor.Create(appTemplate)
|
||||||
if err != nil && strings.Contains(err.Error(), "validation error") {
|
if err != nil && strings.Contains(err.Error(), "validation error") {
|
||||||
@ -228,6 +240,10 @@ func updateEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||||||
AppName: message.AppName,
|
AppName: message.AppName,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
SnapshotProcessor: &snapshotProcessor,
|
SnapshotProcessor: &snapshotProcessor,
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
err = processor.Update(appTemplate)
|
err = processor.Update(appTemplate)
|
||||||
if err != nil && strings.Contains(err.Error(), "validation error") {
|
if err != nil && strings.Contains(err.Error(), "validation error") {
|
||||||
@ -249,6 +265,10 @@ func deleteEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||||||
AppName: message.AppName,
|
AppName: message.AppName,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
SnapshotProcessor: &snapshotProcessor,
|
SnapshotProcessor: &snapshotProcessor,
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
err := processor.Delete()
|
err := processor.Delete()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -268,6 +288,10 @@ func stopEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||||||
AppName: message.AppName,
|
AppName: message.AppName,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
SnapshotProcessor: &snapshotProcessor,
|
SnapshotProcessor: &snapshotProcessor,
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
err := processor.Stop()
|
err := processor.Stop()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -287,6 +311,10 @@ func startEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||||||
AppName: message.AppName,
|
AppName: message.AppName,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
SnapshotProcessor: &snapshotProcessor,
|
SnapshotProcessor: &snapshotProcessor,
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
err := processor.Start()
|
err := processor.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -306,6 +334,10 @@ func restartEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||||||
AppName: message.AppName,
|
AppName: message.AppName,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
SnapshotProcessor: &snapshotProcessor,
|
SnapshotProcessor: &snapshotProcessor,
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
err := processor.Restart()
|
err := processor.Restart()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -327,6 +359,10 @@ func updateKeysEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||||||
AppName: message.AppName,
|
AppName: message.AppName,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
SnapshotProcessor: &snapshotProcessor,
|
SnapshotProcessor: &snapshotProcessor,
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
err := processor.UpdateKeys(body)
|
err := processor.UpdateKeys(body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -347,6 +383,10 @@ func setPasswordEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||||||
AppName: message.AppName,
|
AppName: message.AppName,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
SnapshotProcessor: &snapshotProcessor,
|
SnapshotProcessor: &snapshotProcessor,
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
err := processor.SetPassword(password)
|
err := processor.SetPassword(password)
|
||||||
|
|
||||||
@ -367,6 +407,10 @@ func processesEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||||||
AppName: message.AppName,
|
AppName: message.AppName,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
SnapshotProcessor: &snapshotProcessor,
|
SnapshotProcessor: &snapshotProcessor,
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
processes, err := processor.Processes()
|
processes, err := processor.Processes()
|
||||||
@ -426,6 +470,10 @@ func enableTechEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||||||
AppName: message.AppName,
|
AppName: message.AppName,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
SnapshotProcessor: &snapshotProcessor,
|
SnapshotProcessor: &snapshotProcessor,
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
processor.EnableTech(service, version)
|
processor.EnableTech(service, version)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -445,6 +493,10 @@ func rebuildEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||||||
AppName: message.AppName,
|
AppName: message.AppName,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
SnapshotProcessor: &snapshotProcessor,
|
SnapshotProcessor: &snapshotProcessor,
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
err := processor.Rebuild()
|
err := processor.Rebuild()
|
||||||
@ -467,6 +519,10 @@ func addLabelEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||||||
AppName: message.AppName,
|
AppName: message.AppName,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
SnapshotProcessor: &snapshotProcessor,
|
SnapshotProcessor: &snapshotProcessor,
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
err := processor.AddLabel(label)
|
err := processor.AddLabel(label)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -488,6 +544,10 @@ func removeLabelEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||||||
AppName: message.AppName,
|
AppName: message.AppName,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
SnapshotProcessor: &snapshotProcessor,
|
SnapshotProcessor: &snapshotProcessor,
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
err := processor.RemoveLabel(label)
|
err := processor.RemoveLabel(label)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -533,6 +593,10 @@ func getNodeEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||||||
AppName: message.AppName,
|
AppName: message.AppName,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
SnapshotProcessor: &snapshotProcessor,
|
SnapshotProcessor: &snapshotProcessor,
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
node, err := processor.GetNode()
|
node, err := processor.GetNode()
|
||||||
@ -575,6 +639,10 @@ func createSnapshotEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||||||
AppName: message.AppName,
|
AppName: message.AppName,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
SnapshotProcessor: &snapshotProcessor,
|
SnapshotProcessor: &snapshotProcessor,
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
err := processor.CreateSnapshot(strings.Split(message.Payload, ","))
|
err := processor.CreateSnapshot(strings.Split(message.Payload, ","))
|
||||||
@ -605,6 +673,10 @@ func restoreFromSnapshotEventHandler(m *nats.Msg, message *RequestMessage) error
|
|||||||
AppName: message.AppName,
|
AppName: message.AppName,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
SnapshotProcessor: &snapshotProcessor,
|
SnapshotProcessor: &snapshotProcessor,
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
err := processor.RestoreFromSnapshot(message.Payload)
|
err := processor.RestoreFromSnapshot(message.Payload)
|
||||||
@ -633,6 +705,10 @@ func listSnapshotsEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||||||
AppName: message.AppName,
|
AppName: message.AppName,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
SnapshotProcessor: &snapshotProcessor,
|
SnapshotProcessor: &snapshotProcessor,
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
snapshots, err := processor.ListSnapshots()
|
snapshots, err := processor.ListSnapshots()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -666,6 +742,10 @@ func listAppsSnapshotsEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||||||
AppName: message.AppName,
|
AppName: message.AppName,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
SnapshotProcessor: &snapshotProcessor,
|
SnapshotProcessor: &snapshotProcessor,
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
snapshots, err := processor.ListAppsSnapshots(strings.Split(message.Payload, ","))
|
snapshots, err := processor.ListAppsSnapshots(strings.Split(message.Payload, ","))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -699,6 +779,10 @@ func listSnapshotsByLabelEventHandler(m *nats.Msg, message *RequestMessage) erro
|
|||||||
AppName: message.AppName,
|
AppName: message.AppName,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
SnapshotProcessor: &snapshotProcessor,
|
SnapshotProcessor: &snapshotProcessor,
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
snapshots, err := processor.ListSnapshotsByLabel(message.Payload)
|
snapshots, err := processor.ListSnapshotsByLabel(message.Payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -732,6 +816,10 @@ func getSnapshotEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||||||
AppName: message.AppName,
|
AppName: message.AppName,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
SnapshotProcessor: &snapshotProcessor,
|
SnapshotProcessor: &snapshotProcessor,
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
snapshot, err := processor.GetSnapshot(message.Payload)
|
snapshot, err := processor.GetSnapshot(message.Payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -762,6 +850,10 @@ func getSnapshotDownloadLinkEventHandler(m *nats.Msg, message *RequestMessage) e
|
|||||||
AppName: message.AppName,
|
AppName: message.AppName,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
SnapshotProcessor: &snapshotProcessor,
|
SnapshotProcessor: &snapshotProcessor,
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
link, err := processor.GetSnapshotDownloadLink(message.Payload)
|
link, err := processor.GetSnapshotDownloadLink(message.Payload)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -796,6 +888,10 @@ func deleteSnapshotEventHandler(m *nats.Msg, message *RequestMessage) error {
|
|||||||
AppName: message.AppName,
|
AppName: message.AppName,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
SnapshotProcessor: &snapshotProcessor,
|
SnapshotProcessor: &snapshotProcessor,
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
err := processor.DeleteSnapshot(message.Payload)
|
err := processor.DeleteSnapshot(message.Payload)
|
||||||
@ -821,6 +917,10 @@ func deleteAppSnapshotsEventHandler(m *nats.Msg, message *RequestMessage) error
|
|||||||
AppName: message.AppName,
|
AppName: message.AppName,
|
||||||
DB: common.GetDBConnection(),
|
DB: common.GetDBConnection(),
|
||||||
SnapshotProcessor: &snapshotProcessor,
|
SnapshotProcessor: &snapshotProcessor,
|
||||||
|
DockerSock: config.DockerSocket,
|
||||||
|
BindIPHTTP: config.AppsBindIPHTTP,
|
||||||
|
BindIPSSH: config.AppsBindIPSSH,
|
||||||
|
AppsPath: config.AppsPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
err := processor.DeleteAppSnapshots()
|
err := processor.DeleteAppSnapshots()
|
||||||
|
Loading…
Reference in New Issue
Block a user