Skip to content

Commit 5d02ea4

Browse files
committed
fix: merge conflict
2 parents ffde7b5 + 5ea9468 commit 5d02ea4

File tree

14 files changed

+157
-65
lines changed

14 files changed

+157
-65
lines changed

.dredd/hooks/helpers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ func addTask() *db.Task {
222222

223223
if err != nil {
224224
fmt.Println("error during insertion of task:")
225-
if j, err := json.Marshal(t); err == nil {
225+
if j, e := json.Marshal(t); e == nil {
226226
fmt.Println(string(j))
227227
} else {
228228
fmt.Println("can not stringify task object")

api-docs.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -713,20 +713,29 @@ definitions:
713713
type: integer
714714
status:
715715
type: string
716-
debug:
717-
type: boolean
718716
playbook:
719717
type: string
720718
environment:
721719
type: string
722720
secret:
723721
type: string
724-
limit:
725-
type: string
726722
git_branch:
727723
type:
728724
- string
729725
- 'null'
726+
limit:
727+
type: string
728+
params:
729+
type: object
730+
properties:
731+
debug:
732+
type: boolean
733+
dry_run:
734+
type: boolean
735+
diff:
736+
type: boolean
737+
limit:
738+
type: array
730739
message:
731740
type: string
732741

db/Task.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/json"
55
"errors"
66
"fmt"
7+
"strings"
78
"time"
89

910
"github.com/semaphoreui/semaphore/pkg/tz"
@@ -74,6 +75,9 @@ type Task struct {
7475
InventoryID *int `db:"inventory_id" json:"inventory_id,omitempty"`
7576

7677
Params MapStringAnyField `db:"params" json:"params,omitempty"`
78+
79+
// Limit is deprecated, use Params.Limit instead
80+
Limit string `db:"-" json:"limit"`
7781
}
7882

7983
func (task *Task) FillParams(target any) (err error) {
@@ -85,9 +89,27 @@ func (task *Task) FillParams(target any) (err error) {
8589
return
8690
}
8791

92+
// PreInsert is a hook which is called before inserting task into database.
93+
// Called directly in BoltDB implementation.
8894
func (task *Task) PreInsert(gorp.SqlExecutor) error {
8995
task.Created = tz.In(task.Created)
9096

97+
if _, ok := task.Params["limit"]; !ok {
98+
if task.Params == nil {
99+
task.Params = make(MapStringAnyField)
100+
}
101+
102+
if task.Limit != "" {
103+
limits := strings.Split(task.Limit, ",")
104+
105+
for i := range limits {
106+
limits[i] = strings.TrimSpace(limits[i])
107+
}
108+
109+
task.Params["limit"] = limits
110+
}
111+
}
112+
91113
return nil
92114
}
93115

db/bolt/task.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package bolt
22

33
import (
44
"github.com/semaphoreui/semaphore/db"
5-
"github.com/semaphoreui/semaphore/pkg/tz"
65
"go.etcd.io/bbolt"
76
"time"
87
)
@@ -91,7 +90,11 @@ func (d *BoltDb) clearTasks(projectID int, templateID int, maxTasks int) {
9190
}
9291

9392
func (d *BoltDb) CreateTask(task db.Task, maxTasks int) (newTask db.Task, err error) {
94-
task.Created = tz.Now()
93+
err = task.PreInsert(nil)
94+
if err != nil {
95+
return
96+
}
97+
9598
task.ID = 0
9699
res, err := d.createObject(0, db.TaskProps, task)
97100
if err != nil {

deployment/docker/runner/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ RUN apk add --no-cache -U python3-dev build-base openssl-dev libffi-dev cargo &&
8686
find ${ANSIBLE_VENV_PATH} -iname __pycache__ | xargs rm -rf && \
8787
chown -R semaphore:0 /opt/semaphore
8888

89+
RUN echo 'Host *\n StrictHostKeyChecking no\n UserKnownHostsFile /dev/null' > /etc/ssh/ssh_config.d/semaphore.conf
90+
8991
USER 1001
9092

9193
ENV VIRTUAL_ENV="$ANSIBLE_VENV_PATH"

deployment/docker/server/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ RUN apk add --no-cache -U \
6363
chown -R semaphore:0 /opt/semaphore && \
6464
find /usr/lib/python* -iname __pycache__ | xargs rm -rf
6565

66+
RUN echo $'Host *\n StrictHostKeyChecking no\n UserKnownHostsFile /dev/null' > /etc/ssh/ssh_config.d/semaphore.conf
67+
6668
COPY --chown=1001:0 ./deployment/docker/server/ansible.cfg /etc/ansible/ansible.cfg
6769
COPY --from=builder /go/src/semaphore/deployment/docker/server/server-wrapper /usr/local/bin/
6870
COPY --from=builder /go/src/semaphore/bin/semaphore /usr/local/bin/

deployment/docker/server/ansible.cfg

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
[defaults]
22
host_key_checking = False
33
bin_ansible_callbacks = True
4-
stdout_callback = yaml
5-
6-
[ssh_connection]
7-
ssh_args = -o UserKnownHostsFile=/dev/null
4+
stdout_callback = yaml

openapi.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,22 +1556,29 @@ paths:
15561556
properties:
15571557
template_id:
15581558
type: integer
1559-
debug:
1560-
type: boolean
1561-
dry_run:
1562-
type: boolean
1563-
diff:
1564-
type: boolean
15651559
playbook:
15661560
type: string
15671561
environment:
15681562
type: string
1569-
limit:
1570-
type: string
15711563
git_branch:
15721564
type: string
15731565
message:
15741566
type: string
1567+
limit:
1568+
type: string
1569+
deprecated: true
1570+
params:
1571+
type: object
1572+
properties:
1573+
debug:
1574+
type: boolean
1575+
dry_run:
1576+
type: boolean
1577+
diff:
1578+
type: boolean
1579+
limit:
1580+
type: array
1581+
15751582
required: true
15761583
responses:
15771584
'201':

services/tasks/LocalJob.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,15 +425,15 @@ func (t *LocalJob) getPlaybookArgs(username string, incomingVersion *string) (ar
425425

426426
// Fill fields from task
427427

428-
if tplParams.AllowOverrideLimit {
428+
if tplParams.AllowOverrideLimit && params.Limit != nil {
429429
limit = strings.Join(params.Limit, ",")
430430
}
431431

432-
if tplParams.AllowOverrideTags {
432+
if tplParams.AllowOverrideTags && params.Tags != nil {
433433
tags = strings.Join(params.Tags, ",")
434434
}
435435

436-
if tplParams.AllowOverrideSkipTags {
436+
if tplParams.AllowOverrideSkipTags && params.SkipTags != nil {
437437
skipTags = strings.Join(params.SkipTags, ",")
438438
}
439439

web/package-lock.json

Lines changed: 54 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)