Fix async update
This commit is contained in:
parent
162daf6cba
commit
6cf08d8131
@ -138,19 +138,19 @@ func createEventHandler(m *nats.Msg, message *RequestMessage) error {
|
||||
err := json.Unmarshal(body, &appTemplate)
|
||||
if err != nil {
|
||||
log.Println("ERROR create application problem: " + err.Error())
|
||||
publish(appTemplate.Name, "payload parsing problem", true)
|
||||
publish(message.AppName, "payload parsing problem", true)
|
||||
return err
|
||||
}
|
||||
|
||||
err = apps.New(appTemplate.Name, appTemplate.SSHPort, appTemplate.HTTPPort, appTemplate.Image, appTemplate.CPU, appTemplate.Memory)
|
||||
err = apps.New(message.AppName, appTemplate.SSHPort, appTemplate.HTTPPort, appTemplate.Image, appTemplate.CPU, appTemplate.Memory)
|
||||
if err != nil {
|
||||
if validationError, ok := err.(apps.ValidationError); ok {
|
||||
log.Println("ERROR create application problem: " + validationError.Error())
|
||||
publish(appTemplate.Name, "validation problem", true)
|
||||
publish(message.AppName, "validation problem", true)
|
||||
return err
|
||||
}
|
||||
log.Println("ERROR create application problem: " + err.Error())
|
||||
publish(appTemplate.Name, "backend problem", true)
|
||||
publish(message.AppName, "backend problem", true)
|
||||
return err
|
||||
}
|
||||
|
||||
@ -161,31 +161,30 @@ func createEventHandler(m *nats.Msg, message *RequestMessage) error {
|
||||
err = container.Create()
|
||||
if err != nil {
|
||||
log.Println("ERROR create application problem: " + err.Error())
|
||||
publish(appTemplate.Name, "backend problem", true)
|
||||
publish(message.AppName, "backend problem", true)
|
||||
return err
|
||||
}
|
||||
|
||||
err = container.Start()
|
||||
if err != nil {
|
||||
log.Println("ERROR create application problem: " + err.Error())
|
||||
publish(appTemplate.Name, "backend problem", true)
|
||||
publish(message.AppName, "backend problem", true)
|
||||
return err
|
||||
}
|
||||
|
||||
publish(appTemplate.Name, "created", false)
|
||||
publish(message.AppName, "created", false)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Update existing app
|
||||
func updateEventHandler(m *nats.Msg, message *RequestMessage) error {
|
||||
|
||||
appTemplate := apps.App{}
|
||||
body := []byte(message.Payload)
|
||||
err := json.Unmarshal(body, &appTemplate)
|
||||
if err != nil {
|
||||
log.Println("ERROR update application problem: " + err.Error())
|
||||
publish(appTemplate.Name, "payload parsing problem", true)
|
||||
publish(message.AppName, "payload parsing problem", true)
|
||||
return err
|
||||
}
|
||||
|
||||
@ -193,11 +192,11 @@ func updateEventHandler(m *nats.Msg, message *RequestMessage) error {
|
||||
if err != nil {
|
||||
if validationError, ok := err.(apps.ValidationError); ok {
|
||||
log.Println("ERROR update application problem: " + validationError.Error())
|
||||
publish(appTemplate.Name, "backend problem", true)
|
||||
publish(message.AppName, "backend problem", true)
|
||||
return err
|
||||
}
|
||||
log.Println("ERROR update application problem: " + err.Error())
|
||||
publish(appTemplate.Name, "backend problem", true)
|
||||
publish(message.AppName, "backend problem", true)
|
||||
return err
|
||||
}
|
||||
|
||||
@ -212,25 +211,25 @@ func updateEventHandler(m *nats.Msg, message *RequestMessage) error {
|
||||
}
|
||||
if err != nil {
|
||||
log.Println("ERROR update application problem: " + err.Error())
|
||||
publish(appTemplate.Name, "backend problem", true)
|
||||
publish(app.Name, "backend problem", true)
|
||||
return err
|
||||
}
|
||||
|
||||
err = container.Create()
|
||||
if err != nil {
|
||||
log.Println("ERROR update application problem: " + err.Error())
|
||||
publish(appTemplate.Name, "backend problem", true)
|
||||
publish(app.Name, "backend problem", true)
|
||||
return err
|
||||
}
|
||||
|
||||
err = container.Start()
|
||||
if err != nil {
|
||||
log.Println("ERROR update application problem: " + err.Error())
|
||||
publish(appTemplate.Name, "backend problem", true)
|
||||
publish(app.Name, "backend problem", true)
|
||||
return err
|
||||
}
|
||||
|
||||
publish(appTemplate.Name, "updated", false)
|
||||
publish(app.Name, "updated", false)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user