fix: merge conflict
13
.github/FUNDING.yml
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
# These are supported funding model platforms
|
||||||
|
|
||||||
|
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||||
|
patreon: # Replace with a single Patreon username
|
||||||
|
open_collective: semaphore
|
||||||
|
ko_fi: fiftin
|
||||||
|
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||||
|
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||||
|
liberapay: # Replace with a single Liberapay username
|
||||||
|
issuehunt: # Replace with a single IssueHunt username
|
||||||
|
otechie: # Replace with a single Otechie username
|
||||||
|
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
||||||
|
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
61
.github/workflows/dev.yml
vendored
@ -23,37 +23,40 @@ jobs:
|
|||||||
- run: task compile
|
- run: task compile
|
||||||
|
|
||||||
- name: Test that compile did not create/modify untracked files
|
- name: Test that compile did not create/modify untracked files
|
||||||
run: git diff --exit-code --stat -- . ':(exclude)web2/package.json' ':(exclude)web2/package-lock.json' ':(exclude)go.mod' ':(exclude)go.sum'
|
run: git diff --exit-code --stat -- . ':(exclude)web/package.json' ':(exclude)web/package-lock.json' ':(exclude)go.mod' ':(exclude)go.sum'
|
||||||
|
|
||||||
- run: task build:local
|
- run: task build:local GOOS= GOARCH=
|
||||||
|
|
||||||
|
- run: task test
|
||||||
|
|
||||||
- uses: actions/upload-artifact@master
|
- uses: actions/upload-artifact@master
|
||||||
with:
|
with:
|
||||||
name: semaphore
|
name: semaphore
|
||||||
path: bin/semaphore
|
path: bin/semaphore
|
||||||
|
retention-days: 1
|
||||||
|
|
||||||
|
|
||||||
test-golang:
|
# test-golang:
|
||||||
runs-on: [ubuntu-latest]
|
# runs-on: [ubuntu-latest]
|
||||||
needs: build-local
|
# needs: build-local
|
||||||
steps:
|
# steps:
|
||||||
- uses: actions/setup-go@v3
|
# - uses: actions/setup-go@v3
|
||||||
with: { go-version: 1.18 }
|
# with: { go-version: 1.18 }
|
||||||
|
#
|
||||||
- run: go install github.com/go-task/task/v3/cmd/task@latest
|
# - run: go install github.com/go-task/task/v3/cmd/task@latest
|
||||||
|
#
|
||||||
- uses: actions/checkout@v3
|
# - uses: actions/checkout@v3
|
||||||
|
#
|
||||||
- run: task deps:tools
|
# - run: task deps:tools
|
||||||
- run: task deps:be
|
# - run: task deps:be
|
||||||
- run: task compile:be
|
# - run: task compile:be
|
||||||
# - run: task lint:be
|
# - run: task lint:be
|
||||||
- run: task test
|
# - run: task test
|
||||||
|
|
||||||
|
|
||||||
test-db-migration:
|
test-db-migration:
|
||||||
runs-on: [ubuntu-latest]
|
runs-on: [ubuntu-latest]
|
||||||
needs: [build-local, test-golang]
|
needs: [build-local]
|
||||||
steps:
|
steps:
|
||||||
- uses: shogo82148/actions-setup-mysql@v1
|
- uses: shogo82148/actions-setup-mysql@v1
|
||||||
with:
|
with:
|
||||||
@ -95,12 +98,26 @@ jobs:
|
|||||||
|
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- run: context=prod task docker:test
|
# - run: context=prod task docker:test
|
||||||
|
|
||||||
- run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASS }}
|
- uses: docker/setup-qemu-action@v2
|
||||||
- run: context=prod tag=develop task docker:build
|
|
||||||
- run: tag=develop task docker:push
|
|
||||||
|
|
||||||
|
- uses: docker/setup-buildx-action@v2
|
||||||
|
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USER }}
|
||||||
|
password: ${{ secrets.DOCKER_PASS }}
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
file: ./deployment/docker/prod/buildx.Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: semaphoreui/semaphore:develop
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
25
.github/workflows/release.yml
vendored
@ -42,10 +42,23 @@ jobs:
|
|||||||
|
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- run: context=prod task docker:test
|
# - run: context=prod task docker:test
|
||||||
|
|
||||||
- run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASS }}
|
- uses: docker/setup-qemu-action@v2
|
||||||
- run: context=prod tag=latest task docker:build
|
|
||||||
- run: tag=latest task docker:push
|
- uses: docker/setup-buildx-action@v2
|
||||||
- run: docker tag semaphoreui/semaphore:latest semaphoreui/semaphore:${{ github.ref_name }}
|
|
||||||
- run: tag=${{ github.ref_name }} task docker:push
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_USER }}
|
||||||
|
password: ${{ secrets.DOCKER_PASS }}
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
file: ./deployment/docker/prod/buildx.Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: semaphoreui/semaphore:latest,semaphoreui/semaphore:${{ github.ref_name }}
|
4
.gitignore
vendored
@ -4,8 +4,8 @@ web/public/js/bundle.js
|
|||||||
web/public/css/*.*
|
web/public/css/*.*
|
||||||
web/public/html/**/*.*
|
web/public/html/**/*.*
|
||||||
web/public/fonts/*.*
|
web/public/fonts/*.*
|
||||||
web2/.nyc_output
|
web/.nyc_output
|
||||||
web2/dist/**/*
|
web/dist/**/*
|
||||||
/config.json
|
/config.json
|
||||||
/.dredd/config.json
|
/.dredd/config.json
|
||||||
/database.boltdb
|
/database.boltdb
|
||||||
|
36
README.md
@ -1,8 +1,7 @@
|
|||||||
# Ansible Semaphore
|
# Ansible Semaphore
|
||||||
|
|
||||||
[![Circle CI](https://circleci.com/gh/ansible-semaphore/semaphore.svg?style=svg&circle-token=3702872acf2bec629017fa7dd99fdbea56aef7df)](https://circleci.com/gh/ansible-semaphore/semaphore)
|
|
||||||
[![Twitter](https://img.shields.io/twitter/follow/AnsibleSem?style=social&logo=twitter)](https://twitter.com/AnsibleSem)
|
[![Twitter](https://img.shields.io/twitter/follow/AnsibleSem?style=social&logo=twitter)](https://twitter.com/AnsibleSem)
|
||||||
[![Snap](https://img.shields.io/badge/snap-semaphore-005c63)](https://snapcraft.io/semaphore)
|
[![semaphore](https://snapcraft.io/semaphore/badge.svg)](https://snapcraft.io/semaphore)
|
||||||
[![StackShare](https://img.shields.io/badge/tech-stack-008ff9)](https://stackshare.io/ansible-semaphore)
|
[![StackShare](https://img.shields.io/badge/tech-stack-008ff9)](https://stackshare.io/ansible-semaphore)
|
||||||
[![Join the chat at https://gitter.im/AnsibleSemaphore/semaphore](https://img.shields.io/gitter/room/AnsibleSemaphore/semaphore?logo=gitter)](https://gitter.im/AnsibleSemaphore/semaphore?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
[![Join the chat at https://gitter.im/AnsibleSemaphore/semaphore](https://img.shields.io/gitter/room/AnsibleSemaphore/semaphore?logo=gitter)](https://gitter.im/AnsibleSemaphore/semaphore?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
|
|
||||||
@ -42,10 +41,41 @@ Follow Semaphore on Twitter ([AnsibleSem](https://twitter.com/AnsibleSem)) and S
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
### Full documentation
|
||||||
https://docs.ansible-semaphore.com/administration-guide/installation
|
https://docs.ansible-semaphore.com/administration-guide/installation
|
||||||
|
|
||||||
|
### Snap
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo snap install semaphore
|
||||||
|
sudo snap stop semaphore # BoltDB limitation, it allows only one connection
|
||||||
|
sudo semaphore user add --admin --name "Your Name" --login your_login --email your-email@examaple.com --password your_password
|
||||||
|
sudo snap start semaphore
|
||||||
|
```
|
||||||
[![Get it from the Snap Store](https://snapcraft.io/static/images/badges/en/snap-store-black.svg)](https://snapcraft.io/semaphore)
|
[![Get it from the Snap Store](https://snapcraft.io/static/images/badges/en/snap-store-black.svg)](https://snapcraft.io/semaphore)
|
||||||
|
|
||||||
|
### Docker
|
||||||
|
|
||||||
|
`docker-compose.yml` for minimal configuration:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
services:
|
||||||
|
semaphore:
|
||||||
|
ports:
|
||||||
|
- 3000:3000
|
||||||
|
image: semaphoreui/semaphore:latest
|
||||||
|
environment:
|
||||||
|
SEMAPHORE_DB_DIALECT: bolt
|
||||||
|
SEMAPHORE_ADMIN_PASSWORD: changeme
|
||||||
|
SEMAPHORE_ADMIN_NAME: admin
|
||||||
|
SEMAPHORE_ADMIN_EMAIL: admin@localhost
|
||||||
|
SEMAPHORE_ADMIN: admin
|
||||||
|
volumes:
|
||||||
|
- /path/to/data/home:/etc/semaphore # config.json location
|
||||||
|
- /path/to/data/lib:/var/lib/semaphore # database.boltdb location (Not required if using mysql or postgres)
|
||||||
|
```
|
||||||
|
https://hub.docker.com/r/semaphoreui/semaphore
|
||||||
|
|
||||||
## Demo
|
## Demo
|
||||||
|
|
||||||
You can test latest version of Semaphore on https://demo.ansible-semaphore.com.
|
You can test latest version of Semaphore on https://demo.ansible-semaphore.com.
|
||||||
@ -54,7 +84,7 @@ You can test latest version of Semaphore on https://demo.ansible-semaphore.com.
|
|||||||
|
|
||||||
Admin and user docs: https://docs.ansible-semaphore.com
|
Admin and user docs: https://docs.ansible-semaphore.com
|
||||||
|
|
||||||
API docs: https://ansible-semaphore.com/api/
|
API description: https://ansible-semaphore.com/api/
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
|
33
Taskfile.yml
@ -19,6 +19,9 @@ tasks:
|
|||||||
- task: compile
|
- task: compile
|
||||||
- task: test
|
- task: test
|
||||||
- task: build:local
|
- task: build:local
|
||||||
|
vars:
|
||||||
|
GOOS: ''
|
||||||
|
GOARCH: ''
|
||||||
|
|
||||||
deps:
|
deps:
|
||||||
desc: Install all dependencies (except dredd requirements)
|
desc: Install all dependencies (except dredd requirements)
|
||||||
@ -34,29 +37,28 @@ tasks:
|
|||||||
|
|
||||||
deps:fe2:
|
deps:fe2:
|
||||||
desc: Installs npm requirements for front end from package.json
|
desc: Installs npm requirements for front end from package.json
|
||||||
dir: web2
|
dir: web
|
||||||
cmds:
|
cmds:
|
||||||
- npm install
|
- npm install
|
||||||
# - npm audit fix
|
# - npm audit fix
|
||||||
|
|
||||||
deps:integration:
|
deps:integration:
|
||||||
desc: Installs requirements for integration testing with dredd
|
desc: Installs requirements for integration testing with dredd
|
||||||
dir: web2
|
dir: web
|
||||||
cmds:
|
cmds:
|
||||||
- npm install dredd@13.1.2
|
- npm install dredd@13.1.2
|
||||||
# - npm audit fix
|
# - npm audit fix
|
||||||
|
|
||||||
deps:tools:
|
deps:tools:
|
||||||
desc: Installs tools needed
|
desc: Installs tools needed
|
||||||
dir: web2
|
dir: web
|
||||||
vars:
|
vars:
|
||||||
GORELEASER_VERSION: "0.159.0"
|
GORELEASER_VERSION: "0.183.0"
|
||||||
GOLINTER_VERSION: "1.46.2"
|
GOLINTER_VERSION: "1.46.2"
|
||||||
cmds:
|
cmds:
|
||||||
- go install github.com/gobuffalo/packr/...@v1.10.4
|
- go install github.com/gobuffalo/packr/...@v1.10.4
|
||||||
- go install github.com/haya14busa/goverage@latest
|
|
||||||
- go install github.com/snikch/goodman/cmd/goodman@latest
|
- go install github.com/snikch/goodman/cmd/goodman@latest
|
||||||
- go install github.com/go-swagger/go-swagger/cmd/swagger@latest
|
- go install github.com/go-swagger/go-swagger/cmd/swagger@v0.29.0
|
||||||
- '{{ if ne OS "windows" }} sh -c "curl -L https://github.com/goreleaser/goreleaser/releases/download/v{{ .GORELEASER_VERSION }}/goreleaser_$(uname -s)_$(uname -m).tar.gz | tar -xz -C $(go env GOPATH)/bin goreleaser"{{ else }} {{ end }}'
|
- '{{ if ne OS "windows" }} sh -c "curl -L https://github.com/goreleaser/goreleaser/releases/download/v{{ .GORELEASER_VERSION }}/goreleaser_$(uname -s)_$(uname -m).tar.gz | tar -xz -C $(go env GOPATH)/bin goreleaser"{{ else }} {{ end }}'
|
||||||
- '{{ if ne OS "windows" }} chmod +x $(go env GOPATH)/bin/goreleaser{{ else }} {{ end }}'
|
- '{{ if ne OS "windows" }} chmod +x $(go env GOPATH)/bin/goreleaser{{ else }} {{ end }}'
|
||||||
- '{{ if eq OS "windows" }} echo "NOTICE: You must download goreleaser manually to build this application https://github.com/goreleaser/goreleaser/releases "{{ else }}:{{ end }}'
|
- '{{ if eq OS "windows" }} echo "NOTICE: You must download goreleaser manually to build this application https://github.com/goreleaser/goreleaser/releases "{{ else }}:{{ end }}'
|
||||||
@ -71,7 +73,7 @@ tasks:
|
|||||||
|
|
||||||
compile:fe2:
|
compile:fe2:
|
||||||
desc: Build vue.js project
|
desc: Build vue.js project
|
||||||
dir: web2
|
dir: web
|
||||||
sources:
|
sources:
|
||||||
- src/*.*
|
- src/*.*
|
||||||
- src/**/*.*
|
- src/**/*.*
|
||||||
@ -92,13 +94,13 @@ tasks:
|
|||||||
compile:be:
|
compile:be:
|
||||||
desc: Runs Packr for static assets
|
desc: Runs Packr for static assets
|
||||||
sources:
|
sources:
|
||||||
- web2/dist/*
|
- web/dist/*
|
||||||
- db/migrations/*
|
- db/migrations/*
|
||||||
generates:
|
generates:
|
||||||
- db/db-packr.go
|
- db/db-packr.go
|
||||||
- api/api-packr.go
|
- api/api-packr.go
|
||||||
cmds:
|
cmds:
|
||||||
- mkdir -p web2/dist
|
- mkdir -p web/dist
|
||||||
- go run util/version_gen/generator.go {{ if .TAG }}{{ .TAG }}{{ else }}{{ if .SEMAPHORE_VERSION }}{{ .SEMAPHORE_VERSION }}{{ else }}{{ .BRANCH }}-{{ .SHA }}-{{ .TIMESTAMP }}{{ if .DIRTY }}-dirty{{ end }}{{ end }}{{end}}
|
- go run util/version_gen/generator.go {{ if .TAG }}{{ .TAG }}{{ else }}{{ if .SEMAPHORE_VERSION }}{{ .SEMAPHORE_VERSION }}{{ else }}{{ .BRANCH }}-{{ .SHA }}-{{ .TIMESTAMP }}{{ if .DIRTY }}-dirty{{ end }}{{ end }}{{end}}
|
||||||
- packr
|
- packr
|
||||||
vars:
|
vars:
|
||||||
@ -108,7 +110,7 @@ tasks:
|
|||||||
sh: git rev-parse --abbrev-ref HEAD
|
sh: git rev-parse --abbrev-ref HEAD
|
||||||
DIRTY:
|
DIRTY:
|
||||||
# We must exclude the package-lock file as npm install can change it!
|
# We must exclude the package-lock file as npm install can change it!
|
||||||
sh: git diff --exit-code --stat -- . ':(exclude)web2/package-lock.json' ':(exclude)web2/package.json' || true
|
sh: git diff --exit-code --stat -- . ':(exclude)web/package-lock.json' ':(exclude)web/package.json' || true
|
||||||
SHA:
|
SHA:
|
||||||
sh: git log --pretty=format:'%h' -n 1
|
sh: git log --pretty=format:'%h' -n 1
|
||||||
TIMESTAMP:
|
TIMESTAMP:
|
||||||
@ -128,7 +130,7 @@ tasks:
|
|||||||
desc: Build a binary for the current architecture
|
desc: Build a binary for the current architecture
|
||||||
dir: cli
|
dir: cli
|
||||||
cmds:
|
cmds:
|
||||||
- go build -o ../bin/semaphore{{ if eq OS "windows" }}.exe{{ end }}
|
- env GOOS={{ .GOOS }} GOARCH={{ .GOARCH }} go build -o ../bin/semaphore{{ if eq OS "windows" }}.exe{{ end }}
|
||||||
|
|
||||||
release:
|
release:
|
||||||
desc: creates a release without performing validations or publishing artifacts
|
desc: creates a release without performing validations or publishing artifacts
|
||||||
@ -157,14 +159,12 @@ tasks:
|
|||||||
cmds:
|
cmds:
|
||||||
- go vet ./...
|
- go vet ./...
|
||||||
- swagger validate ./api-docs.yml
|
- swagger validate ./api-docs.yml
|
||||||
# 2> /dev/null makes goverage less noisy about pattern matching
|
- go test -v -coverprofile=coverage.out ./...
|
||||||
# if no tests exist but will still print failing test results
|
|
||||||
- goverage -v -coverprofile=coverage.out ./... 2> /dev/null
|
|
||||||
|
|
||||||
test:api:
|
test:api:
|
||||||
desc: test the api with dredd
|
desc: test the api with dredd
|
||||||
cmds:
|
cmds:
|
||||||
- ./web2/node_modules/.bin/dredd --config .dredd/dredd.yml
|
- ./web/node_modules/.bin/dredd --config .dredd/dredd.yml
|
||||||
|
|
||||||
ci:artifacts:
|
ci:artifacts:
|
||||||
cmds:
|
cmds:
|
||||||
@ -252,7 +252,6 @@ tasks:
|
|||||||
prefix: -dredd
|
prefix: -dredd
|
||||||
args: up
|
args: up
|
||||||
|
|
||||||
|
|
||||||
docker:build:
|
docker:build:
|
||||||
desc: Build an image for Semaphore, requires context
|
desc: Build an image for Semaphore, requires context
|
||||||
vars:
|
vars:
|
||||||
@ -276,7 +275,7 @@ tasks:
|
|||||||
- sudo chmod +rx /usr/local/bin/goss
|
- sudo chmod +rx /usr/local/bin/goss
|
||||||
- sudo curl -L https://raw.githubusercontent.com/aelsabbahy/goss/v0.3.5/extras/dgoss/dgoss -o /usr/local/bin/dgoss
|
- sudo curl -L https://raw.githubusercontent.com/aelsabbahy/goss/v0.3.5/extras/dgoss/dgoss -o /usr/local/bin/dgoss
|
||||||
- sudo chmod +rx /usr/local/bin/dgoss
|
- sudo chmod +rx /usr/local/bin/dgoss
|
||||||
- sudo curl -L https://github.com/hadolint/hadolint/releases/download/v1.5.0/hadolint-Linux-x86_64 -o /usr/local/bin/hadolint
|
- sudo curl -L https://github.com/hadolint/hadolint/releases/download/v2.10.0/hadolint-Linux-x86_64 -o /usr/local/bin/hadolint
|
||||||
- sudo chmod +rx /usr/local/bin/hadolint
|
- sudo chmod +rx /usr/local/bin/hadolint
|
||||||
|
|
||||||
docker:test:
|
docker:test:
|
||||||
|
@ -4,3 +4,7 @@ tasks:
|
|||||||
cmds:
|
cmds:
|
||||||
- packr
|
- packr
|
||||||
- go run util/version_gen/generator.go 1
|
- go run util/version_gen/generator.go 1
|
||||||
|
build:local:
|
||||||
|
dir: cli
|
||||||
|
cmds:
|
||||||
|
- go build -o ../bin/semaphore{{ if eq OS "windows" }}.exe{{ end }}
|
||||||
|
@ -1448,6 +1448,8 @@ paths:
|
|||||||
type: boolean
|
type: boolean
|
||||||
dry_run:
|
dry_run:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
diff:
|
||||||
|
type: boolean
|
||||||
playbook:
|
playbook:
|
||||||
type: string
|
type: string
|
||||||
environment:
|
environment:
|
||||||
|
74
api/login.go
@ -7,14 +7,14 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"golang.org/x/crypto/bcrypt"
|
||||||
|
|
||||||
"github.com/ansible-semaphore/semaphore/api/helpers"
|
"github.com/ansible-semaphore/semaphore/api/helpers"
|
||||||
"github.com/ansible-semaphore/semaphore/db"
|
"github.com/ansible-semaphore/semaphore/db"
|
||||||
"github.com/go-ldap/ldap/v3"
|
"github.com/go-ldap/ldap/v3"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
"github.com/ansible-semaphore/semaphore/util"
|
"github.com/ansible-semaphore/semaphore/util"
|
||||||
|
|
||||||
"golang.org/x/crypto/bcrypt"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func tryFindLDAPUser(username, password string) (*db.User, error) {
|
func tryFindLDAPUser(username, password string) (*db.User, error) {
|
||||||
@ -146,6 +146,43 @@ func createSession(w http.ResponseWriter, r *http.Request, user db.User) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func loginByPassword(store db.Store, login string, password string) (user db.User, err error) {
|
||||||
|
user, err = store.GetUserByLoginOrEmail(login, login)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.External {
|
||||||
|
err = db.ErrNotFound
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(password))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
err = db.ErrNotFound
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func loginByLDAP(store db.Store, ldapUser db.User) (user db.User, err error) {
|
||||||
|
user, err = store.GetUserByLoginOrEmail(ldapUser.Username, ldapUser.Email)
|
||||||
|
|
||||||
|
if err == db.ErrNotFound {
|
||||||
|
user, err = store.CreateUserWithoutPassword(ldapUser)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !user.External {
|
||||||
|
err = db.ErrNotFound
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// nolint: gocyclo
|
// nolint: gocyclo
|
||||||
func login(w http.ResponseWriter, r *http.Request) {
|
func login(w http.ResponseWriter, r *http.Request) {
|
||||||
var login struct {
|
var login struct {
|
||||||
@ -180,39 +217,22 @@ func login(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
user, err := helpers.Store(r).GetUserByLoginOrEmail(login.Auth, login.Auth)
|
var user db.User
|
||||||
|
|
||||||
if err == db.ErrNotFound {
|
if ldapUser == nil {
|
||||||
if ldapUser != nil {
|
user, err = loginByPassword(helpers.Store(r), login.Auth, login.Password)
|
||||||
// create new LDAP user
|
|
||||||
user, err = helpers.Store(r).CreateUserWithoutPassword(*ldapUser)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
user, err = loginByLDAP(helpers.Store(r), *ldapUser)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
if err == db.ErrNotFound {
|
||||||
w.WriteHeader(http.StatusUnauthorized)
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else if err != nil {
|
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if ldap user & no ldap user found
|
|
||||||
if user.External && ldapUser == nil {
|
|
||||||
w.WriteHeader(http.StatusUnauthorized)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// non-ldap login
|
|
||||||
if !user.External {
|
|
||||||
if err = bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(login.Password)); err != nil {
|
|
||||||
w.WriteHeader(http.StatusUnauthorized)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// authenticated.
|
|
||||||
}
|
|
||||||
|
|
||||||
createSession(w, r, user)
|
createSession(w, r, user)
|
||||||
|
|
||||||
w.WriteHeader(http.StatusNoContent)
|
w.WriteHeader(http.StatusNoContent)
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
var publicAssets2 = packr.NewBox("../web2/dist")
|
var publicAssets2 = packr.NewBox("../web/dist")
|
||||||
|
|
||||||
//JSONMiddleware ensures that all the routes respond with Json, this is added by default to all routes
|
//JSONMiddleware ensures that all the routes respond with Json, this is added by default to all routes
|
||||||
func JSONMiddleware(next http.Handler) http.Handler {
|
func JSONMiddleware(next http.Handler) http.Handler {
|
||||||
|
@ -27,18 +27,10 @@ var setupCmd = &cobra.Command{
|
|||||||
//nolint: gocyclo
|
//nolint: gocyclo
|
||||||
func doSetup() int {
|
func doSetup() int {
|
||||||
var config *util.ConfigType
|
var config *util.ConfigType
|
||||||
for {
|
|
||||||
config = &util.ConfigType{}
|
config = &util.ConfigType{}
|
||||||
config.GenerateSecrets()
|
config.GenerateSecrets()
|
||||||
setup.InteractiveSetup(config)
|
setup.InteractiveSetup(config)
|
||||||
|
|
||||||
if setup.AskConfigConfirmation(config) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println()
|
|
||||||
}
|
|
||||||
|
|
||||||
configPath := setup.SaveConfig(config)
|
configPath := setup.SaveConfig(config)
|
||||||
util.Config = config
|
util.Config = config
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ const (
|
|||||||
AccessKeySSH AccessKeyType = "ssh"
|
AccessKeySSH AccessKeyType = "ssh"
|
||||||
AccessKeyNone AccessKeyType = "none"
|
AccessKeyNone AccessKeyType = "none"
|
||||||
AccessKeyLoginPassword AccessKeyType = "login_password"
|
AccessKeyLoginPassword AccessKeyType = "login_password"
|
||||||
AccessKeyPAT AccessKeyType = "pat"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// AccessKey represents a key used to access a machine with ansible from semaphore
|
// AccessKey represents a key used to access a machine with ansible from semaphore
|
||||||
@ -40,7 +39,6 @@ type AccessKey struct {
|
|||||||
|
|
||||||
LoginPassword LoginPassword `db:"-" json:"login_password"`
|
LoginPassword LoginPassword `db:"-" json:"login_password"`
|
||||||
SshKey SshKey `db:"-" json:"ssh"`
|
SshKey SshKey `db:"-" json:"ssh"`
|
||||||
PAT string `db:"-" json:"pat"`
|
|
||||||
OverrideSecret bool `db:"-" json:"override_secret"`
|
OverrideSecret bool `db:"-" json:"override_secret"`
|
||||||
|
|
||||||
InstallationKey int64 `db:"-" json:"-"`
|
InstallationKey int64 `db:"-" json:"-"`
|
||||||
@ -193,8 +191,6 @@ func (key *AccessKey) SerializeSecret() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
case AccessKeyPAT:
|
|
||||||
plaintext = []byte(key.PAT)
|
|
||||||
case AccessKeyNone:
|
case AccessKeyNone:
|
||||||
key.Secret = nil
|
key.Secret = nil
|
||||||
return nil
|
return nil
|
||||||
@ -251,8 +247,6 @@ func (key *AccessKey) unmarshalAppropriateField(secret []byte) (err error) {
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
key.LoginPassword = loginPass
|
key.LoginPassword = loginPass
|
||||||
}
|
}
|
||||||
case AccessKeyPAT:
|
|
||||||
key.PAT = string(secret)
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,8 @@ func getEventObjectName(d Store, evt Event) (string, error) {
|
|||||||
case EventTask:
|
case EventTask:
|
||||||
task, err := d.GetTask(*evt.ProjectID, *evt.ObjectID)
|
task, err := d.GetTask(*evt.ProjectID, *evt.ObjectID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
// Task can be deleted, it is ok, just return empty string
|
||||||
|
return "", nil
|
||||||
}
|
}
|
||||||
return task.Playbook, nil
|
return task.Playbook, nil
|
||||||
default:
|
default:
|
||||||
|
@ -58,6 +58,7 @@ func GetMigrations() []Migration {
|
|||||||
{Version: "2.8.42"},
|
{Version: "2.8.42"},
|
||||||
{Version: "2.8.51"},
|
{Version: "2.8.51"},
|
||||||
{Version: "2.8.57"},
|
{Version: "2.8.57"},
|
||||||
|
{Version: "2.8.58"},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,8 +80,6 @@ func (r Repository) GetGitURL() string {
|
|||||||
switch r.SSHKey.Type {
|
switch r.SSHKey.Type {
|
||||||
case AccessKeyLoginPassword:
|
case AccessKeyLoginPassword:
|
||||||
auth = r.SSHKey.LoginPassword.Login + ":" + r.SSHKey.LoginPassword.Password
|
auth = r.SSHKey.LoginPassword.Login + ":" + r.SSHKey.LoginPassword.Password
|
||||||
case AccessKeyPAT:
|
|
||||||
auth = r.SSHKey.PAT
|
|
||||||
}
|
}
|
||||||
if auth != "" {
|
if auth != "" {
|
||||||
auth += "@"
|
auth += "@"
|
||||||
|
@ -25,6 +25,7 @@ type Task struct {
|
|||||||
Debug bool `db:"debug" json:"debug"`
|
Debug bool `db:"debug" json:"debug"`
|
||||||
|
|
||||||
DryRun bool `db:"dry_run" json:"dry_run"`
|
DryRun bool `db:"dry_run" json:"dry_run"`
|
||||||
|
Diff bool `db:"diff" json:"diff"`
|
||||||
|
|
||||||
// override variables
|
// override variables
|
||||||
Playbook string `db:"playbook" json:"playbook"`
|
Playbook string `db:"playbook" json:"playbook"`
|
||||||
|
@ -442,7 +442,7 @@ func (d *BoltDb) createObject(bucketID int, props db.ObjectProps, object interfa
|
|||||||
reflect.Uint16,
|
reflect.Uint16,
|
||||||
reflect.Uint32,
|
reflect.Uint32,
|
||||||
reflect.Uint64:
|
reflect.Uint64:
|
||||||
//if idValue.Int() == 0 {
|
if idValue.Int() == 0 {
|
||||||
id, err3 := b.NextSequence()
|
id, err3 := b.NextSequence()
|
||||||
if err3 != nil {
|
if err3 != nil {
|
||||||
return err3
|
return err3
|
||||||
@ -451,7 +451,7 @@ func (d *BoltDb) createObject(bucketID int, props db.ObjectProps, object interfa
|
|||||||
id = MaxID - id
|
id = MaxID - id
|
||||||
}
|
}
|
||||||
idValue.SetInt(int64(id))
|
idValue.SetInt(int64(id))
|
||||||
//}
|
}
|
||||||
|
|
||||||
objID = intObjectID(idValue.Int())
|
objID = intObjectID(idValue.Int())
|
||||||
case reflect.String:
|
case reflect.String:
|
||||||
|
@ -70,10 +70,9 @@ func (d *BoltDb) getTasks(projectID int, templateID *int, params db.RetrieveQuer
|
|||||||
if task.UserID != nil {
|
if task.UserID != nil {
|
||||||
usr, ok := users[*task.UserID]
|
usr, ok := users[*task.UserID]
|
||||||
if !ok {
|
if !ok {
|
||||||
usr, err = d.GetUser(*task.UserID)
|
// trying to get user , but ignore error, because
|
||||||
if err != nil {
|
// user can be deleted, and it is ok
|
||||||
return
|
usr, _ = d.GetUser(*task.UserID)
|
||||||
}
|
|
||||||
users[*task.UserID] = usr
|
users[*task.UserID] = usr
|
||||||
}
|
}
|
||||||
tasksWithTpl[i].UserName = &usr.Name
|
tasksWithTpl[i].UserName = &usr.Name
|
||||||
|
1
db/sql/migrations/v2.8.58.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE task ADD diff boolean NOT NULL DEFAULT false;
|
@ -17,9 +17,11 @@ RUN adduser -D -u 1002 -g 0 semaphore && \
|
|||||||
mkdir -p /go/src/github.com/ansible-semaphore/semaphore && \
|
mkdir -p /go/src/github.com/ansible-semaphore/semaphore && \
|
||||||
mkdir -p /tmp/semaphore && \
|
mkdir -p /tmp/semaphore && \
|
||||||
mkdir -p /etc/semaphore && \
|
mkdir -p /etc/semaphore && \
|
||||||
|
mkdir -p /var/lib/semaphore && \
|
||||||
chown -R semaphore:0 /go && \
|
chown -R semaphore:0 /go && \
|
||||||
chown -R semaphore:0 /tmp/semaphore && \
|
chown -R semaphore:0 /tmp/semaphore && \
|
||||||
chown -R semaphore:0 /etc/semaphore && \
|
chown -R semaphore:0 /etc/semaphore && \
|
||||||
|
chown -R semaphore:0 /var/lib/semaphore && \
|
||||||
ssh-keygen -t rsa -q -f "/root/.ssh/id_rsa" -N "" && \
|
ssh-keygen -t rsa -q -f "/root/.ssh/id_rsa" -N "" && \
|
||||||
ssh-keyscan -H github.com > /root/.ssh/known_hosts
|
ssh-keyscan -H github.com > /root/.ssh/known_hosts
|
||||||
|
|
||||||
|
@ -1,54 +0,0 @@
|
|||||||
Bootstrap: docker
|
|
||||||
From: golang:1.18.3-alpine3.16
|
|
||||||
Stage: spython-base
|
|
||||||
|
|
||||||
%setup
|
|
||||||
mkdir $SINGULARITY_ROOTFS/bigdata
|
|
||||||
|
|
||||||
%post
|
|
||||||
SEMAPHORE_VERSION="development"
|
|
||||||
SEMAPHORE_ARCH="linux_amd64"
|
|
||||||
SEMAPHORE_CONFIG_PATH="${SEMAPHORE_CONFIG_PATH:-/etc/semaphore}"
|
|
||||||
APP_ROOT="/mnt/"
|
|
||||||
|
|
||||||
# hadolint ignore=DL3013
|
|
||||||
apk add --no-cache sshpass git mysql-client python3 py3-pip py-openssl openssl ca-certificates curl curl-dev openssh-client-default tini nodejs npm bash rsync && \
|
|
||||||
apk --update add --virtual build-dependencies python3-dev libffi-dev openssl-dev build-base &&\
|
|
||||||
rm -rf /var/cache/apk/*
|
|
||||||
|
|
||||||
pip3 install --upgrade pip cffi && \
|
|
||||||
pip3 install ansible &&\
|
|
||||||
apk del build-dependencies
|
|
||||||
|
|
||||||
adduser -D -u 1002 -g 0 semaphore && \
|
|
||||||
mkdir -p $APP_ROOT && \
|
|
||||||
mkdir -p /tmp/semaphore && \
|
|
||||||
mkdir -p /etc/semaphore && \
|
|
||||||
chown -R semaphore:0 /go && \
|
|
||||||
chown -R semaphore:0 /tmp/semaphore && \
|
|
||||||
chown -R semaphore:0 /etc/semaphore && \
|
|
||||||
ssh-keygen -t rsa -q -f "/root/.ssh/id_rsa" -N "" && \
|
|
||||||
ssh-keyscan -H github.com > /root/.ssh/known_hosts
|
|
||||||
|
|
||||||
cd $(go env GOPATH) && curl -sL https://taskfile.dev/install.sh | sh
|
|
||||||
|
|
||||||
# Copy in app source
|
|
||||||
cd ${APP_ROOT}
|
|
||||||
./deployment/docker/ci/bin/install
|
|
||||||
|
|
||||||
su - semaphore # USER semaphore
|
|
||||||
# EXPOSE 3000
|
|
||||||
|
|
||||||
%environment
|
|
||||||
export SEMAPHORE_VERSION="development"
|
|
||||||
export SEMAPHORE_ARCH="linux_amd64"
|
|
||||||
export SEMAPHORE_CONFIG_PATH="${SEMAPHORE_CONFIG_PATH:-/etc/semaphore}"
|
|
||||||
export APP_ROOT="/mnt/"
|
|
||||||
|
|
||||||
%runscript
|
|
||||||
cd ${APP_ROOT}
|
|
||||||
exec /usr/local/bin/semaphore-wrapper ./bin/semaphore server --config /etc/semaphore/config.json "$@"
|
|
||||||
|
|
||||||
%startscript
|
|
||||||
cd ${APP_ROOT}
|
|
||||||
exec /usr/local/bin/semaphore-wrapper ./bin/semaphore server --config /etc/semaphore/config.json "$@"
|
|
@ -1,29 +0,0 @@
|
|||||||
#!/bin/bash -l
|
|
||||||
|
|
||||||
# Set env
|
|
||||||
SUSER=$USER
|
|
||||||
SCRIPT_HOME=$(realpath $(dirname $0))
|
|
||||||
SEMAPHORE_HOME=$(realpath $SCRIPT_HOME/../../../../)
|
|
||||||
echo "Building in $SEMAPHORE_HOME"
|
|
||||||
|
|
||||||
if [[ ! -f $SCRIPT_HOME/../semaphore.simg ]]; then
|
|
||||||
# Build Image
|
|
||||||
sudo bash -lc "
|
|
||||||
# Set env
|
|
||||||
module purge
|
|
||||||
module load singularity || echo 'Not using modules'
|
|
||||||
export SINGULARITY_BIND=${SEMAPHORE_HOME}:/mnt
|
|
||||||
|
|
||||||
# Build image
|
|
||||||
cd $SCRIPT_HOME/../ && singularity build semaphore.simg Singularity
|
|
||||||
|
|
||||||
# Update perms
|
|
||||||
chmod -R ${SUSER}: $SEMAPHORE_HOME"
|
|
||||||
else
|
|
||||||
# Build RPM
|
|
||||||
module load singularity || echo 'Not using modules'
|
|
||||||
cd ${SEMAPHORE_HOME} && singularity exec $SCRIPT_HOME/../semaphore.simg task release
|
|
||||||
chmod a+rx ${SEMAPHORE_HOME}/bin
|
|
||||||
chmod a+r ${SEMAPHORE_HOME}/bin/*
|
|
||||||
fi
|
|
||||||
|
|
@ -11,4 +11,4 @@ echo "--> Install Semaphore entrypoint wrapper script"
|
|||||||
cp ./deployment/docker/common/semaphore-wrapper /usr/local/bin/semaphore-wrapper
|
cp ./deployment/docker/common/semaphore-wrapper /usr/local/bin/semaphore-wrapper
|
||||||
task deps
|
task deps
|
||||||
task compile
|
task compile
|
||||||
task build:local
|
task build:local GOOS= GOARCH=
|
||||||
|
@ -26,7 +26,6 @@ services:
|
|||||||
SEMAPHORE_DB_HOST: mysql
|
SEMAPHORE_DB_HOST: mysql
|
||||||
SEMAPHORE_DB_PORT: 3306
|
SEMAPHORE_DB_PORT: 3306
|
||||||
SEMAPHORE_DB: semaphore
|
SEMAPHORE_DB: semaphore
|
||||||
SEMAPHORE_PLAYBOOK_PATH: /etc/semaphore
|
|
||||||
SEMAPHORE_ADMIN_PASSWORD: password
|
SEMAPHORE_ADMIN_PASSWORD: password
|
||||||
SEMAPHORE_ADMIN_NAME: "Developer"
|
SEMAPHORE_ADMIN_NAME: "Developer"
|
||||||
SEMAPHORE_ADMIN_EMAIL: admin@localhost
|
SEMAPHORE_ADMIN_EMAIL: admin@localhost
|
||||||
|
8
deployment/docker/common/README.md
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# How to test semaphore-wrapper
|
||||||
|
|
||||||
|
```bash
|
||||||
|
SEMAPHORE_DB_DIALECT=bolt \
|
||||||
|
SEMAPHORE_CONFIG_PATH=/tmp/semaphore
|
||||||
|
SEMAPHORE_DB_HOST=/tmp/semaphore \
|
||||||
|
./semaphore-wrapper ../../../bin/semaphore server --config /tmp/semaphore/config.json
|
||||||
|
```
|
@ -4,31 +4,51 @@ set -e
|
|||||||
|
|
||||||
echoerr() { printf "%s\n" "$*" >&2; }
|
echoerr() { printf "%s\n" "$*" >&2; }
|
||||||
|
|
||||||
|
file_env() {
|
||||||
|
local var=""
|
||||||
|
local fileVar=""
|
||||||
|
eval var="\$${1}"
|
||||||
|
eval fileVar="\$${1}_FILE"
|
||||||
|
local def="${2:-}"
|
||||||
|
if [ -n "${var:-}" ] && [ -n "${fileVar:-}" ]; then
|
||||||
|
echo >&2 "error: both ${1} and ${1}_FILE are set (but are exclusive)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
local val="$def"
|
||||||
|
if [ -n "${var:-}" ]; then
|
||||||
|
val="${var}"
|
||||||
|
elif [ -n "${fileVar:-}" ]; then
|
||||||
|
val="$(cat "${fileVar}")"
|
||||||
|
fi
|
||||||
|
export "${1}"="$val"
|
||||||
|
unset "${1}_FILE"
|
||||||
|
}
|
||||||
|
|
||||||
SEMAPHORE_CONFIG_PATH="${SEMAPHORE_CONFIG_PATH:-/etc/semaphore}"
|
SEMAPHORE_CONFIG_PATH="${SEMAPHORE_CONFIG_PATH:-/etc/semaphore}"
|
||||||
SEMAPHORE_TMP_PATH="${SEMAPHORE_TMP_PATH:-/tmp/semaphore}"
|
SEMAPHORE_TMP_PATH="${SEMAPHORE_TMP_PATH:-/tmp/semaphore}"
|
||||||
|
|
||||||
# Semaphore database env config
|
# Semaphore database env config
|
||||||
SEMAPHORE_DB_DIALECT="${SEMAPHORE_DB_DIALECT:-mysql}"
|
SEMAPHORE_DB_DIALECT="${SEMAPHORE_DB_DIALECT:-mysql}"
|
||||||
SEMAPHORE_DB_DIALECT_ID=1
|
|
||||||
SEMAPHORE_DB_HOST="${SEMAPHORE_DB_HOST:-0.0.0.0}"
|
SEMAPHORE_DB_HOST="${SEMAPHORE_DB_HOST:-0.0.0.0}"
|
||||||
SEMAPHORE_DB_PORT="${SEMAPHORE_DB_PORT:-3306}"
|
SEMAPHORE_DB_PATH="${SEMAPHORE_DB_PATH:-/var/lib/semaphore}"
|
||||||
|
SEMAPHORE_DB_PORT="${SEMAPHORE_DB_PORT:-}"
|
||||||
SEMAPHORE_DB="${SEMAPHORE_DB:-semaphore}"
|
SEMAPHORE_DB="${SEMAPHORE_DB:-semaphore}"
|
||||||
SEMAPHORE_DB_USER="${SEMAPHORE_DB_USER:-semaphore}"
|
file_env 'SEMAPHORE_DB_USER' 'semaphore'
|
||||||
SEMAPHORE_DB_PASS="${SEMAPHORE_DB_PASS:-semaphore}"
|
file_env 'SEMAPHORE_DB_PASS' 'semaphore'
|
||||||
# Email alert env config
|
# Email alert env config
|
||||||
SEMAPHORE_WEB_ROOT="${SEMAPHORE_WEB_ROOT:-}"
|
SEMAPHORE_WEB_ROOT="${SEMAPHORE_WEB_ROOT:-}"
|
||||||
# Semaphore Admin env config
|
# Semaphore Admin env config
|
||||||
SEMAPHORE_ADMIN="${SEMAPHORE_ADMIN:-admin}"
|
file_env 'SEMAPHORE_ADMIN' 'admin'
|
||||||
SEMAPHORE_ADMIN_EMAIL="${SEMAPHORE_ADMIN_EMAIL:-admin@localhost}"
|
SEMAPHORE_ADMIN_EMAIL="${SEMAPHORE_ADMIN_EMAIL:-admin@localhost}"
|
||||||
SEMAPHORE_ADMIN_NAME="${SEMAPHORE_ADMIN_NAME:-Semaphore Admin}"
|
SEMAPHORE_ADMIN_NAME="${SEMAPHORE_ADMIN_NAME:-Semaphore Admin}"
|
||||||
SEMAPHORE_ADMIN_PASSWORD="${SEMAPHORE_ADMIN_PASSWORD:-semaphorepassword}"
|
file_env 'SEMAPHORE_ADMIN_PASSWORD' 'semaphorepassword'
|
||||||
#Semaphore LDAP env config
|
#Semaphore LDAP env config
|
||||||
SEMAPHORE_LDAP_ACTIVATED="${SEMAPHORE_LDAP_ACTIVATED:-no}"
|
SEMAPHORE_LDAP_ACTIVATED="${SEMAPHORE_LDAP_ACTIVATED:-no}"
|
||||||
SEMAPHORE_LDAP_HOST="${SEMAPHORE_LDAP_HOST:-}"
|
SEMAPHORE_LDAP_HOST="${SEMAPHORE_LDAP_HOST:-}"
|
||||||
SEMAPHORE_LDAP_PORT="${SEMAPHORE_LDAP_PORT:-}"
|
SEMAPHORE_LDAP_PORT="${SEMAPHORE_LDAP_PORT:-}"
|
||||||
SEMAPHORE_LDAP_NEEDTLS="${SEMAPHORE_LDAP_NEEDTLS:-no}"
|
SEMAPHORE_LDAP_NEEDTLS="${SEMAPHORE_LDAP_NEEDTLS:-no}"
|
||||||
SEMAPHORE_LDAP_DN_BIND="${SEMAPHORE_LDAP_DN_BIND:-}"
|
SEMAPHORE_LDAP_DN_BIND="${SEMAPHORE_LDAP_DN_BIND:-}"
|
||||||
SEMAPHORE_LDAP_PASSWORD="${SEMAPHORE_LDAP_PASSWORD:-}"
|
file_env 'SEMAPHORE_LDAP_PASSWORD'
|
||||||
SEMAPHORE_LDAP_DN_SEARCH="${SEMAPHORE_LDAP_DN_SEARCH:-}"
|
SEMAPHORE_LDAP_DN_SEARCH="${SEMAPHORE_LDAP_DN_SEARCH:-}"
|
||||||
SEMAPHORE_LDAP_SEARCH_FILTER="${SEMAPHORE_LDAP_SEARCH_FILTER:-(uid=%s)}"
|
SEMAPHORE_LDAP_SEARCH_FILTER="${SEMAPHORE_LDAP_SEARCH_FILTER:-(uid=%s)}"
|
||||||
SEMAPHORE_LDAP_MAPPING_DN="${SEMAPHORE_LDAP_MAPPING_DN:-dn}"
|
SEMAPHORE_LDAP_MAPPING_DN="${SEMAPHORE_LDAP_MAPPING_DN:-dn}"
|
||||||
@ -36,23 +56,33 @@ SEMAPHORE_LDAP_MAPPING_USERNAME="${SEMAPHORE_LDAP_MAPPING_USERNAME:-uid}"
|
|||||||
SEMAPHORE_LDAP_MAPPING_FULLNAME="${SEMAPHORE_LDAP_MAPPING_FULLNAME:-cn}"
|
SEMAPHORE_LDAP_MAPPING_FULLNAME="${SEMAPHORE_LDAP_MAPPING_FULLNAME:-cn}"
|
||||||
SEMAPHORE_LDAP_MAPPING_EMAIL="${SEMAPHORE_LDAP_MAPPING_EMAIL:-mail}"
|
SEMAPHORE_LDAP_MAPPING_EMAIL="${SEMAPHORE_LDAP_MAPPING_EMAIL:-mail}"
|
||||||
|
|
||||||
export SEMAPHORE_ACCESS_KEY_ENCRYPTION="${SEMAPHORE_ACCESS_KEY_ENCRYPTION:-cFcXI5qHzCDqtS4xCnblOACuNu5AmKHkvxK7abwR8Eg=}"
|
file_env 'SEMAPHORE_ACCESS_KEY_ENCRYPTION' 'cFcXI5qHzCDqtS4xCnblOACuNu5AmKHkvxK7abwR8Eg='
|
||||||
|
|
||||||
# create semaphore temporary directory if non existent
|
|
||||||
[ -d "${SEMAPHORE_TMP_PATH}" ] || mkdir -p "${SEMAPHORE_TMP_PATH}" || {
|
[ -d "${SEMAPHORE_TMP_PATH}" ] || mkdir -p "${SEMAPHORE_TMP_PATH}" || {
|
||||||
echo "Can't create Semaphore tmp path ${SEMAPHORE_TMP_PATH}."
|
echo "Can't create Semaphore tmp path ${SEMAPHORE_TMP_PATH}."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
# create semaphore config directory if non existent
|
|
||||||
[ -d "${SEMAPHORE_CONFIG_PATH}" ] || mkdir -p "${SEMAPHORE_CONFIG_PATH}" || {
|
[ -d "${SEMAPHORE_CONFIG_PATH}" ] || mkdir -p "${SEMAPHORE_CONFIG_PATH}" || {
|
||||||
echo "Can't create Semaphore Config path ${SEMAPHORE_CONFIG_PATH}."
|
echo "Can't create Semaphore Config path ${SEMAPHORE_CONFIG_PATH}."
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ -d "${SEMAPHORE_DB_PATH}" ] || mkdir -p "${SEMAPHORE_DB_PATH}" || {
|
||||||
|
echo "Can't create data path ${SEMAPHORE_DB_PATH}."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if [ -n "${SEMAPHORE_DB_PORT}" ]; then
|
||||||
|
SEMAPHORE_DB_HOST="${SEMAPHORE_DB_HOST}:${SEMAPHORE_DB_PORT}"
|
||||||
|
fi
|
||||||
|
|
||||||
# wait on db to be up
|
# wait on db to be up
|
||||||
echoerr "Attempting to connect to database ${SEMAPHORE_DB} on ${SEMAPHORE_DB_HOST}:${SEMAPHORE_DB_PORT} with user ${SEMAPHORE_DB_USER} ..."
|
|
||||||
TIMEOUT=30
|
if [ "${SEMAPHORE_DB_DIALECT}" != 'bolt' ]; then
|
||||||
while ! $(nc -z "$SEMAPHORE_DB_HOST" "$SEMAPHORE_DB_PORT") >/dev/null 2>&1; do
|
echoerr "Attempting to connect to database ${SEMAPHORE_DB} on ${SEMAPHORE_DB_HOST}:${SEMAPHORE_DB_PORT} with user ${SEMAPHORE_DB_USER} ..."
|
||||||
|
TIMEOUT=30
|
||||||
|
while ! $(nc -z "$SEMAPHORE_DB_HOST" "$SEMAPHORE_DB_PORT") >/dev/null 2>&1; do
|
||||||
TIMEOUT=$(expr $TIMEOUT - 1)
|
TIMEOUT=$(expr $TIMEOUT - 1)
|
||||||
if [ $TIMEOUT -eq 0 ]; then
|
if [ $TIMEOUT -eq 0 ]; then
|
||||||
echoerr "Could not connect to database server. Exiting."
|
echoerr "Could not connect to database server. Exiting."
|
||||||
@ -60,12 +90,17 @@ while ! $(nc -z "$SEMAPHORE_DB_HOST" "$SEMAPHORE_DB_PORT") >/dev/null 2>&1; do
|
|||||||
fi
|
fi
|
||||||
echo -n "."
|
echo -n "."
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
case ${SEMAPHORE_DB_DIALECT} in
|
case ${SEMAPHORE_DB_DIALECT} in
|
||||||
"mysql") SEMAPHORE_DB_DIALECT_ID=1;;
|
mysql) SEMAPHORE_DB_DIALECT_ID=1;;
|
||||||
"bolt") SEMAPHORE_DB_DIALECT_ID=2;;
|
bolt) SEMAPHORE_DB_DIALECT_ID=2;;
|
||||||
"postgres") SEMAPHORE_DB_DIALECT_ID=3;;
|
postgres) SEMAPHORE_DB_DIALECT_ID=3;;
|
||||||
|
*)
|
||||||
|
echoerr "Unknown database dialect: ${SEMAPHORE_DB_DIALECT}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Create a config if it does not exist in the current config path
|
# Create a config if it does not exist in the current config path
|
||||||
@ -73,10 +108,22 @@ if [ ! -f "${SEMAPHORE_CONFIG_PATH}/config.json" ]; then
|
|||||||
echoerr "Generating ${SEMAPHORE_TMP_PATH}/config.stdin ..."
|
echoerr "Generating ${SEMAPHORE_TMP_PATH}/config.stdin ..."
|
||||||
cat << EOF > "${SEMAPHORE_TMP_PATH}/config.stdin"
|
cat << EOF > "${SEMAPHORE_TMP_PATH}/config.stdin"
|
||||||
${SEMAPHORE_DB_DIALECT_ID}
|
${SEMAPHORE_DB_DIALECT_ID}
|
||||||
${SEMAPHORE_DB_HOST}:${SEMAPHORE_DB_PORT}
|
EOF
|
||||||
|
|
||||||
|
if [ "${SEMAPHORE_DB_DIALECT}" = "bolt" ]; then
|
||||||
|
cat << EOF >> "${SEMAPHORE_TMP_PATH}/config.stdin"
|
||||||
|
${SEMAPHORE_DB_PATH}/database.boltdb
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
cat << EOF >> "${SEMAPHORE_TMP_PATH}/config.stdin"
|
||||||
|
${SEMAPHORE_DB_HOST}
|
||||||
${SEMAPHORE_DB_USER}
|
${SEMAPHORE_DB_USER}
|
||||||
${SEMAPHORE_DB_PASS}
|
${SEMAPHORE_DB_PASS}
|
||||||
${SEMAPHORE_DB}
|
${SEMAPHORE_DB}
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat << EOF >> "${SEMAPHORE_TMP_PATH}/config.stdin"
|
||||||
${SEMAPHORE_TMP_PATH}
|
${SEMAPHORE_TMP_PATH}
|
||||||
${SEMAPHORE_WEB_ROOT}
|
${SEMAPHORE_WEB_ROOT}
|
||||||
no
|
no
|
||||||
@ -101,7 +148,6 @@ EOF
|
|||||||
fi;
|
fi;
|
||||||
|
|
||||||
cat << EOF >> "${SEMAPHORE_TMP_PATH}/config.stdin"
|
cat << EOF >> "${SEMAPHORE_TMP_PATH}/config.stdin"
|
||||||
yes
|
|
||||||
${SEMAPHORE_CONFIG_PATH}
|
${SEMAPHORE_CONFIG_PATH}
|
||||||
${SEMAPHORE_ADMIN}
|
${SEMAPHORE_ADMIN}
|
||||||
${SEMAPHORE_ADMIN_EMAIL}
|
${SEMAPHORE_ADMIN_EMAIL}
|
||||||
|
@ -17,9 +17,11 @@ RUN adduser -D -u 1002 -g 0 semaphore && \
|
|||||||
mkdir -p /go/src/github.com/ansible-semaphore/semaphore && \
|
mkdir -p /go/src/github.com/ansible-semaphore/semaphore && \
|
||||||
mkdir -p /tmp/semaphore && \
|
mkdir -p /tmp/semaphore && \
|
||||||
mkdir -p /etc/semaphore && \
|
mkdir -p /etc/semaphore && \
|
||||||
|
mkdir -p /var/lib/semaphore && \
|
||||||
chown -R semaphore:0 /go && \
|
chown -R semaphore:0 /go && \
|
||||||
chown -R semaphore:0 /tmp/semaphore && \
|
chown -R semaphore:0 /tmp/semaphore && \
|
||||||
chown -R semaphore:0 /etc/semaphore && \
|
chown -R semaphore:0 /etc/semaphore && \
|
||||||
|
chown -R semaphore:0 /var/lib/semaphore && \
|
||||||
ssh-keygen -t rsa -q -f "/root/.ssh/id_rsa" -N "" && \
|
ssh-keygen -t rsa -q -f "/root/.ssh/id_rsa" -N "" && \
|
||||||
ssh-keyscan -H github.com > /root/.ssh/known_hosts
|
ssh-keyscan -H github.com > /root/.ssh/known_hosts
|
||||||
|
|
||||||
|
@ -28,7 +28,6 @@ services:
|
|||||||
SEMAPHORE_DB_HOST: mysql
|
SEMAPHORE_DB_HOST: mysql
|
||||||
SEMAPHORE_DB_PORT: 3306
|
SEMAPHORE_DB_PORT: 3306
|
||||||
SEMAPHORE_DB: semaphore
|
SEMAPHORE_DB: semaphore
|
||||||
SEMAPHORE_PLAYBOOK_PATH: /etc/semaphore
|
|
||||||
SEMAPHORE_ADMIN_PASSWORD: password
|
SEMAPHORE_ADMIN_PASSWORD: password
|
||||||
SEMAPHORE_ADMIN_NAME: "Developer"
|
SEMAPHORE_ADMIN_NAME: "Developer"
|
||||||
SEMAPHORE_ADMIN_EMAIL: admin@localhost
|
SEMAPHORE_ADMIN_EMAIL: admin@localhost
|
||||||
|
@ -1,24 +1,23 @@
|
|||||||
# ansible-semaphore production image
|
# ansible-semaphore production image
|
||||||
FROM golang:1.18.3-alpine3.16 as builder
|
FROM golang:1.18.3-alpine3.16 as builder
|
||||||
|
|
||||||
|
|
||||||
COPY ./ /go/src/github.com/ansible-semaphore/semaphore
|
COPY ./ /go/src/github.com/ansible-semaphore/semaphore
|
||||||
WORKDIR /go/src/github.com/ansible-semaphore/semaphore
|
WORKDIR /go/src/github.com/ansible-semaphore/semaphore
|
||||||
|
|
||||||
RUN apk add --no-cache -U libc-dev curl nodejs npm git && \
|
RUN apk add --no-cache -U libc-dev curl nodejs npm git && \
|
||||||
./deployment/docker/prod/bin/install
|
./deployment/docker/prod/bin/install
|
||||||
|
|
||||||
# Uses frolvlad alpine so we have access to glibc which is needed for golang
|
FROM alpine:3.16 as runner
|
||||||
# and when deploying in openshift
|
|
||||||
FROM frolvlad/alpine-glibc:alpine-3.16 as runner
|
|
||||||
LABEL maintainer="Tom Whiston <tom.whiston@gmail.com>"
|
LABEL maintainer="Tom Whiston <tom.whiston@gmail.com>"
|
||||||
|
|
||||||
RUN apk add --no-cache sshpass git curl ansible mysql-client openssh-client-default tini py3-aiohttp && \
|
RUN apk add --no-cache sshpass git curl ansible mysql-client openssh-client-default tini py3-aiohttp && \
|
||||||
adduser -D -u 1001 -G root semaphore && \
|
adduser -D -u 1001 -G root semaphore && \
|
||||||
mkdir -p /tmp/semaphore && \
|
mkdir -p /tmp/semaphore && \
|
||||||
mkdir -p /etc/semaphore && \
|
mkdir -p /etc/semaphore && \
|
||||||
|
mkdir -p /var/lib/semaphore && \
|
||||||
chown -R semaphore:0 /tmp/semaphore && \
|
chown -R semaphore:0 /tmp/semaphore && \
|
||||||
chown -R semaphore:0 /etc/semaphore
|
chown -R semaphore:0 /etc/semaphore && \
|
||||||
|
chown -R semaphore:0 /var/lib/semaphore
|
||||||
|
|
||||||
COPY --from=builder /usr/local/bin/semaphore-wrapper /usr/local/bin/
|
COPY --from=builder /usr/local/bin/semaphore-wrapper /usr/local/bin/
|
||||||
COPY --from=builder /usr/local/bin/semaphore /usr/local/bin/
|
COPY --from=builder /usr/local/bin/semaphore /usr/local/bin/
|
||||||
|
@ -10,7 +10,8 @@ task deps
|
|||||||
set +e
|
set +e
|
||||||
task compile
|
task compile
|
||||||
set -e
|
set -e
|
||||||
task build:local
|
|
||||||
|
task build:local GOOS=$1 GOARCH=$2
|
||||||
|
|
||||||
mv ./bin/semaphore /usr/local/bin/
|
mv ./bin/semaphore /usr/local/bin/
|
||||||
chown 1001:0 /usr/local/bin/semaphore
|
chown 1001:0 /usr/local/bin/semaphore
|
||||||
|
37
deployment/docker/prod/buildx.Dockerfile
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
# ansible-semaphore production image
|
||||||
|
FROM --platform=$BUILDPLATFORM golang:1.18.3-alpine3.16 as builder
|
||||||
|
|
||||||
|
COPY ./ /go/src/github.com/ansible-semaphore/semaphore
|
||||||
|
WORKDIR /go/src/github.com/ansible-semaphore/semaphore
|
||||||
|
|
||||||
|
ARG TARGETOS
|
||||||
|
ARG TARGETARCH
|
||||||
|
|
||||||
|
RUN apk add --no-cache -U libc-dev curl nodejs npm git
|
||||||
|
RUN ./deployment/docker/prod/bin/install ${TARGETOS} ${TARGETARCH}
|
||||||
|
|
||||||
|
FROM alpine:3.16 as runner
|
||||||
|
LABEL maintainer="Tom Whiston <tom.whiston@gmail.com>"
|
||||||
|
|
||||||
|
RUN apk add --no-cache sshpass git curl ansible mysql-client openssh-client-default tini py3-aiohttp && \
|
||||||
|
adduser -D -u 1001 -G root semaphore && \
|
||||||
|
mkdir -p /tmp/semaphore && \
|
||||||
|
mkdir -p /etc/semaphore && \
|
||||||
|
mkdir -p /var/lib/semaphore && \
|
||||||
|
chown -R semaphore:0 /tmp/semaphore && \
|
||||||
|
chown -R semaphore:0 /etc/semaphore && \
|
||||||
|
chown -R semaphore:0 /var/lib/semaphore
|
||||||
|
|
||||||
|
COPY --from=builder /usr/local/bin/semaphore-wrapper /usr/local/bin/
|
||||||
|
COPY --from=builder /usr/local/bin/semaphore /usr/local/bin/
|
||||||
|
|
||||||
|
RUN chown -R semaphore:0 /usr/local/bin/semaphore-wrapper &&\
|
||||||
|
chown -R semaphore:0 /usr/local/bin/semaphore &&\
|
||||||
|
chmod +x /usr/local/bin/semaphore-wrapper &&\
|
||||||
|
chmod +x /usr/local/bin/semaphore
|
||||||
|
|
||||||
|
WORKDIR /home/semaphore
|
||||||
|
USER 1001
|
||||||
|
|
||||||
|
ENTRYPOINT ["/sbin/tini", "--"]
|
||||||
|
CMD ["/usr/local/bin/semaphore-wrapper", "/usr/local/bin/semaphore", "server", "--config", "/etc/semaphore/config.json"]
|
@ -24,7 +24,6 @@ services:
|
|||||||
SEMAPHORE_DB_HOST: mysql
|
SEMAPHORE_DB_HOST: mysql
|
||||||
SEMAPHORE_DB_PORT: 3306
|
SEMAPHORE_DB_PORT: 3306
|
||||||
SEMAPHORE_DB: semaphore
|
SEMAPHORE_DB: semaphore
|
||||||
SEMAPHORE_PLAYBOOK_PATH: /tmp/semaphore/
|
|
||||||
SEMAPHORE_ADMIN_PASSWORD: cangetin
|
SEMAPHORE_ADMIN_PASSWORD: cangetin
|
||||||
SEMAPHORE_ADMIN_NAME: admin
|
SEMAPHORE_ADMIN_NAME: admin
|
||||||
SEMAPHORE_ADMIN_EMAIL: admin@localhost
|
SEMAPHORE_ADMIN_EMAIL: admin@localhost
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
# Deploying Semaphore on Openshift
|
|
||||||
|
|
||||||
This is intended as a quick starter config to get semaphore up and running using only the docker hub image.The image is set to be periodically pulled from the repository source.
|
|
||||||
|
|
||||||
## Setup
|
|
||||||
|
|
||||||
Your openshift cluster needs to have the mysql-persistent template installed, however it comes by default.
|
|
||||||
```
|
|
||||||
# oc cluster up
|
|
||||||
oc new-project semaphore
|
|
||||||
oc create -fdeployment/openshift/template.yml
|
|
||||||
oc new-app mysql-persistent -p MYSQL_DATABASE=semaphore
|
|
||||||
oc new-app semaphore # -p SEMAPHORE_IMAGE_TAG=develop
|
|
||||||
```
|
|
||||||
|
|
||||||
It will take some moments for the application to become available (mainly due to the mysql pod startup time), check the logs of the semaphore container to see when it is ready. After this the web ui will be available on http://semaphore-semaphore.127.0.0.1.nip.io/auth/login (if running your oc cluster locally and you did not override the url via parameters). You can log in with the default values.
|
|
||||||
If you deploy the template to multiple namespaces you must set the SEMAPHORE_URL to a unique value or it will be rejected by the router.
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
`oc process --parameters semaphore`
|
|
||||||
|
|
||||||
|NAME| DESCRIPTION| VALUE|
|
|
||||||
|SEMAPHORE_IMAGE_SOURCE| The id of the repository from which to pull the semaphore image| docker.io/semaphoreui/semaphore|
|
|
||||||
|SEMAPHORE_IMAGE_TAG| The tag to use for the semaphore repository| latest|
|
|
||||||
|SEMAPHORE_DATA_VOLUME_SIZE| The size, in Gi of the semaphore data volume, which is mounted at /etc/semaphore| 5|
|
|
||||||
|SEMAPHORE_URL| Set this to the value which you wish to be passed to the route. Default value works for local development usage| semaphore-semaphore.127.0.0.1.nip.io|
|
|
@ -1,166 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: Template
|
|
||||||
metadata:
|
|
||||||
name: semaphore
|
|
||||||
objects:
|
|
||||||
- apiVersion: v1
|
|
||||||
kind: ImageStream
|
|
||||||
metadata:
|
|
||||||
name: semaphore
|
|
||||||
labels:
|
|
||||||
app: semaphore
|
|
||||||
spec:
|
|
||||||
tags:
|
|
||||||
- name: latest
|
|
||||||
from:
|
|
||||||
kind: DockerImage
|
|
||||||
name: "${SEMAPHORE_IMAGE_SOURCE}:${SEMAPHORE_IMAGE_TAG}"
|
|
||||||
importPolicy:
|
|
||||||
scheduled: true
|
|
||||||
- apiVersion: v1
|
|
||||||
kind: PersistentVolumeClaim
|
|
||||||
metadata:
|
|
||||||
name: semaphore-data
|
|
||||||
spec:
|
|
||||||
accessModes:
|
|
||||||
- ReadWriteOnce
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
storage: "${SEMAPHORE_DATA_VOLUME_SIZE}Gi"
|
|
||||||
status: {}
|
|
||||||
- apiVersion: v1
|
|
||||||
kind: DeploymentConfig
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: semaphore
|
|
||||||
name: semaphore
|
|
||||||
spec:
|
|
||||||
replicas: 1
|
|
||||||
selector:
|
|
||||||
app: semaphore
|
|
||||||
deploymentconfig: semaphore
|
|
||||||
strategy:
|
|
||||||
activeDeadlineSeconds: 21600
|
|
||||||
resources: {}
|
|
||||||
rollingParams:
|
|
||||||
intervalSeconds: 1
|
|
||||||
maxSurge: 25%
|
|
||||||
maxUnavailable: 25%
|
|
||||||
timeoutSeconds: 600
|
|
||||||
updatePeriodSeconds: 1
|
|
||||||
type: Rolling
|
|
||||||
template:
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: semaphore
|
|
||||||
deploymentconfig: semaphore
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- env:
|
|
||||||
- name: SEMAPHORE_DB_HOST
|
|
||||||
value: mysql
|
|
||||||
- name: SEMAPHORE_DB
|
|
||||||
value: semaphore
|
|
||||||
- name: SEMAPHORE_DB_PASS
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
key: database-password
|
|
||||||
name: mysql
|
|
||||||
- name: SEMAPHORE_DB_USER
|
|
||||||
valueFrom:
|
|
||||||
secretKeyRef:
|
|
||||||
key: database-user
|
|
||||||
name: mysql
|
|
||||||
- name: SEMAPHORE_PLAYBOOK_PATH
|
|
||||||
value: /tmp/semaphore
|
|
||||||
imagePullPolicy: Always
|
|
||||||
name: semaphore
|
|
||||||
ports:
|
|
||||||
- containerPort: 3000
|
|
||||||
protocol: TCP
|
|
||||||
resources: {}
|
|
||||||
terminationMessagePath: /dev/termination-log
|
|
||||||
terminationMessagePolicy: File
|
|
||||||
volumeMounts:
|
|
||||||
- mountPath: /etc/semaphore
|
|
||||||
name: semaphore-etc
|
|
||||||
subPath: etc
|
|
||||||
- mountPath: /tmp
|
|
||||||
name: tmp
|
|
||||||
dnsPolicy: ClusterFirst
|
|
||||||
restartPolicy: Always
|
|
||||||
schedulerName: default-scheduler
|
|
||||||
securityContext: {}
|
|
||||||
terminationGracePeriodSeconds: 30
|
|
||||||
volumes:
|
|
||||||
- name: semaphore-etc
|
|
||||||
persistentVolumeClaim:
|
|
||||||
claimName: semaphore-data
|
|
||||||
- name: tmp
|
|
||||||
emptyDir:
|
|
||||||
test: false
|
|
||||||
triggers:
|
|
||||||
- type: ConfigChange
|
|
||||||
- imageChangeParams:
|
|
||||||
automatic: true
|
|
||||||
containerNames:
|
|
||||||
- semaphore
|
|
||||||
from:
|
|
||||||
kind: ImageStreamTag
|
|
||||||
name: semaphore:latest
|
|
||||||
type: ImageChange
|
|
||||||
- apiVersion: v1
|
|
||||||
kind: Route
|
|
||||||
metadata:
|
|
||||||
name: semaphore
|
|
||||||
spec:
|
|
||||||
host: "${SEMAPHORE_URL}"
|
|
||||||
port:
|
|
||||||
targetPort: 3000-tcp
|
|
||||||
to:
|
|
||||||
kind: Service
|
|
||||||
name: semaphore
|
|
||||||
weight: 100
|
|
||||||
wildcardPolicy: None
|
|
||||||
- apiVersion: v1
|
|
||||||
kind: Service
|
|
||||||
metadata:
|
|
||||||
labels:
|
|
||||||
app: semaphore
|
|
||||||
name: semaphore
|
|
||||||
spec:
|
|
||||||
ports:
|
|
||||||
- name: 3000-tcp
|
|
||||||
port: 3000
|
|
||||||
protocol: TCP
|
|
||||||
targetPort: 3000
|
|
||||||
selector:
|
|
||||||
app: semaphore
|
|
||||||
deploymentconfig: semaphore
|
|
||||||
sessionAffinity: None
|
|
||||||
type: ClusterIP
|
|
||||||
status:
|
|
||||||
loadBalancer: {}
|
|
||||||
|
|
||||||
|
|
||||||
parameters:
|
|
||||||
- name: SEMAPHORE_IMAGE_SOURCE
|
|
||||||
displayName: Semaphore image
|
|
||||||
description: The id of the repository from which to pull the semaphore image
|
|
||||||
value: docker.io/semaphoreui/semaphore
|
|
||||||
required: true
|
|
||||||
- name: SEMAPHORE_IMAGE_TAG
|
|
||||||
displayName: Semaphore image
|
|
||||||
description: The tag to use for the semaphore repository
|
|
||||||
value: latest
|
|
||||||
required: true
|
|
||||||
- name: SEMAPHORE_DATA_VOLUME_SIZE
|
|
||||||
displayName: Semaphore data volume size
|
|
||||||
description: The size, in Gi of the semaphore data volume, which is mounted at /etc/semaphore
|
|
||||||
value: "5"
|
|
||||||
required: true
|
|
||||||
- name: SEMAPHORE_URL
|
|
||||||
displayName: URL
|
|
||||||
description: Set this to the value which you wish to be passed to the route. If blank will use generated url
|
|
||||||
required: false
|
|
||||||
|
|
2
go.mod
@ -9,7 +9,7 @@ require (
|
|||||||
github.com/go-sql-driver/mysql v1.4.1
|
github.com/go-sql-driver/mysql v1.4.1
|
||||||
github.com/gobuffalo/packr v1.10.4
|
github.com/gobuffalo/packr v1.10.4
|
||||||
github.com/google/go-github v17.0.0+incompatible
|
github.com/google/go-github v17.0.0+incompatible
|
||||||
github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f
|
github.com/gorilla/context v1.1.1
|
||||||
github.com/gorilla/handlers v1.4.2
|
github.com/gorilla/handlers v1.4.2
|
||||||
github.com/gorilla/mux v1.7.3
|
github.com/gorilla/mux v1.7.3
|
||||||
github.com/gorilla/securecookie v1.1.1
|
github.com/gorilla/securecookie v1.1.1
|
||||||
|
2
go.sum
@ -157,6 +157,8 @@ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5m
|
|||||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||||
github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f h1:9oNbS1z4rVpbnkHBdPZU4jo9bSmrLpII768arSyMFgk=
|
github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f h1:9oNbS1z4rVpbnkHBdPZU4jo9bSmrLpII768arSyMFgk=
|
||||||
github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
github.com/gorilla/context v0.0.0-20160226214623-1ea25387ff6f/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||||
|
github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8=
|
||||||
|
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||||
github.com/gorilla/handlers v1.4.2 h1:0QniY0USkHQ1RGCLfKxeNHK9bkDHGRYGNDFBCS+YARg=
|
github.com/gorilla/handlers v1.4.2 h1:0QniY0USkHQ1RGCLfKxeNHK9bkDHGRYGNDFBCS+YARg=
|
||||||
github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
|
github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
|
||||||
github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw=
|
github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw=
|
||||||
|
@ -10,10 +10,11 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const emailTemplate = `Subject: Task '{{ .Name }}' failed
|
const emailTemplate = "Subject: Task '{{ .Name }}' failed\r\n" +
|
||||||
|
"From: {{ .From }}\r\n" +
|
||||||
Task {{ .TaskID }} with template '{{ .Name }}' has failed!
|
"\r\n" +
|
||||||
Task log: <a href='{{ .TaskURL }}'>{{ .TaskURL }}</a>`
|
"Task {{ .TaskID }} with template '{{ .Name }}' has failed!`\n" +
|
||||||
|
"Task Log: {{ .TaskURL }}"
|
||||||
|
|
||||||
const telegramTemplate = `{"chat_id": "{{ .ChatID }}","parse_mode":"HTML","text":"<code>{{ .Name }}</code>\n#{{ .TaskID }} <b>{{ .TaskResult }}</b> <code>{{ .TaskVersion }}</code> {{ .TaskDescription }}\nby {{ .Author }}\n{{ .TaskURL }}"}`
|
const telegramTemplate = `{"chat_id": "{{ .ChatID }}","parse_mode":"HTML","text":"<code>{{ .Name }}</code>\n#{{ .TaskID }} <b>{{ .TaskResult }}</b> <code>{{ .TaskVersion }}</code> {{ .TaskDescription }}\nby {{ .Author }}\n{{ .TaskURL }}"}`
|
||||||
|
|
||||||
@ -30,6 +31,7 @@ type Alert struct {
|
|||||||
TaskVersion string
|
TaskVersion string
|
||||||
Author string
|
Author string
|
||||||
Color string
|
Color string
|
||||||
|
From string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TaskRunner) sendMailAlert() {
|
func (t *TaskRunner) sendMailAlert() {
|
||||||
@ -43,7 +45,10 @@ func (t *TaskRunner) sendMailAlert() {
|
|||||||
alert := Alert{
|
alert := Alert{
|
||||||
TaskID: strconv.Itoa(t.task.ID),
|
TaskID: strconv.Itoa(t.task.ID),
|
||||||
Name: t.template.Name,
|
Name: t.template.Name,
|
||||||
TaskURL: util.Config.WebHost + "/project/" + strconv.Itoa(t.template.ProjectID),
|
TaskURL: util.Config.WebHost + "/project/" + strconv.Itoa(t.template.ProjectID) +
|
||||||
|
"/templates/" + strconv.Itoa(t.template.ID) +
|
||||||
|
"?t=" + strconv.Itoa(t.task.ID),
|
||||||
|
From: util.Config.EmailSender,
|
||||||
}
|
}
|
||||||
tpl := template.New("mail body template")
|
tpl := template.New("mail body template")
|
||||||
tpl, err := tpl.Parse(emailTemplate)
|
tpl, err := tpl.Parse(emailTemplate)
|
||||||
@ -60,11 +65,15 @@ func (t *TaskRunner) sendMailAlert() {
|
|||||||
t.panicOnError(err, "Can't find user Email!")
|
t.panicOnError(err, "Can't find user Email!")
|
||||||
|
|
||||||
t.Log("Sending email to " + userObj.Email + " from " + util.Config.EmailSender)
|
t.Log("Sending email to " + userObj.Email + " from " + util.Config.EmailSender)
|
||||||
|
|
||||||
if util.Config.EmailSecure {
|
if util.Config.EmailSecure {
|
||||||
err = util.SendSecureMail(util.Config.EmailHost, util.Config.EmailPort, util.Config.EmailSender, util.Config.EmailUsername, util.Config.EmailPassword, userObj.Email, mailBuffer)
|
err = util.SendSecureMail(util.Config.EmailHost, util.Config.EmailPort,
|
||||||
|
util.Config.EmailSender, util.Config.EmailUsername, util.Config.EmailPassword,
|
||||||
|
userObj.Email, mailBuffer)
|
||||||
} else {
|
} else {
|
||||||
err = util.SendMail(mailHost, util.Config.EmailSender, userObj.Email, mailBuffer)
|
err = util.SendMail(mailHost, util.Config.EmailSender, userObj.Email, mailBuffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
t.panicOnError(err, "Can't send email!")
|
t.panicOnError(err, "Can't send email!")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,9 +145,9 @@ func (t *TaskRunner) sendTelegramAlert() {
|
|||||||
resp, err := http.Post("https://api.telegram.org/bot"+util.Config.TelegramToken+"/sendMessage", "application/json", &telegramBuffer)
|
resp, err := http.Post("https://api.telegram.org/bot"+util.Config.TelegramToken+"/sendMessage", "application/json", &telegramBuffer)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Log("Can't send telegram alert! Response code not 200!")
|
t.Log("Can't send telegram alert! Error: " + err.Error())
|
||||||
} else if resp.StatusCode != 200 {
|
} else if resp.StatusCode != 200 {
|
||||||
t.Log("Can't send telegram alert! Response code not 200!")
|
t.Log("Can't send telegram alert! Response code: " + strconv.Itoa(resp.StatusCode))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,8 +228,8 @@ func (t *TaskRunner) sendSlackAlert() {
|
|||||||
resp, err := http.Post(slackUrl, "application/json", &slackBuffer)
|
resp, err := http.Post(slackUrl, "application/json", &slackBuffer)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Log("Can't send slack alert! Response code not 200!")
|
t.Log("Can't send slack alert! Error: " + err.Error())
|
||||||
} else if resp.StatusCode != 200 {
|
} else if resp.StatusCode != 200 {
|
||||||
t.Log("Can't send slack alert! Response code not 200!")
|
t.Log("Can't send slack alert! Response code: " + strconv.Itoa(resp.StatusCode))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,16 @@ import (
|
|||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/ansible-semaphore/semaphore/lib"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/ansible-semaphore/semaphore/lib"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
"github.com/ansible-semaphore/semaphore/api/sockets"
|
"github.com/ansible-semaphore/semaphore/api/sockets"
|
||||||
"github.com/ansible-semaphore/semaphore/db"
|
"github.com/ansible-semaphore/semaphore/db"
|
||||||
@ -47,6 +49,12 @@ func getMD5Hash(filepath string) (string, error) {
|
|||||||
return fmt.Sprintf("%x", hash.Sum(nil)), nil
|
return fmt.Sprintf("%x", hash.Sum(nil)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *TaskRunner) getPlaybookDir() string {
|
||||||
|
playbookPath := path.Join(t.getRepoPath(), t.template.Playbook)
|
||||||
|
|
||||||
|
return path.Dir(playbookPath)
|
||||||
|
}
|
||||||
|
|
||||||
func (t *TaskRunner) getRepoPath() string {
|
func (t *TaskRunner) getRepoPath() string {
|
||||||
repo := lib.GitRepository{
|
repo := lib.GitRepository{
|
||||||
Logger: t,
|
Logger: t,
|
||||||
@ -72,14 +80,13 @@ func (t *TaskRunner) setStatus(status db.TaskStatus) {
|
|||||||
|
|
||||||
t.updateStatus()
|
t.updateStatus()
|
||||||
|
|
||||||
t.sendSlackAlert()
|
|
||||||
|
|
||||||
if status == db.TaskFailStatus {
|
if status == db.TaskFailStatus {
|
||||||
t.sendMailAlert()
|
t.sendMailAlert()
|
||||||
}
|
}
|
||||||
|
|
||||||
if status == db.TaskSuccessStatus || status == db.TaskFailStatus {
|
if status == db.TaskSuccessStatus || status == db.TaskFailStatus {
|
||||||
t.sendTelegramAlert()
|
t.sendTelegramAlert()
|
||||||
|
t.sendSlackAlert()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,7 +322,7 @@ func (t *TaskRunner) prepareError(err error, errMsg string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint: gocyclo
|
// nolint: gocyclo
|
||||||
func (t *TaskRunner) populateDetails() error {
|
func (t *TaskRunner) populateDetails() error {
|
||||||
// get template
|
// get template
|
||||||
var err error
|
var err error
|
||||||
@ -480,7 +487,7 @@ func (t *TaskRunner) updateRepository() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *TaskRunner) installCollectionsRequirements() error {
|
func (t *TaskRunner) installCollectionsRequirements() error {
|
||||||
requirementsFilePath := fmt.Sprintf("%s/collections/requirements.yml", t.getRepoPath())
|
requirementsFilePath := path.Join(t.getPlaybookDir(), "collections", "requirements.yml")
|
||||||
requirementsHashFilePath := fmt.Sprintf("%s.md5", requirementsFilePath)
|
requirementsHashFilePath := fmt.Sprintf("%s.md5", requirementsFilePath)
|
||||||
|
|
||||||
if _, err := os.Stat(requirementsFilePath); err != nil {
|
if _, err := os.Stat(requirementsFilePath); err != nil {
|
||||||
@ -639,7 +646,7 @@ func (t *TaskRunner) getEnvironmentExtraVars() (str string, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//nolint: gocyclo
|
// nolint: gocyclo
|
||||||
func (t *TaskRunner) getPlaybookArgs() (args []string, err error) {
|
func (t *TaskRunner) getPlaybookArgs() (args []string, err error) {
|
||||||
playbookName := t.task.Playbook
|
playbookName := t.task.Playbook
|
||||||
if playbookName == "" {
|
if playbookName == "" {
|
||||||
@ -696,6 +703,10 @@ func (t *TaskRunner) getPlaybookArgs() (args []string, err error) {
|
|||||||
args = append(args, "-vvvv")
|
args = append(args, "-vvvv")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if t.task.Diff {
|
||||||
|
args = append(args, "--diff")
|
||||||
|
}
|
||||||
|
|
||||||
if t.task.DryRun {
|
if t.task.DryRun {
|
||||||
args = append(args, "--check")
|
args = append(args, "--check")
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
package tasks
|
package tasks
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/ansible-semaphore/semaphore/db"
|
|
||||||
"github.com/ansible-semaphore/semaphore/db/bolt"
|
|
||||||
"github.com/ansible-semaphore/semaphore/util"
|
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
@ -11,8 +8,68 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/ansible-semaphore/semaphore/db"
|
||||||
|
"github.com/ansible-semaphore/semaphore/db/bolt"
|
||||||
|
"github.com/ansible-semaphore/semaphore/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestGetRepoPath(t *testing.T) {
|
||||||
|
util.Config = &util.ConfigType{
|
||||||
|
TmpPath: "/tmp",
|
||||||
|
}
|
||||||
|
|
||||||
|
inventoryID := 1
|
||||||
|
|
||||||
|
tsk := TaskRunner{
|
||||||
|
task: db.Task{},
|
||||||
|
inventory: db.Inventory{
|
||||||
|
SSHKeyID: &inventoryID,
|
||||||
|
SSHKey: db.AccessKey{
|
||||||
|
ID: 12345,
|
||||||
|
Type: db.AccessKeySSH,
|
||||||
|
},
|
||||||
|
Type: db.InventoryStatic,
|
||||||
|
},
|
||||||
|
template: db.Template{
|
||||||
|
Playbook: "deploy/test.yml",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
dir := tsk.getPlaybookDir()
|
||||||
|
if dir != "/tmp/repository_0_0/deploy" {
|
||||||
|
t.Fatal("Invalid playbook dir: " + dir)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetRepoPath_whenStartsWithSlash(t *testing.T) {
|
||||||
|
util.Config = &util.ConfigType{
|
||||||
|
TmpPath: "/tmp",
|
||||||
|
}
|
||||||
|
|
||||||
|
inventoryID := 1
|
||||||
|
|
||||||
|
tsk := TaskRunner{
|
||||||
|
task: db.Task{},
|
||||||
|
inventory: db.Inventory{
|
||||||
|
SSHKeyID: &inventoryID,
|
||||||
|
SSHKey: db.AccessKey{
|
||||||
|
ID: 12345,
|
||||||
|
Type: db.AccessKeySSH,
|
||||||
|
},
|
||||||
|
Type: db.InventoryStatic,
|
||||||
|
},
|
||||||
|
template: db.Template{
|
||||||
|
Playbook: "/deploy/test.yml",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
dir := tsk.getPlaybookDir()
|
||||||
|
if dir != "/tmp/repository_0_0/deploy" {
|
||||||
|
t.Fatal("Invalid playbook dir: " + dir)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestPopulateDetails(t *testing.T) {
|
func TestPopulateDetails(t *testing.T) {
|
||||||
r := rand.New(rand.NewSource(time.Now().UTC().UnixNano()))
|
r := rand.New(rand.NewSource(time.Now().UTC().UnixNano()))
|
||||||
fn := "/tmp/test_semaphore_db_" + strconv.Itoa(r.Int())
|
fn := "/tmp/test_semaphore_db_" + strconv.Itoa(r.Int())
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# web2
|
# web
|
||||||
|
|
||||||
## Project setup
|
## Project setup
|
||||||
```
|
```
|
2576
web2/package-lock.json → web/package-lock.json
generated
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "web2",
|
"name": "web",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -13,7 +13,6 @@
|
|||||||
"ansi-to-html": "^0.7.2",
|
"ansi-to-html": "^0.7.2",
|
||||||
"axios": "^0.21.4",
|
"axios": "^0.21.4",
|
||||||
"core-js": "^3.23.2",
|
"core-js": "^3.23.2",
|
||||||
"eslint-plugin-vuejs-accessibility": "^1.2.0",
|
|
||||||
"moment": "^2.29.3",
|
"moment": "^2.29.3",
|
||||||
"vue": "^2.6.14",
|
"vue": "^2.6.14",
|
||||||
"vue-codemirror": "^4.0.6",
|
"vue-codemirror": "^4.0.6",
|
||||||
@ -34,6 +33,7 @@
|
|||||||
"eslint": "^7.32.0",
|
"eslint": "^7.32.0",
|
||||||
"eslint-plugin-import": "^2.26.0",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
"eslint-plugin-vue": "^9.1.1",
|
"eslint-plugin-vue": "^9.1.1",
|
||||||
|
"eslint-plugin-vuejs-accessibility": "^1.2.0",
|
||||||
"glob-parent": ">=5.1.2",
|
"glob-parent": ">=5.1.2",
|
||||||
"nanoid": ">=3.1.31",
|
"nanoid": ">=3.1.31",
|
||||||
"nyc": "^15.1.0",
|
"nyc": "^15.1.0",
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 8.2 KiB |
Before Width: | Height: | Size: 539 B After Width: | Height: | Size: 539 B |
@ -52,7 +52,7 @@
|
|||||||
Example:
|
Example:
|
||||||
<pre style="font-size: 14px;">{
|
<pre style="font-size: 14px;">{
|
||||||
"var_available_in_playbook_1": 1245,
|
"var_available_in_playbook_1": 1245,
|
||||||
"var_available_in_playbook_2": "test",
|
"var_available_in_playbook_2": "test"
|
||||||
}</pre>
|
}</pre>
|
||||||
</v-alert>
|
</v-alert>
|
||||||
</v-form>
|
</v-form>
|
@ -100,7 +100,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<style>
|
<style>
|
||||||
.CodeMirror {
|
.CodeMirror {
|
||||||
height: 200px !important;
|
height: 160px !important;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
@ -71,13 +71,6 @@
|
|||||||
v-if="item.type === 'ssh'"
|
v-if="item.type === 'ssh'"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<v-text-field
|
|
||||||
v-model="item.pat"
|
|
||||||
label="Personal access token"
|
|
||||||
v-if="item.type === 'pat'"
|
|
||||||
:disabled="formSaving || !canEditSecrets"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<v-checkbox
|
<v-checkbox
|
||||||
v-model="item.override_secret"
|
v-model="item.override_secret"
|
||||||
label="Override"
|
label="Override"
|
||||||
@ -108,9 +101,6 @@ export default {
|
|||||||
}, {
|
}, {
|
||||||
id: 'login_password',
|
id: 'login_password',
|
||||||
name: 'Login with password',
|
name: 'Login with password',
|
||||||
}, {
|
|
||||||
id: 'pat',
|
|
||||||
name: 'Personal access token',
|
|
||||||
}, {
|
}, {
|
||||||
id: 'none',
|
id: 'none',
|
||||||
name: 'None',
|
name: 'None',
|
||||||
@ -129,7 +119,6 @@ export default {
|
|||||||
return {
|
return {
|
||||||
ssh: {},
|
ssh: {},
|
||||||
login_password: {},
|
login_password: {},
|
||||||
pat: '',
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
78
web/src/components/NewTaskDialog.vue
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
<template>
|
||||||
|
<EditDialog
|
||||||
|
v-model="dialog"
|
||||||
|
:save-button-text="TEMPLATE_TYPE_ACTION_TITLES[templateType]"
|
||||||
|
title="New Task"
|
||||||
|
@save="closeDialog"
|
||||||
|
@close="closeDialog"
|
||||||
|
>
|
||||||
|
<template v-slot:title={}>
|
||||||
|
<v-icon small class="mr-4">{{ TEMPLATE_TYPE_ICONS[templateType] }}</v-icon>
|
||||||
|
<span class="breadcrumbs__item">{{ templateAlias }}</span>
|
||||||
|
<v-icon>mdi-chevron-right</v-icon>
|
||||||
|
<span class="breadcrumbs__item">New Task</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-slot:form="{ onSave, onError, needSave, needReset }">
|
||||||
|
<TaskForm
|
||||||
|
:project-id="projectId"
|
||||||
|
item-id="new"
|
||||||
|
:template-id="templateId"
|
||||||
|
@save="onSave"
|
||||||
|
@error="onError"
|
||||||
|
:need-save="needSave"
|
||||||
|
:need-reset="needReset"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</EditDialog>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import TaskForm from './TaskForm.vue';
|
||||||
|
import EditDialog from './EditDialog.vue';
|
||||||
|
|
||||||
|
import { TEMPLATE_TYPE_ACTION_TITLES, TEMPLATE_TYPE_ICONS } from '../lib/constants';
|
||||||
|
import EventBus from '../event-bus';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
TaskForm,
|
||||||
|
EditDialog,
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
value: Boolean,
|
||||||
|
projectId: Number,
|
||||||
|
templateId: Number,
|
||||||
|
templateType: String,
|
||||||
|
templateAlias: String,
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
dialog: false,
|
||||||
|
TEMPLATE_TYPE_ACTION_TITLES,
|
||||||
|
TEMPLATE_TYPE_ICONS,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
async dialog(val) {
|
||||||
|
this.$emit('input', val);
|
||||||
|
},
|
||||||
|
|
||||||
|
async value(val) {
|
||||||
|
this.dialog = val;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
closeDialog(e) {
|
||||||
|
this.dialog = false;
|
||||||
|
if (e) {
|
||||||
|
EventBus.$emit('i-show-task', {
|
||||||
|
taskId: e.item.id,
|
||||||
|
});
|
||||||
|
this.$emit('save', e);
|
||||||
|
}
|
||||||
|
this.$emit('close');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
@ -35,32 +35,14 @@
|
|||||||
<div class="mt-1 mb-4">
|
<div class="mt-1 mb-4">
|
||||||
<span class="caption">git:</span>
|
<span class="caption">git:</span>
|
||||||
<v-chip
|
<v-chip
|
||||||
|
v-for="x in ['ssh', 'https', 'file', 'git']"
|
||||||
x-small
|
x-small
|
||||||
class="ml-1"
|
class="ml-1"
|
||||||
:color="type ==='file' ? 'primary' : ''"
|
:color="type ===x ? 'primary' : ''"
|
||||||
@click="setType('file')"
|
@click="setType(x)"
|
||||||
style="font-weight: bold;"
|
style="font-weight: bold;"
|
||||||
>
|
:key="x"
|
||||||
file
|
>{{ x }}</v-chip>
|
||||||
</v-chip>
|
|
||||||
<v-chip
|
|
||||||
x-small
|
|
||||||
class="ml-1"
|
|
||||||
:color="type ==='git' ? 'primary' : ''"
|
|
||||||
@click="setType('git')"
|
|
||||||
style="font-weight: bold;"
|
|
||||||
>
|
|
||||||
git
|
|
||||||
</v-chip>
|
|
||||||
<v-chip
|
|
||||||
x-small
|
|
||||||
class="ml-1"
|
|
||||||
:color="type ==='ssh' ? 'primary' : ''"
|
|
||||||
@click="setType('ssh')"
|
|
||||||
style="font-weight: bold;"
|
|
||||||
>
|
|
||||||
ssh
|
|
||||||
</v-chip>
|
|
||||||
<span class="caption ml-3">local:</span>
|
<span class="caption ml-3">local:</span>
|
||||||
<v-chip
|
<v-chip
|
||||||
x-small
|
x-small
|
||||||
@ -166,7 +148,7 @@ export default {
|
|||||||
return 'ssh';
|
return 'ssh';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!['git', 'file', 'ssh'].includes(m[1])) {
|
if (!['git', 'file', 'ssh', 'https'].includes(m[1])) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -8,25 +8,33 @@
|
|||||||
<v-card :color="$vuetify.theme.dark ? '#212121' : 'white'">
|
<v-card :color="$vuetify.theme.dark ? '#212121' : 'white'">
|
||||||
<v-card-title></v-card-title>
|
<v-card-title></v-card-title>
|
||||||
<v-card-text class="pb-0">
|
<v-card-text class="pb-0">
|
||||||
<v-form v-if="editedVar != null">
|
<v-form
|
||||||
|
ref="form"
|
||||||
|
lazy-validation
|
||||||
|
v-if="editedVar != null"
|
||||||
|
>
|
||||||
<v-text-field
|
<v-text-field
|
||||||
label="Name"
|
label="Name *"
|
||||||
v-model="editedVar.name"
|
v-model.trim="editedVar.name"
|
||||||
|
:rules="[(v) => !!v || 'Name is required']"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<v-text-field
|
<v-text-field
|
||||||
label="Title"
|
label="Title *"
|
||||||
v-model="editedVar.title"
|
v-model="editedVar.title"
|
||||||
|
:rules="[(v) => !!v || 'Title is required']"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<v-text-field
|
<v-text-field
|
||||||
label="Description (Optional)"
|
label="Description"
|
||||||
v-model="editedVar.description"
|
v-model="editedVar.description"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
<v-select
|
<v-select
|
||||||
v-model="editedVar.type"
|
v-model="editedVar.type"
|
||||||
label="Type (Optional)"
|
label="Type"
|
||||||
:items="varTypes"
|
:items="varTypes"
|
||||||
item-value="id"
|
item-value="id"
|
||||||
item-text="name"
|
item-text="name"
|
||||||
@ -56,7 +64,7 @@
|
|||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
<fieldset style="padding: 0 10px 5px 10px;
|
<fieldset style="padding: 0 10px 2px 10px;
|
||||||
border: 1px solid rgba(0, 0, 0, 0.38);
|
border: 1px solid rgba(0, 0, 0, 0.38);
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
font-size: 12px;"
|
font-size: 12px;"
|
||||||
@ -66,7 +74,7 @@
|
|||||||
'rgba(0, 0, 0, 0.38)'
|
'rgba(0, 0, 0, 0.38)'
|
||||||
}">
|
}">
|
||||||
<legend style="padding: 0 3px;">Survey Variables</legend>
|
<legend style="padding: 0 3px;">Survey Variables</legend>
|
||||||
<v-chip-group column>
|
<v-chip-group column style="margin-top: -4px;">
|
||||||
<v-chip
|
<v-chip
|
||||||
v-for="(v, i) in modifiedVars"
|
v-for="(v, i) in modifiedVars"
|
||||||
close
|
close
|
||||||
@ -77,7 +85,9 @@
|
|||||||
>
|
>
|
||||||
{{ v.title }}
|
{{ v.title }}
|
||||||
</v-chip>
|
</v-chip>
|
||||||
<v-chip @click="editVar(null)">+</v-chip>
|
<v-chip @click="editVar(null)">
|
||||||
|
+ <span class="ml-1" v-if="modifiedVars.length === 0">Add variable</span>
|
||||||
|
</v-chip>
|
||||||
</v-chip-group>
|
</v-chip-group>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
@ -95,9 +105,11 @@ export default {
|
|||||||
this.var = val || [];
|
this.var = val || [];
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
created() {
|
created() {
|
||||||
this.modifiedVars = (this.vars || []).map((v) => ({ ...v }));
|
this.modifiedVars = (this.vars || []).map((v) => ({ ...v }));
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
editDialog: null,
|
editDialog: null,
|
||||||
@ -117,17 +129,23 @@ export default {
|
|||||||
editVar(index) {
|
editVar(index) {
|
||||||
this.editedVar = index != null ? { ...this.modifiedVars[index] } : {};
|
this.editedVar = index != null ? { ...this.modifiedVars[index] } : {};
|
||||||
this.editedVarIndex = index;
|
this.editedVarIndex = index;
|
||||||
|
if (this.$refs.form) {
|
||||||
|
this.$refs.form.resetValidation();
|
||||||
|
}
|
||||||
this.editDialog = true;
|
this.editDialog = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
saveVar() {
|
saveVar() {
|
||||||
|
if (!this.$refs.form.validate()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.editedVarIndex != null) {
|
if (this.editedVarIndex != null) {
|
||||||
this.modifiedVars[this.editedVarIndex] = this.editedVar;
|
this.modifiedVars[this.editedVarIndex] = this.editedVar;
|
||||||
} else {
|
} else {
|
||||||
this.modifiedVars.push(this.editedVar);
|
this.modifiedVars.push(this.editedVar);
|
||||||
}
|
}
|
||||||
this.editDialog = false;
|
this.editDialog = false;
|
||||||
this.editVarIndex = null;
|
|
||||||
this.editedVar = null;
|
this.editedVar = null;
|
||||||
this.$emit('change', this.modifiedVars);
|
this.$emit('change', this.modifiedVars);
|
||||||
},
|
},
|
@ -58,13 +58,44 @@
|
|||||||
]"
|
]"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div class="mt-4 mb-2" v-if="!advancedOptions">
|
<v-row no-gutters class="mt-6">
|
||||||
|
<v-col cols="12" sm="6">
|
||||||
|
<v-checkbox class="mt-0" v-model="item.debug">
|
||||||
|
<template v-slot:label>
|
||||||
|
<div class="text-no-wrap">Debug <code>--vvvv</code></div>
|
||||||
|
</template>
|
||||||
|
</v-checkbox>
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="12" sm="6">
|
||||||
|
<v-checkbox class="mt-0" v-model="item.dry_run">
|
||||||
|
<template v-slot:label>
|
||||||
|
<div class="text-no-wrap">Dry Run <code>--check</code></div>
|
||||||
|
</template>
|
||||||
|
</v-checkbox>
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="12" sm="6">
|
||||||
|
<v-checkbox class="mt-0" v-model="item.diff">
|
||||||
|
<template v-slot:label>
|
||||||
|
<div class="text-no-wrap">Diff <code>--diff</code></div>
|
||||||
|
</template>
|
||||||
|
</v-checkbox>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
|
||||||
|
<div class="mt-4" v-if="!advancedOptions">
|
||||||
<a @click="advancedOptions = true">
|
<a @click="advancedOptions = true">
|
||||||
Advanced
|
Advanced
|
||||||
<v-icon style="transform: translateY(-1px)">mdi-chevron-right</v-icon>
|
<v-icon style="transform: translateY(-1px)">mdi-chevron-right</v-icon>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-4" v-else>
|
||||||
|
<a @click="advancedOptions = false">
|
||||||
|
Hide
|
||||||
|
<v-icon style="transform: translateY(-1px)">mdi-chevron-up</v-icon>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
<v-alert
|
<v-alert
|
||||||
v-if="advancedOptions && !template.allow_override_args_in_task"
|
v-if="advancedOptions && !template.allow_override_args_in_task"
|
||||||
color="info"
|
color="info"
|
||||||
@ -92,8 +123,7 @@
|
|||||||
:style="{ border: '1px solid lightgray' }"
|
:style="{ border: '1px solid lightgray' }"
|
||||||
v-model="item.arguments"
|
v-model="item.arguments"
|
||||||
:options="cmOptions"
|
:options="cmOptions"
|
||||||
placeholder='Enter extra CLI Arguments...
|
placeholder='CLI Args (JSON array). Example:
|
||||||
Example:
|
|
||||||
[
|
[
|
||||||
"-i",
|
"-i",
|
||||||
"@myinventory.sh",
|
"@myinventory.sh",
|
||||||
@ -102,30 +132,6 @@ Example:
|
|||||||
]'
|
]'
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div
|
|
||||||
v-if="advancedOptions"
|
|
||||||
>
|
|
||||||
<a @click="advancedOptions = false">
|
|
||||||
Hide
|
|
||||||
<v-icon style="transform: translateY(-1px)">mdi-chevron-up</v-icon>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<v-row no-gutters>
|
|
||||||
<v-col>
|
|
||||||
<v-checkbox
|
|
||||||
v-model="item.debug"
|
|
||||||
label="Debug"
|
|
||||||
></v-checkbox>
|
|
||||||
</v-col>
|
|
||||||
<v-col>
|
|
||||||
<v-checkbox
|
|
||||||
v-model="item.dry_run"
|
|
||||||
label="Dry Run"
|
|
||||||
></v-checkbox>
|
|
||||||
</v-col>
|
|
||||||
</v-row>
|
|
||||||
|
|
||||||
</v-form>
|
</v-form>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
@ -115,16 +115,30 @@
|
|||||||
|
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="item.name"
|
v-model="item.name"
|
||||||
label="Playbook Name"
|
label="Name *"
|
||||||
:rules="[v => !!v || 'Playbook Name is required']"
|
:rules="[v => !!v || 'Name is required']"
|
||||||
|
outlined
|
||||||
|
dense
|
||||||
required
|
required
|
||||||
:disabled="formSaving"
|
:disabled="formSaving"
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
|
|
||||||
|
<v-textarea
|
||||||
|
v-model="item.description"
|
||||||
|
label="Description"
|
||||||
|
:disabled="formSaving"
|
||||||
|
rows="1"
|
||||||
|
:auto-grow="true"
|
||||||
|
outlined
|
||||||
|
dense
|
||||||
|
></v-textarea>
|
||||||
|
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="item.playbook"
|
v-model="item.playbook"
|
||||||
label="Playbook Filename"
|
label="Playbook Filename *"
|
||||||
:rules="[v => !!v || 'Playbook Filename is required']"
|
:rules="[v => !!v || 'Playbook Filename is required']"
|
||||||
|
outlined
|
||||||
|
dense
|
||||||
required
|
required
|
||||||
:disabled="formSaving"
|
:disabled="formSaving"
|
||||||
placeholder="Example: site.yml"
|
placeholder="Example: site.yml"
|
||||||
@ -132,37 +146,45 @@
|
|||||||
|
|
||||||
<v-select
|
<v-select
|
||||||
v-model="item.inventory_id"
|
v-model="item.inventory_id"
|
||||||
label="Inventory"
|
label="Inventory *"
|
||||||
:items="inventory"
|
:items="inventory"
|
||||||
item-value="id"
|
item-value="id"
|
||||||
item-text="name"
|
item-text="name"
|
||||||
:rules="[v => !!v || 'Inventory is required']"
|
:rules="[v => !!v || 'Inventory is required']"
|
||||||
|
outlined
|
||||||
|
dense
|
||||||
required
|
required
|
||||||
:disabled="formSaving"
|
:disabled="formSaving"
|
||||||
></v-select>
|
></v-select>
|
||||||
|
|
||||||
<v-select
|
<v-select
|
||||||
v-model="item.repository_id"
|
v-model="item.repository_id"
|
||||||
label="Repository"
|
label="Repository *"
|
||||||
:items="repositories"
|
:items="repositories"
|
||||||
item-value="id"
|
item-value="id"
|
||||||
item-text="name"
|
item-text="name"
|
||||||
:rules="[v => !!v || 'Repository is required']"
|
:rules="[v => !!v || 'Repository is required']"
|
||||||
|
outlined
|
||||||
|
dense
|
||||||
required
|
required
|
||||||
:disabled="formSaving"
|
:disabled="formSaving"
|
||||||
></v-select>
|
></v-select>
|
||||||
|
|
||||||
<v-select
|
<v-select
|
||||||
v-model="item.environment_id"
|
v-model="item.environment_id"
|
||||||
label="Environment"
|
label="Environment *"
|
||||||
:items="environment"
|
:items="environment"
|
||||||
item-value="id"
|
item-value="id"
|
||||||
item-text="name"
|
item-text="name"
|
||||||
:rules="[v => !!v || 'Environment is required']"
|
:rules="[v => !!v || 'Environment is required']"
|
||||||
|
outlined
|
||||||
|
dense
|
||||||
required
|
required
|
||||||
:disabled="formSaving"
|
:disabled="formSaving"
|
||||||
></v-select>
|
></v-select>
|
||||||
|
|
||||||
<v-select
|
<v-select
|
||||||
|
v-if="itemTypeIndex === 0"
|
||||||
v-model="item.vault_key_id"
|
v-model="item.vault_key_id"
|
||||||
label="Vault Password"
|
label="Vault Password"
|
||||||
clearable
|
clearable
|
||||||
@ -170,71 +192,114 @@
|
|||||||
item-value="id"
|
item-value="id"
|
||||||
item-text="name"
|
item-text="name"
|
||||||
:disabled="formSaving"
|
:disabled="formSaving"
|
||||||
|
outlined
|
||||||
|
dense
|
||||||
></v-select>
|
></v-select>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
|
||||||
<v-col cols="12" md="6" class="pb-0">
|
<v-col cols="12" md="6" class="pb-0">
|
||||||
<v-textarea
|
|
||||||
outlined
|
|
||||||
v-model="item.description"
|
|
||||||
label="Description (Optional)"
|
|
||||||
:disabled="formSaving"
|
|
||||||
rows="5"
|
|
||||||
></v-textarea>
|
|
||||||
|
|
||||||
<SurveyVars :vars="item.survey_vars" @change="setSurveyVars"/>
|
<v-select
|
||||||
|
v-if="itemTypeIndex > 0"
|
||||||
|
v-model="item.vault_key_id"
|
||||||
|
label="Vault Password"
|
||||||
|
clearable
|
||||||
|
:items="loginPasswordKeys"
|
||||||
|
item-value="id"
|
||||||
|
item-text="name"
|
||||||
|
:disabled="formSaving"
|
||||||
|
outlined
|
||||||
|
dense
|
||||||
|
></v-select>
|
||||||
|
|
||||||
|
<SurveyVars style="margin-top: -10px;" :vars="item.survey_vars" @change="setSurveyVars"/>
|
||||||
|
|
||||||
<v-select
|
<v-select
|
||||||
v-model="item.view_id"
|
v-model="item.view_id"
|
||||||
label="View (Optional)"
|
label="View"
|
||||||
clearable
|
clearable
|
||||||
:items="views"
|
:items="views"
|
||||||
item-value="id"
|
item-value="id"
|
||||||
item-text="title"
|
item-text="title"
|
||||||
:disabled="formSaving"
|
:disabled="formSaving"
|
||||||
|
outlined
|
||||||
|
dense
|
||||||
></v-select>
|
></v-select>
|
||||||
|
|
||||||
|
<v-row>
|
||||||
|
<v-col cols="5" class="pr-1">
|
||||||
<v-text-field
|
<v-text-field
|
||||||
class="mt-6"
|
style="font-size: 14px"
|
||||||
v-model="cronFormat"
|
v-model="cronFormat"
|
||||||
label="Cron (Optional)"
|
label="Cron"
|
||||||
:disabled="formSaving"
|
:disabled="formSaving"
|
||||||
placeholder="Example: * 1 * * *"
|
placeholder="* * * * *"
|
||||||
v-if="schedules == null || schedules.length <= 1"
|
v-if="schedules == null || schedules.length <= 1"
|
||||||
append-outer-icon="mdi-help-circle"
|
outlined
|
||||||
@click:append-outer="showHelpDialog('cron')"
|
dense
|
||||||
|
hide-details
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
|
</v-col>
|
||||||
|
|
||||||
|
<v-col cols="7">
|
||||||
|
<a
|
||||||
|
v-if="!cronRepositoryIdVisible && cronRepositoryId == null"
|
||||||
|
@click="cronRepositoryIdVisible = true"
|
||||||
|
class="text-caption d-block"
|
||||||
|
style="line-height: 1.1;"
|
||||||
|
>
|
||||||
|
I want to run a task by the cron only for for new commits of some repository
|
||||||
|
</a>
|
||||||
|
|
||||||
<v-select
|
<v-select
|
||||||
|
style="font-size: 14px"
|
||||||
|
v-if="cronRepositoryIdVisible || cronRepositoryId != null"
|
||||||
v-model="cronRepositoryId"
|
v-model="cronRepositoryId"
|
||||||
label="Cron Condition Repository (Optional)"
|
label="Repository"
|
||||||
placeholder="Cron checks new commit before run"
|
placeholder="Cron checks new commit before run"
|
||||||
:items="repositories"
|
:items="repositories"
|
||||||
item-value="id"
|
item-value="id"
|
||||||
item-text="name"
|
item-text="name"
|
||||||
|
clearable
|
||||||
:disabled="formSaving"
|
:disabled="formSaving"
|
||||||
|
outlined
|
||||||
|
dense
|
||||||
|
hide-details
|
||||||
></v-select>
|
></v-select>
|
||||||
|
|
||||||
<a @click="advancedOptions = true" v-if="!advancedOptions">
|
</v-col>
|
||||||
Advanced
|
</v-row>
|
||||||
<v-icon style="transform: translateY(-1px)">mdi-chevron-right</v-icon>
|
|
||||||
</a>
|
<small class="mt-1 mb-4 d-block">
|
||||||
|
Read the
|
||||||
|
<a target="_blank" href="https://pkg.go.dev/github.com/robfig/cron#hdr-CRON_Expression_Format">docs</a>
|
||||||
|
to learn more about Cron.
|
||||||
|
</small>
|
||||||
|
|
||||||
<v-checkbox
|
<v-checkbox
|
||||||
v-if="advancedOptions"
|
|
||||||
class="mt-0"
|
class="mt-0"
|
||||||
label="Suppress success alerts"
|
label="Suppress success alerts"
|
||||||
v-model="item.suppress_success_alerts"
|
v-model="item.suppress_success_alerts"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<!-- <a @click="advancedOptions = true" v-if="!advancedOptions">-->
|
||||||
|
<!-- Advanced-->
|
||||||
|
<!-- <v-icon style="transform: translateY(-1px)">mdi-chevron-right</v-icon>-->
|
||||||
|
<!-- </a>-->
|
||||||
|
|
||||||
|
<!-- <div v-if="advancedOptions" class="mb-3">-->
|
||||||
|
<!-- <a @click="advancedOptions = false">-->
|
||||||
|
<!-- Hide-->
|
||||||
|
<!-- <v-icon style="transform: translateY(-1px)">mdi-chevron-up</v-icon>-->
|
||||||
|
<!-- </a>-->
|
||||||
|
<!-- </div>-->
|
||||||
|
|
||||||
<codemirror
|
<codemirror
|
||||||
v-if="advancedOptions"
|
|
||||||
:style="{ border: '1px solid lightgray' }"
|
:style="{ border: '1px solid lightgray' }"
|
||||||
v-model="item.arguments"
|
v-model="item.arguments"
|
||||||
:options="cmOptions"
|
:options="cmOptions"
|
||||||
:disabled="formSaving"
|
:disabled="formSaving"
|
||||||
placeholder='Enter extra CLI Arguments...
|
placeholder='CLI Args (JSON array). Example:
|
||||||
Example:
|
|
||||||
[
|
[
|
||||||
"-i",
|
"-i",
|
||||||
"@myinventory.sh",
|
"@myinventory.sh",
|
||||||
@ -244,11 +309,10 @@ Example:
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<v-checkbox
|
<v-checkbox
|
||||||
v-if="advancedOptions"
|
label="Allow CLI args in Task"
|
||||||
class="mt-0"
|
|
||||||
label="Allow override CLI args in task"
|
|
||||||
v-model="item.allow_override_args_in_task"
|
v-model="item.allow_override_args_in_task"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-form>
|
</v-form>
|
||||||
@ -307,6 +371,7 @@ export default {
|
|||||||
buildTemplates: null,
|
buildTemplates: null,
|
||||||
cronFormat: null,
|
cronFormat: null,
|
||||||
cronRepositoryId: null,
|
cronRepositoryId: null,
|
||||||
|
cronRepositoryIdVisible: false,
|
||||||
|
|
||||||
helpDialog: null,
|
helpDialog: null,
|
||||||
helpKey: null,
|
helpKey: null,
|
@ -1,7 +1,7 @@
|
|||||||
export const TEMPLATE_TYPE_ICONS = {
|
export const TEMPLATE_TYPE_ICONS = {
|
||||||
'': 'mdi-cog',
|
'': 'mdi-cog',
|
||||||
build: 'mdi-wrench',
|
build: 'mdi-wrench',
|
||||||
deploy: 'mdi-rocket-launch',
|
deploy: 'mdi-arrow-up-bold-box',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const TEMPLATE_TYPE_TITLES = {
|
export const TEMPLATE_TYPE_TITLES = {
|