From 3161fa9ae24f50aa9f900c7e70bb77e80aaaf4be Mon Sep 17 00:00:00 2001 From: Denis Gukov Date: Sun, 24 Nov 2024 15:05:07 +0500 Subject: [PATCH] feat: params --- db/Migration.go | 1 + db/Task.go | 17 +++++++++++++++++ db/sql/migrations/v2.10.46.sql | 2 ++ 3 files changed, 20 insertions(+) create mode 100644 db/sql/migrations/v2.10.46.sql diff --git a/db/Migration.go b/db/Migration.go index 47772867..e21bc85d 100644 --- a/db/Migration.go +++ b/db/Migration.go @@ -75,6 +75,7 @@ func GetMigrations() []Migration { {Version: "2.10.26"}, {Version: "2.10.28"}, {Version: "2.10.33"}, + {Version: "2.10.46"}, } } diff --git a/db/Task.go b/db/Task.go index b10c0989..43609a59 100644 --- a/db/Task.go +++ b/db/Task.go @@ -9,6 +9,17 @@ import ( "github.com/semaphoreui/semaphore/util" ) +type TerraformTaskParams struct { + Plan bool `json:"plan"` + AutoApprove bool `json:"auto_approve"` +} + +type AnsibleTaskParams struct { + Debug bool `json:"debug"` + DryRun bool `json:"dry_run"` + Diff bool `json:"diff"` +} + // Task is a model of a task which will be executed by the runner type Task struct { ID int `db:"id" json:"id"` @@ -51,6 +62,12 @@ type Task struct { Version *string `db:"version" json:"version"` InventoryID *int `db:"inventory_id" json:"inventory_id"` + + TaskParams MapStringAnyField `db:"params" json:"params"` +} + +func (task *Task) GetParams(target interface{}) error { + return nil } func (task *Task) PreInsert(gorp.SqlExecutor) error { diff --git a/db/sql/migrations/v2.10.46.sql b/db/sql/migrations/v2.10.46.sql new file mode 100644 index 00000000..d9ddbca8 --- /dev/null +++ b/db/sql/migrations/v2.10.46.sql @@ -0,0 +1,2 @@ +alter table `project__template` add `task_params` text; +alter table `task` add `params` text; \ No newline at end of file