mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-12-04 07:11:05 +01:00
feat(terraform): auto approve and plan flags
This commit is contained in:
parent
29c7f53d02
commit
289cd6d937
22
db/Task.go
22
db/Task.go
@ -1,6 +1,7 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/go-gorp/gorp/v3"
|
||||
"time"
|
||||
@ -9,7 +10,7 @@ import (
|
||||
"github.com/semaphoreui/semaphore/util"
|
||||
)
|
||||
|
||||
type ShellTaskParams struct {
|
||||
type DefaultTaskParams struct {
|
||||
}
|
||||
|
||||
type TerraformTaskParams struct {
|
||||
@ -70,7 +71,11 @@ type Task struct {
|
||||
}
|
||||
|
||||
func (task *Task) GetParams(target interface{}) error {
|
||||
return nil
|
||||
content, err := json.Marshal(task.TaskParams)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return json.Unmarshal(content, target)
|
||||
}
|
||||
|
||||
func (task *Task) PreInsert(gorp.SqlExecutor) error {
|
||||
@ -124,7 +129,18 @@ func (task *Task) GetUrl() *string {
|
||||
}
|
||||
|
||||
func (task *Task) ValidateNewTask(template Template) error {
|
||||
return nil
|
||||
|
||||
var params interface{}
|
||||
switch template.App {
|
||||
case AppAnsible:
|
||||
params = &AnsibleTaskParams{}
|
||||
case AppTerraform, AppTofu:
|
||||
params = &TerraformTaskParams{}
|
||||
default:
|
||||
params = &DefaultTaskParams{}
|
||||
}
|
||||
|
||||
return task.GetParams(params)
|
||||
}
|
||||
|
||||
func (task *TaskWithTpl) Fill(d Store) error {
|
||||
|
@ -437,7 +437,7 @@ func (t *LocalJob) Run(username string, incomingVersion *string) (err error) {
|
||||
params = db.TerraformTaskParams{}
|
||||
default:
|
||||
args, err = t.getShellArgs(username, incomingVersion)
|
||||
params = db.ShellTaskParams{}
|
||||
params = db.DefaultTaskParams{}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user