mirror of
https://github.com/semaphoreui/semaphore.git
synced 2024-12-04 23:31: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
|
package db
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/go-gorp/gorp/v3"
|
"github.com/go-gorp/gorp/v3"
|
||||||
"time"
|
"time"
|
||||||
@ -9,7 +10,7 @@ import (
|
|||||||
"github.com/semaphoreui/semaphore/util"
|
"github.com/semaphoreui/semaphore/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ShellTaskParams struct {
|
type DefaultTaskParams struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type TerraformTaskParams struct {
|
type TerraformTaskParams struct {
|
||||||
@ -70,7 +71,11 @@ type Task struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (task *Task) GetParams(target interface{}) error {
|
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 {
|
func (task *Task) PreInsert(gorp.SqlExecutor) error {
|
||||||
@ -124,7 +129,18 @@ func (task *Task) GetUrl() *string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (task *Task) ValidateNewTask(template Template) error {
|
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 {
|
func (task *TaskWithTpl) Fill(d Store) error {
|
||||||
|
@ -437,7 +437,7 @@ func (t *LocalJob) Run(username string, incomingVersion *string) (err error) {
|
|||||||
params = db.TerraformTaskParams{}
|
params = db.TerraformTaskParams{}
|
||||||
default:
|
default:
|
||||||
args, err = t.getShellArgs(username, incomingVersion)
|
args, err = t.getShellArgs(username, incomingVersion)
|
||||||
params = db.ShellTaskParams{}
|
params = db.DefaultTaskParams{}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user