mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-12-04 15:21:05 +01:00
feat(apps): change log message
This commit is contained in:
parent
da6fa99980
commit
989d3b4a8e
@ -2,6 +2,7 @@ package projects
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/ansible-semaphore/semaphore/util"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"github.com/ansible-semaphore/semaphore/api/helpers"
|
"github.com/ansible-semaphore/semaphore/api/helpers"
|
||||||
@ -81,6 +82,12 @@ func AddTemplate(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, ok := util.Config.Apps[string(newTemplate.App)]; !ok {
|
||||||
|
helpers.WriteErrorStatus(w, "Invalid app id", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check workspace and create it if required.
|
||||||
if newTemplate.App.IsTerraform() {
|
if newTemplate.App.IsTerraform() {
|
||||||
var inv db.Inventory
|
var inv db.Inventory
|
||||||
|
|
||||||
@ -138,6 +145,11 @@ func UpdateTemplate(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, ok := util.Config.Apps[string(template.App)]; !ok {
|
||||||
|
helpers.WriteErrorStatus(w, "Invalid app id", http.StatusBadRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// project ID and template ID in the body and the path must be the same
|
// project ID and template ID in the body and the path must be the same
|
||||||
|
|
||||||
if template.ID != oldTemplate.ID {
|
if template.ID != oldTemplate.ID {
|
||||||
|
@ -18,28 +18,19 @@ func CreateApp(template db.Template, repository db.Repository, logger task_logge
|
|||||||
Logger: logger,
|
Logger: logger,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
case db.TemplateTerraform:
|
case db.TemplateTerraform, db.TemplateTofu:
|
||||||
return &TerraformApp{
|
return &TerraformApp{
|
||||||
Template: template,
|
Template: template,
|
||||||
Repository: repository,
|
Repository: repository,
|
||||||
Logger: logger,
|
Logger: logger,
|
||||||
Name: TerraformAppTerraform,
|
Name: TerraformAppName(template.App),
|
||||||
}
|
}
|
||||||
case db.TemplateTofu:
|
default:
|
||||||
return &TerraformApp{
|
|
||||||
Template: template,
|
|
||||||
Repository: repository,
|
|
||||||
Logger: logger,
|
|
||||||
Name: TerraformAppTofu,
|
|
||||||
}
|
|
||||||
case db.TemplateBash, db.TemplatePowerShell, db.TemplatePython:
|
|
||||||
return &ShellApp{
|
return &ShellApp{
|
||||||
Template: template,
|
Template: template,
|
||||||
Repository: repository,
|
Repository: repository,
|
||||||
Logger: logger,
|
Logger: logger,
|
||||||
App: template.App,
|
App: template.App,
|
||||||
}
|
}
|
||||||
default:
|
|
||||||
panic("unknown app: " + template.App)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,12 @@ func (t *ShellApp) makeShellCmd(args []string, environmentVars *[]string) *exec.
|
|||||||
case db.TemplatePowerShell:
|
case db.TemplatePowerShell:
|
||||||
command = "powershell"
|
command = "powershell"
|
||||||
appArgs = []string{"-File"}
|
appArgs = []string{"-File"}
|
||||||
|
default:
|
||||||
|
if app, ok := util.Config.Apps[string(t.App)]; ok && app.AppPath != "" {
|
||||||
|
command = app.AppPath
|
||||||
|
} else {
|
||||||
|
command = string(t.App)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return t.makeCmd(command, append(appArgs, args...), environmentVars)
|
return t.makeCmd(command, append(appArgs, args...), environmentVars)
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ func (t *LocalJob) getEnvironmentENV() (arr []string, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// nolint: gocyclo
|
// nolint: gocyclo
|
||||||
func (t *LocalJob) getBashArgs(username string, incomingVersion *string) (args []string, err error) {
|
func (t *LocalJob) getShellArgs(username string, incomingVersion *string) (args []string, err error) {
|
||||||
extraVars, err := t.getEnvironmentExtraVars(username, incomingVersion)
|
extraVars, err := t.getEnvironmentExtraVars(username, incomingVersion)
|
||||||
|
|
||||||
args = append(args, t.Template.Playbook)
|
args = append(args, t.Template.Playbook)
|
||||||
@ -378,10 +378,8 @@ func (t *LocalJob) Run(username string, incomingVersion *string) (err error) {
|
|||||||
args, inputs, err = t.getPlaybookArgs(username, incomingVersion)
|
args, inputs, err = t.getPlaybookArgs(username, incomingVersion)
|
||||||
case db.TemplateTerraform, db.TemplateTofu:
|
case db.TemplateTerraform, db.TemplateTofu:
|
||||||
args, err = t.getTerraformArgs(username, incomingVersion)
|
args, err = t.getTerraformArgs(username, incomingVersion)
|
||||||
case db.TemplateBash, db.TemplatePowerShell, db.TemplatePython:
|
|
||||||
args, err = t.getBashArgs(username, incomingVersion)
|
|
||||||
default:
|
default:
|
||||||
panic("unknown template app")
|
args, err = t.getShellArgs(username, incomingVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -158,7 +158,7 @@ func (t *TaskRunner) run() {
|
|||||||
err = t.job.Run(username, incomingVersion)
|
err = t.job.Run(username, incomingVersion)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Log("Running playbook failed: " + err.Error())
|
t.Log("Running app failed: " + err.Error())
|
||||||
t.SetStatus(task_logger.TaskFailStatus)
|
t.SetStatus(task_logger.TaskFailStatus)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -172,7 +172,7 @@ func (t *TaskRunner) run() {
|
|||||||
AutorunOnly: true,
|
AutorunOnly: true,
|
||||||
}, db.RetrieveQueryParams{})
|
}, db.RetrieveQueryParams{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Log("Running playbook failed: " + err.Error())
|
t.Log("Running app failed: " + err.Error())
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ func (t *TaskRunner) run() {
|
|||||||
BuildTaskID: &t.Task.ID,
|
BuildTaskID: &t.Task.ID,
|
||||||
}, nil, tpl.ProjectID)
|
}, nil, tpl.ProjectID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Log("Running playbook failed: " + err.Error())
|
t.Log("Running app failed: " + err.Error())
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<EditDialog
|
<EditDialog
|
||||||
|
v-if="isAppsLoaded"
|
||||||
:max-width="700"
|
:max-width="700"
|
||||||
:min-content-height="457"
|
:min-content-height="457"
|
||||||
v-model="dialog"
|
v-model="dialog"
|
||||||
|
@ -340,7 +340,8 @@ export default {
|
|||||||
|
|
||||||
props: {
|
props: {
|
||||||
sourceItemId: Number,
|
sourceItemId: Number,
|
||||||
fields: Array,
|
fields: Object,
|
||||||
|
app: String,
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
@ -563,6 +564,8 @@ export default {
|
|||||||
cron_format: this.cronFormat,
|
cron_format: this.cronFormat,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.item.app = this.app;
|
||||||
},
|
},
|
||||||
|
|
||||||
async afterSave(newItem) {
|
async afterSave(newItem) {
|
||||||
|
Loading…
Reference in New Issue
Block a user