This commit is contained in:
parent
00beda8137
commit
fe8aa885e7
@ -67,7 +67,7 @@ func (a *AppsProcessor) New(name string, SSHPort int, HTTPPort int, image string
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update changes value about app in the database
|
// Update changes value about app in the database
|
||||||
func (a *AppsProcessor) Update(name string, SSHPort int, HTTPPort int, image string, CPU int, memory int) (*App, error) {
|
func (a *AppsProcessor) Update(name string, SSHPort int, HTTPPort int, image string, CPU int, memory int, env map[string]string) (*App, error) {
|
||||||
var app App
|
var app App
|
||||||
|
|
||||||
err := a.DB.Where("name = ?", name).First(&app).Error
|
err := a.DB.Where("name = ?", name).First(&app).Error
|
||||||
@ -98,6 +98,10 @@ func (a *AppsProcessor) Update(name string, SSHPort int, HTTPPort int, image str
|
|||||||
app.HTTPPort = HTTPPort
|
app.HTTPPort = HTTPPort
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(env) != 0 {
|
||||||
|
app.Env = env
|
||||||
|
}
|
||||||
|
|
||||||
validationErrors := app.Validate()
|
validationErrors := app.Validate()
|
||||||
if len(validationErrors) != 0 {
|
if len(validationErrors) != 0 {
|
||||||
return &app, ValidationError{
|
return &app, ValidationError{
|
||||||
|
@ -306,8 +306,12 @@ func (p *Processor) Register(appTemplate apps.App) error {
|
|||||||
|
|
||||||
// Update updates application
|
// Update updates application
|
||||||
func (p *Processor) Update(appTemplate apps.App) error {
|
func (p *Processor) Update(appTemplate apps.App) error {
|
||||||
|
if appTemplate.Env == nil {
|
||||||
|
appTemplate.Env = make(map[string]string)
|
||||||
|
}
|
||||||
|
|
||||||
processor := p.getAppProcessor()
|
processor := p.getAppProcessor()
|
||||||
app, err := processor.Update(appTemplate.Name, appTemplate.SSHPort, appTemplate.HTTPPort, appTemplate.Image, appTemplate.CPU, appTemplate.Memory)
|
app, err := processor.Update(appTemplate.Name, appTemplate.SSHPort, appTemplate.HTTPPort, appTemplate.Image, appTemplate.CPU, appTemplate.Memory, appTemplate.Env)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if validationError, ok := err.(apps.ValidationError); ok {
|
if validationError, ok := err.(apps.ValidationError); ok {
|
||||||
return fmt.Errorf("validation error: %v", validationError.Error())
|
return fmt.Errorf("validation error: %v", validationError.Error())
|
||||||
|
Loading…
Reference in New Issue
Block a user