You've already forked db-wait
Compare commits
17 Commits
v0.1.0
...
e96001f2a0
Author | SHA1 | Date | |
---|---|---|---|
e96001f2a0 | |||
68c07b6a81 | |||
e44cbaeed3
|
|||
655c5b0329
|
|||
62df6f7955
|
|||
1e3a25c202 | |||
f4740434c6
|
|||
47d8e2222a
|
|||
a7a8703d7f
|
|||
8dd6bc21fb
|
|||
6c6bfd8c6d | |||
d53bf5fafe
|
|||
9b37cc1966
|
|||
7a0eaa6764
|
|||
760c55f48e
|
|||
081f147657
|
|||
7afd418bb8
|
493
.drone.yml
493
.drone.yml
@ -5,13 +5,12 @@ name: linter
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: markdown lint
|
||||
commands:
|
||||
- markdownlint *.md
|
||||
image: docker.io/volkerraschek/markdownlint:0.28.1
|
||||
image: docker.io/volkerraschek/markdownlint:0.29.0
|
||||
resources:
|
||||
limits:
|
||||
cpu: 50
|
||||
@ -41,6 +40,172 @@ trigger:
|
||||
event:
|
||||
exclude:
|
||||
- tag
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: dry-run-amd64
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: plugins/docker
|
||||
settings:
|
||||
dockerfile: Dockerfile
|
||||
auto_tag: false
|
||||
dry_run: true
|
||||
tags: latest-amd64
|
||||
repo: volkerraschek/db-wait
|
||||
no_cache: true
|
||||
volumes:
|
||||
- name: docker_socket
|
||||
path: /var/run/docker.sock
|
||||
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
environment:
|
||||
PLUGIN_HOST:
|
||||
from_secret: smtp_host
|
||||
PLUGIN_USERNAME:
|
||||
from_secret: smtp_username
|
||||
PLUGIN_PASSWORD:
|
||||
from_secret: smtp_password
|
||||
PLUGIN_FROM:
|
||||
from_secret: smtp_mail_address
|
||||
when:
|
||||
status:
|
||||
- changed
|
||||
- failure
|
||||
|
||||
volumes:
|
||||
- name: docker_socket
|
||||
host:
|
||||
path: /var/run/docker.sock
|
||||
|
||||
depends_on:
|
||||
- linter
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
exclude:
|
||||
- master
|
||||
event:
|
||||
- pull_request
|
||||
- push
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: dry-run-arm-v7
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: arm
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: plugins/docker
|
||||
settings:
|
||||
dockerfile: Dockerfile
|
||||
auto_tag: false
|
||||
dry_run: true
|
||||
tags: latest-arm-v7
|
||||
repo: volkerraschek/db-wait
|
||||
no_cache: true
|
||||
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
environment:
|
||||
PLUGIN_HOST:
|
||||
from_secret: smtp_host
|
||||
PLUGIN_USERNAME:
|
||||
from_secret: smtp_username
|
||||
PLUGIN_PASSWORD:
|
||||
from_secret: smtp_password
|
||||
PLUGIN_FROM:
|
||||
from_secret: smtp_mail_address
|
||||
volumes:
|
||||
- name: docker_socket
|
||||
path: /var/run/docker.sock
|
||||
when:
|
||||
status:
|
||||
- changed
|
||||
- failure
|
||||
|
||||
volumes:
|
||||
- name: docker_socket
|
||||
host:
|
||||
path: /var/run/docker.sock
|
||||
|
||||
depends_on:
|
||||
- linter
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
exclude:
|
||||
- master
|
||||
event:
|
||||
- pull_request
|
||||
- push
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: dry-run-arm64-v8
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: arm64
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: plugins/docker
|
||||
settings:
|
||||
dockerfile: Dockerfile
|
||||
auto_tag: false
|
||||
dry_run: true
|
||||
tags: latest-arm64-v8
|
||||
repo: volkerraschek/db-wait
|
||||
no_cache: true
|
||||
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
environment:
|
||||
PLUGIN_HOST:
|
||||
from_secret: smtp_host
|
||||
PLUGIN_USERNAME:
|
||||
from_secret: smtp_username
|
||||
PLUGIN_PASSWORD:
|
||||
from_secret: smtp_password
|
||||
PLUGIN_FROM:
|
||||
from_secret: smtp_mail_address
|
||||
volumes:
|
||||
- name: docker_socket
|
||||
path: /var/run/docker.sock
|
||||
when:
|
||||
status:
|
||||
- changed
|
||||
- failure
|
||||
|
||||
volumes:
|
||||
- name: docker_socket
|
||||
host:
|
||||
path: /var/run/docker.sock
|
||||
|
||||
depends_on:
|
||||
- linter
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
exclude:
|
||||
- master
|
||||
event:
|
||||
- pull_request
|
||||
- push
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
@ -62,12 +227,10 @@ steps:
|
||||
from_secret: container_image_registry_user
|
||||
password:
|
||||
from_secret: container_image_registry_password
|
||||
no_cache: true
|
||||
volumes:
|
||||
- name: docker_socket
|
||||
path: /var/run/docker.sock
|
||||
when:
|
||||
branch:
|
||||
- master
|
||||
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
@ -90,15 +253,22 @@ volumes:
|
||||
host:
|
||||
path: /var/run/docker.sock
|
||||
|
||||
depends_on:
|
||||
- linter
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
exclude:
|
||||
- tag
|
||||
- cron
|
||||
- push
|
||||
repo:
|
||||
- volker.raschek/db-wait
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: latest-armv7
|
||||
name: latest-arm-v7
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
@ -110,15 +280,13 @@ steps:
|
||||
settings:
|
||||
dockerfile: Dockerfile
|
||||
auto_tag: false
|
||||
tags: latest-armv7
|
||||
tags: latest-arm-v7
|
||||
repo: volkerraschek/db-wait
|
||||
username:
|
||||
from_secret: container_image_registry_user
|
||||
password:
|
||||
from_secret: container_image_registry_password
|
||||
when:
|
||||
branch:
|
||||
- master
|
||||
no_cache: true
|
||||
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
@ -144,10 +312,76 @@ volumes:
|
||||
host:
|
||||
path: /var/run/docker.sock
|
||||
|
||||
depends_on:
|
||||
- linter
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
exclude:
|
||||
- tag
|
||||
- cron
|
||||
- push
|
||||
repo:
|
||||
- volker.raschek/db-wait
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: latest-arm64-v8
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: arm64
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: plugins/docker
|
||||
settings:
|
||||
dockerfile: Dockerfile
|
||||
auto_tag: false
|
||||
tags: latest-arm64-v8
|
||||
repo: volkerraschek/db-wait
|
||||
username:
|
||||
from_secret: container_image_registry_user
|
||||
password:
|
||||
from_secret: container_image_registry_password
|
||||
no_cache: true
|
||||
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
environment:
|
||||
PLUGIN_HOST:
|
||||
from_secret: smtp_host
|
||||
PLUGIN_USERNAME:
|
||||
from_secret: smtp_username
|
||||
PLUGIN_PASSWORD:
|
||||
from_secret: smtp_password
|
||||
PLUGIN_FROM:
|
||||
from_secret: smtp_mail_address
|
||||
volumes:
|
||||
- name: docker_socket
|
||||
path: /var/run/docker.sock
|
||||
when:
|
||||
status:
|
||||
- changed
|
||||
- failure
|
||||
|
||||
volumes:
|
||||
- name: docker_socket
|
||||
host:
|
||||
path: /var/run/docker.sock
|
||||
|
||||
depends_on:
|
||||
- linter
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
- cron
|
||||
- push
|
||||
repo:
|
||||
- volker.raschek/db-wait
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
@ -188,12 +422,231 @@ steps:
|
||||
|
||||
depends_on:
|
||||
- latest-amd64
|
||||
- latest-armv7
|
||||
- latest-arm-v7
|
||||
- latest-arm64-v8
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
- cron
|
||||
- push
|
||||
repo:
|
||||
- volker.raschek/db-wait
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: tagged-amd64
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: amd64
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: plugins/docker
|
||||
settings:
|
||||
dockerfile: Dockerfile
|
||||
auto_tag: true
|
||||
auto_tag_suffix: amd64
|
||||
repo: volkerraschek/db-wait
|
||||
username:
|
||||
from_secret: container_image_registry_user
|
||||
password:
|
||||
from_secret: container_image_registry_password
|
||||
build_args:
|
||||
- VERSION=${DRONE_TAG}
|
||||
no_cache: true
|
||||
volumes:
|
||||
- name: docker_socket
|
||||
path: /var/run/docker.sock
|
||||
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
environment:
|
||||
PLUGIN_HOST:
|
||||
from_secret: smtp_host
|
||||
PLUGIN_USERNAME:
|
||||
from_secret: smtp_username
|
||||
PLUGIN_PASSWORD:
|
||||
from_secret: smtp_password
|
||||
PLUGIN_FROM:
|
||||
from_secret: smtp_mail_address
|
||||
when:
|
||||
status:
|
||||
- changed
|
||||
- failure
|
||||
|
||||
volumes:
|
||||
- name: docker_socket
|
||||
host:
|
||||
path: /var/run/docker.sock
|
||||
|
||||
trigger:
|
||||
event:
|
||||
exclude:
|
||||
- tag
|
||||
- tag
|
||||
repo:
|
||||
- volker.raschek/db-wait
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: tagged-arm-v7
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: arm
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: plugins/docker
|
||||
settings:
|
||||
dockerfile: Dockerfile
|
||||
auto_tag: true
|
||||
auto_tag_suffix: arm-v7
|
||||
repo: volkerraschek/db-wait
|
||||
username:
|
||||
from_secret: container_image_registry_user
|
||||
password:
|
||||
from_secret: container_image_registry_password
|
||||
build_args:
|
||||
- VERSION=${DRONE_TAG}
|
||||
no_cache: true
|
||||
volumes:
|
||||
- name: docker_socket
|
||||
path: /var/run/docker.sock
|
||||
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
environment:
|
||||
PLUGIN_HOST:
|
||||
from_secret: smtp_host
|
||||
PLUGIN_USERNAME:
|
||||
from_secret: smtp_username
|
||||
PLUGIN_PASSWORD:
|
||||
from_secret: smtp_password
|
||||
PLUGIN_FROM:
|
||||
from_secret: smtp_mail_address
|
||||
when:
|
||||
status:
|
||||
- changed
|
||||
- failure
|
||||
|
||||
volumes:
|
||||
- name: docker_socket
|
||||
host:
|
||||
path: /var/run/docker.sock
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- tag
|
||||
repo:
|
||||
- volker.raschek/db-wait
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: tagged-arm64-v8
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: arm64
|
||||
|
||||
steps:
|
||||
- name: build
|
||||
image: plugins/docker
|
||||
settings:
|
||||
dockerfile: Dockerfile
|
||||
auto_tag: true
|
||||
auto_tag_suffix: arm64-v8
|
||||
repo: volkerraschek/db-wait
|
||||
username:
|
||||
from_secret: container_image_registry_user
|
||||
password:
|
||||
from_secret: container_image_registry_password
|
||||
build_args:
|
||||
- MARKDOWNLINT_VERSION=${DRONE_TAG}
|
||||
no_cache: true
|
||||
volumes:
|
||||
- name: docker_socket
|
||||
path: /var/run/docker.sock
|
||||
|
||||
- name: notify
|
||||
image: drillster/drone-email
|
||||
environment:
|
||||
PLUGIN_HOST:
|
||||
from_secret: smtp_host
|
||||
PLUGIN_USERNAME:
|
||||
from_secret: smtp_username
|
||||
PLUGIN_PASSWORD:
|
||||
from_secret: smtp_password
|
||||
PLUGIN_FROM:
|
||||
from_secret: smtp_mail_address
|
||||
when:
|
||||
status:
|
||||
- changed
|
||||
- failure
|
||||
|
||||
volumes:
|
||||
- name: docker_socket
|
||||
host:
|
||||
path: /var/run/docker.sock
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- tag
|
||||
repo:
|
||||
- volker.raschek/db-wait
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: kubernetes
|
||||
name: tagged-manifest
|
||||
|
||||
steps:
|
||||
- name: build-manifest
|
||||
image: plugins/manifest
|
||||
settings:
|
||||
auto_tag: true
|
||||
ignore_missing: true
|
||||
spec: manifest.tmpl
|
||||
username:
|
||||
from_secret: container_image_registry_user
|
||||
password:
|
||||
from_secret: container_image_registry_password
|
||||
|
||||
- name: notify
|
||||
image: docker.io/drillster/drone-email:latest
|
||||
environment:
|
||||
PLUGIN_HOST:
|
||||
from_secret: smtp_host
|
||||
PLUGIN_USERNAME:
|
||||
from_secret: smtp_username
|
||||
PLUGIN_PASSWORD:
|
||||
from_secret: smtp_password
|
||||
PLUGIN_FROM:
|
||||
from_secret: smtp_mail_address
|
||||
resources:
|
||||
limits:
|
||||
cpu: 50
|
||||
memory: 25M
|
||||
when:
|
||||
status:
|
||||
- changed
|
||||
- failure
|
||||
|
||||
depends_on:
|
||||
- tagged-amd64
|
||||
- tagged-arm-v7
|
||||
- tagged-arm64-v8
|
||||
|
||||
trigger:
|
||||
event:
|
||||
- tag
|
||||
repo:
|
||||
- volker.raschek/db-wait
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: kubernetes
|
||||
@ -237,8 +690,14 @@ steps:
|
||||
- changed
|
||||
- failure
|
||||
|
||||
depends_on:
|
||||
- latest-manifest
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- master
|
||||
event:
|
||||
- cron
|
||||
- push
|
||||
repo:
|
||||
- volker.raschek/db-wait
|
||||
|
@ -1,4 +1,6 @@
|
||||
FROM docker.io/library/golang:1.17-alpine3.14 AS build
|
||||
FROM docker.io/library/golang:1.17-alpine3.13 AS build
|
||||
|
||||
ARG VERSION=latest
|
||||
|
||||
COPY . /workspace
|
||||
|
||||
@ -7,9 +9,9 @@ WORKDIR /workspace
|
||||
RUN set -ex && \
|
||||
apk update && \
|
||||
apk add git make && \
|
||||
make install DESTDIR=/db-wait PREFIX=/usr
|
||||
make install VERSION=${VERSION} DESTDIR=/db-wait PREFIX=/usr
|
||||
|
||||
FROM docker.io/library/alpine:3.14.2
|
||||
FROM docker.io/library/alpine:3.14
|
||||
|
||||
COPY --from=build /db-wait /
|
||||
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
_ "github.com/lib/pq"
|
||||
_ "github.com/sijms/go-ora"
|
||||
_ "github.com/sijms/go-ora/v2"
|
||||
)
|
||||
|
||||
func Execute(version string) error {
|
||||
|
7
go.mod
7
go.mod
@ -3,9 +3,12 @@ module git.cryptic.systems/volker.raschek/db-wait
|
||||
go 1.17
|
||||
|
||||
require (
|
||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
||||
github.com/lib/pq v1.10.3
|
||||
github.com/sijms/go-ora v1.2.1
|
||||
github.com/sijms/go-ora/v2 v2.2.14
|
||||
github.com/spf13/cobra v1.2.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/inconshreveable/mousetrap v1.0.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
)
|
||||
|
4
go.sum
4
go.sum
@ -200,8 +200,8 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
|
||||
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sijms/go-ora v1.2.1 h1:+Vh95Lyv1+AltE74Ru9fvpJx/X1Y7hvw9OriuxPqLbU=
|
||||
github.com/sijms/go-ora v1.2.1/go.mod h1:ZGVmJgxUfyGIVmYgA7MVGEq6BX5aoFECRMtHW5DEcs4=
|
||||
github.com/sijms/go-ora/v2 v2.2.14 h1:Hwwyz6CfYju1HAa+bRfeSYlct66XPdBvjTQfqFyZ/2w=
|
||||
github.com/sijms/go-ora/v2 v2.2.14/go.mod h1:jzfAFD+4CXHE+LjGWFl6cPrtiIpQVxakI2gvrMF2w6Y=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
|
||||
|
@ -13,8 +13,8 @@ manifests:
|
||||
architecture: amd64
|
||||
os: linux
|
||||
-
|
||||
image: volkerraschek/db-wait:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{else}}latest{{/if}}-arm64
|
||||
image: volkerraschek/db-wait:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{else}}latest{{/if}}-arm-v7
|
||||
platform:
|
||||
architecture: arm64
|
||||
architecture: arm
|
||||
os: linux
|
||||
variant: v8
|
||||
variant: v7
|
@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -44,16 +45,35 @@ LOOP:
|
||||
|
||||
switch databaseURL.Scheme {
|
||||
case "oracle":
|
||||
_, err := sqlDB.QueryContext(queryCtx, "SELECT 1 FROM dual")
|
||||
row := sqlDB.QueryRowContext(queryCtx, "SELECT INSTANCE_NAME, STATUS, DATABASE_STATUS FROM V$INSTANCE WHERE INSTANCE_NAME=$1", databaseURL.Path)
|
||||
|
||||
var instaceName string
|
||||
var instanceStatus string
|
||||
var databaseStatus string
|
||||
|
||||
err := row.Scan(instaceName, instanceStatus, databaseStatus)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%s: %s\n", time.Now().String(), err.Error())
|
||||
ticker.Reset(period)
|
||||
continue LOOP
|
||||
}
|
||||
|
||||
if strings.ToUpper(instanceStatus) != "OPEN" {
|
||||
fmt.Fprintf(os.Stderr, "%s: Instance status is not open: %s\n", time.Now().String(), instanceStatus)
|
||||
ticker.Reset(period)
|
||||
continue LOOP
|
||||
}
|
||||
|
||||
if strings.ToUpper(databaseStatus) != "OPEN" {
|
||||
fmt.Fprintf(os.Stderr, "%s: Database status is not active: %s\n", time.Now().String(), databaseStatus)
|
||||
ticker.Reset(period)
|
||||
continue LOOP
|
||||
}
|
||||
|
||||
return nil
|
||||
case "postgres":
|
||||
_, err := sqlDB.QueryContext(queryCtx, "SELECT 1 AS ROW")
|
||||
if err != nil {
|
||||
row := sqlDB.QueryRowContext(queryCtx, "SELECT 1 AS ROW")
|
||||
if row.Err() != nil {
|
||||
fmt.Fprintf(os.Stderr, "%s: %s\n", time.Now().String(), err.Error())
|
||||
ticker.Reset(period)
|
||||
continue LOOP
|
||||
|
11
renovate.json
Normal file
11
renovate.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"automerge": false,
|
||||
"automergeStrategy": "merge-commit",
|
||||
"automergeType": "pr",
|
||||
"rebaseLabel": "renovate/rebase",
|
||||
"rebaseWhen": "behind-base-branch",
|
||||
"postUpdateOptions": [
|
||||
"gomodTidy"
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user