Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
373f3d1
add interface variable to settings
twhiston May 14, 2018
087acb8
remove collisions on prepareTask stage
strangeman Jun 7, 2018
a817d2d
add requested changes, add some logging
strangeman Jun 8, 2018
b60213a
remove task from queue if it failed (on prepare step)
strangeman Jun 8, 2018
bfe1a4f
Merge pull request #540 from twhiston/interface_setting
twhiston Jun 8, 2018
853fe5f
Merge pull request #546 from UnitedTraders/545-prepare-collisions
twhiston Jun 8, 2018
cd30536
make semaphore less panic
strangeman Jun 14, 2018
8e18b9d
Merge pull request #551 from UnitedTraders/549-dont-panic
strangeman Aug 9, 2018
c5f402b
Add “Extra CLI Arguments” filed to "Create Task" UI.
Sep 11, 2018
4814b7e
Add arguments column on task table.
Sep 11, 2018
5d1ac12
Add task.arguments value to getPlaybookArgs() method.
Sep 11, 2018
70bea1e
add version 2.5.2
Oct 15, 2018
4450534
documentation hotfix
strangeman Oct 20, 2018
cbe0c5f
add compiled_hooks to gitignore
strangeman Oct 20, 2018
2b13fe6
Merge pull request #563 from dahyungKwon/develop
strangeman Oct 22, 2018
7bab8e0
add dredd to dev dc environment
strangeman Oct 22, 2018
bdced30
fix dredd build and launch
strangeman Oct 22, 2018
1bb7fc5
fix `permission denied` errors
strangeman Oct 22, 2018
5e71ce6
add dc dredd to taskfile
strangeman Oct 22, 2018
d113a3a
add documentation about dredd in docker-compose
strangeman Oct 22, 2018
2f85b29
Merge branch 'develop' of https://github.com/ansible-semaphore/semaph…
strangeman Oct 22, 2018
14f5f6b
return 401 instead of 403 on unauthorized pages
strangeman Oct 22, 2018
822c8fd
Merge pull request #567 from UnitedTraders/documentation-improvements
strangeman Oct 22, 2018
b4aac02
Merge branch 'develop' into 523-401-logout
strangeman Oct 22, 2018
5dc8aca
Merge pull request #568 from UnitedTraders/523-401-logout
strangeman Oct 22, 2018
5fa0703
ADMIN-3023 add task slugs
strangeman Dec 26, 2019
93534b2
tune taskfile
strangeman Jan 14, 2020
127fc03
allow custom wrappers for ansible-galaxy and ansible-playbook
strangeman Apr 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ util/version.go
/coverage.out
/public/package-lock.json
!.gitkeep

.dredd/compiled_hooks
10 changes: 4 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,8 @@ This means that you should never run these tests against your productive databas
The best practice to run these tests is to use docker and the task commands.

```bash
task dc:build #First run only to build the images
context=dev task dc:up
task test:api
# alternatively if you want to run dredd in a container use the following command.
# You will need to use the host network so that it can reach the docker container on a 0.0.0.0 address
# docker run -it --rm -v $(pwd):/home/developer/src --network host tomwhiston/dredd --config .dredd/dredd.yml
context=dev task dc:build #build fresh semaphore images
context=dev task dc:up #up semaphore and mysql
task dc:build:dredd #build fresh dredd image
task dc:up:dredd #run dredd over docker-compose stack
```
10 changes: 8 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[[constraint]]
branch = "master"
name = "github.com/castawaylabs/mulekick"
name = "github.com/strangeman/mulekick"

[[constraint]]
name = "github.com/go-sql-driver/mysql"
Expand Down Expand Up @@ -58,6 +58,10 @@
name = "gopkg.in/ldap.v2"
version = "2.5.1"

[[constraint]]
name = "github.com/tjarratt/babble"
branch = "master"

[prune]
go-tests = true
unused-packages = true
25 changes: 23 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ tasks:
sh: git rev-parse --abbrev-ref HEAD
DIRTY:
# We must exclude the package-lock file as npm install can change it!
sh: git diff --exit-code --stat -- . ':(exclude)web/package-lock.json' ':(exclude)web/package.json'
sh: git diff --exit-code --stat -- . ':(exclude)web/package-lock.json' ':(exclude)web/package.json' ':(exclude)deployment/*' ':(exclude)Taskfile*'
SHA:
sh: git log --pretty=format:'%h' -n 1
TIMESTAMP:
Expand Down Expand Up @@ -241,6 +241,27 @@ tasks:
args: stop
context: "{{ .context }}"

dc:build:dredd:
desc: build a dredd container to the local testing with docker-compose stack
cmds:
- task: docker
vars:
context: dev
compose: true
prefix: -dredd
args: build

dc:up:dredd:
desc: build a dredd container to the local testing with docker-compose stack
cmds:
- task: docker
vars:
context: dev
compose: true
prefix: -dredd
args: up


docker:build:
desc: Build an image for Semaphore, requires context
vars:
Expand Down Expand Up @@ -302,4 +323,4 @@ tasks:
vars:
docker_root: deployment/docker/
cmds:
- docker{{ if .compose }}-compose{{ end }} {{ if .action }}{{ .action }}{{ end }} -f {{ .docker_root }}{{ .context }}/{{ if .compose }}docker-compose.yml{{ else }}Dockerfile{{ end }} {{if .args }}{{ .args }}{{ end }}
- docker{{ if .compose }}-compose{{ end }} {{ if .action }}{{ .action }}{{ end }} -f {{ .docker_root }}{{ .context }}/{{ if .compose }}docker-compose{{ if .prefix }}{{ .prefix }}{{ end }}.yml{{ else }}Dockerfile{{ if .prefix }}{{ .prefix }}{{ end }}{{ end }} {{if .args }}{{ .args }}{{ end }}
41 changes: 40 additions & 1 deletion api-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ definitions:
environment_id:
type: integer
minimum: 1
slug:
type: string
alias:
type: string
playbook:
Expand All @@ -301,6 +303,8 @@ definitions:
id:
type: integer
minimum: 1
slug:
type: string
ssh_key_id:
type: integer
minimum: 1
Expand Down Expand Up @@ -424,6 +428,13 @@ parameters:
type: integer
required: true
x-example: 8
slug:
name: slug
description: Slug
in: path
type: string
required: true
x-example: some-task

paths:
/ping:
Expand Down Expand Up @@ -451,7 +462,7 @@ paths:
responses:
200:
description: OK
403:
401:
description: not authenticated

/info:
Expand Down Expand Up @@ -1213,6 +1224,34 @@ paths:
description: Task queued
schema:
$ref: "#/definitions/Task"
/project/{project_id}/slug/{slug}:
parameters:
- $ref: "#/parameters/project_id"
- $ref: "#/parameters/slug"
post:
tags:
- project
summary: Starts a job via task slug
parameters:
- name: task
in: body
required: true
schema:
type: object
properties:
debug:
type: boolean
dry_run:
type: boolean
playbook:
type: string
environment:
type: string
responses:
201:
description: Task queued
schema:
$ref: "#/definitions/Task"
/project/{project_id}/tasks/last:
parameters:
- $ref: "#/parameters/project_id"
Expand Down
14 changes: 7 additions & 7 deletions api/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func authentication(w http.ResponseWriter, r *http.Request) {
var token db.APIToken
if err := db.Mysql.SelectOne(&token, "select * from user__token where id=? and expired=0", strings.Replace(authHeader, "bearer ", "", 1)); err != nil {
if err == sql.ErrNoRows {
w.WriteHeader(http.StatusForbidden)
w.WriteHeader(http.StatusUnauthorized)
return
}

Expand All @@ -32,20 +32,20 @@ func authentication(w http.ResponseWriter, r *http.Request) {
// fetch session from cookie
cookie, err := r.Cookie("semaphore")
if err != nil {
w.WriteHeader(http.StatusForbidden)
w.WriteHeader(http.StatusUnauthorized)
return
}

value := make(map[string]interface{})
if err = util.Cookie.Decode("semaphore", cookie.Value, &value); err != nil {
w.WriteHeader(http.StatusForbidden)
w.WriteHeader(http.StatusUnauthorized)
return
}

user, ok := value["user"]
sessionVal, okSession := value["session"]
if !ok || !okSession {
w.WriteHeader(http.StatusForbidden)
w.WriteHeader(http.StatusUnauthorized)
return
}

Expand All @@ -55,7 +55,7 @@ func authentication(w http.ResponseWriter, r *http.Request) {
// fetch session
var session db.Session
if err := db.Mysql.SelectOne(&session, "select * from session where id=? and user_id=? and expired=0", sessionID, userID); err != nil {
w.WriteHeader(http.StatusForbidden)
w.WriteHeader(http.StatusUnauthorized)
return
}

Expand All @@ -66,7 +66,7 @@ func authentication(w http.ResponseWriter, r *http.Request) {
panic(err)
}

w.WriteHeader(http.StatusForbidden)
w.WriteHeader(http.StatusUnauthorized)
return
}

Expand All @@ -78,7 +78,7 @@ func authentication(w http.ResponseWriter, r *http.Request) {
user, err := db.FetchUser(userID)
if err != nil {
fmt.Println("Can't find user", err)
w.WriteHeader(http.StatusForbidden)
w.WriteHeader(http.StatusUnauthorized)
return
}

Expand Down
4 changes: 2 additions & 2 deletions api/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"net/http"

"github.com/ansible-semaphore/semaphore/db"
"github.com/castawaylabs/mulekick"
"github.com/ansible-semaphore/semaphore/util"
"github.com/gorilla/context"
"github.com/masterminds/squirrel"
"github.com/ansible-semaphore/semaphore/util"
"github.com/strangeman/mulekick"
)

//nolint: gocyclo
Expand Down
2 changes: 1 addition & 1 deletion api/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
log "github.com/Sirupsen/logrus"
"github.com/ansible-semaphore/semaphore/db"
"github.com/ansible-semaphore/semaphore/util"
"github.com/castawaylabs/mulekick"
"github.com/strangeman/mulekick"
sq "github.com/masterminds/squirrel"
"golang.org/x/crypto/bcrypt"
"gopkg.in/ldap.v2"
Expand Down
2 changes: 1 addition & 1 deletion api/projects/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (

"github.com/ansible-semaphore/semaphore/db"
"github.com/ansible-semaphore/semaphore/util"
"github.com/castawaylabs/mulekick"
"github.com/gorilla/context"
"github.com/masterminds/squirrel"
"github.com/strangeman/mulekick"
)

// EnvironmentMiddleware ensures an environment exists and loads it to the context
Expand Down
2 changes: 1 addition & 1 deletion api/projects/inventory.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/ansible-semaphore/semaphore/db"
"github.com/ansible-semaphore/semaphore/util"
"github.com/castawaylabs/mulekick"
"github.com/strangeman/mulekick"
"github.com/gorilla/context"
"github.com/masterminds/squirrel"
"path/filepath"
Expand Down
2 changes: 1 addition & 1 deletion api/projects/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/ansible-semaphore/semaphore/db"
"github.com/ansible-semaphore/semaphore/util"
"github.com/castawaylabs/mulekick"
"github.com/strangeman/mulekick"
"github.com/gorilla/context"
"github.com/masterminds/squirrel"
)
Expand Down
2 changes: 1 addition & 1 deletion api/projects/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (

"github.com/ansible-semaphore/semaphore/db"
"github.com/ansible-semaphore/semaphore/util"
"github.com/castawaylabs/mulekick"
"github.com/strangeman/mulekick"
"github.com/gorilla/context"
"github.com/masterminds/squirrel"
)
Expand Down
2 changes: 1 addition & 1 deletion api/projects/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"net/http"

"github.com/ansible-semaphore/semaphore/db"
"github.com/castawaylabs/mulekick"
"github.com/strangeman/mulekick"
"github.com/gorilla/context"
"github.com/masterminds/squirrel"
"time"
Expand Down
2 changes: 1 addition & 1 deletion api/projects/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/ansible-semaphore/semaphore/db"
"github.com/ansible-semaphore/semaphore/util"
"github.com/castawaylabs/mulekick"
"github.com/strangeman/mulekick"
"github.com/gorilla/context"
"github.com/masterminds/squirrel"
)
Expand Down
Loading