17 Commits

Author SHA1 Message Date
e96001f2a0 Merge pull request 'chore(deps): update docker.io/library/alpine docker tag to v3.14' (#4) from renovate/docker.io-library-alpine-3.x into master
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #4
2021-10-30 10:07:57 +00:00
68c07b6a81 chore(deps): update docker.io/library/alpine docker tag to v3.14
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2021-10-30 12:00:19 +02:00
e44cbaeed3 fix: rebase label
All checks were successful
continuous-integration/drone/push Build is passing
2021-10-30 11:58:49 +02:00
655c5b0329 chore(deps): update module github.com/sijms/go-ora/v2 to v2.2.14
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing
2021-10-30 10:12:16 +02:00
62df6f7955 fix: upgrade to sijms/go-ora/v2 v2.2.13
Some checks failed
continuous-integration/drone/push Build is failing
2021-10-28 22:42:08 +02:00
1e3a25c202 fix(renovate): disable automerge
Some checks failed
continuous-integration/drone/push Build is failing
2021-10-28 17:27:16 +00:00
f4740434c6 Revert "chore(deps): update module github.com/sijms/go-ora/v2 to v2.2.12"
Some checks failed
continuous-integration/drone/push Build is failing
This reverts commit 6c6bfd8c6d.
2021-10-28 10:11:29 +02:00
47d8e2222a fix(ci): remove repo scope in dry_run
Some checks failed
continuous-integration/drone/push Build is failing
2021-10-28 10:08:03 +02:00
a7a8703d7f fix: downgrade alpine image
Some checks failed
continuous-integration/drone/push Build is failing
2021-10-28 09:58:14 +02:00
8dd6bc21fb fix(ci): dry_run
Some checks failed
continuous-integration/drone/push Build is failing
2021-10-28 09:55:48 +02:00
6c6bfd8c6d chore(deps): update module github.com/sijms/go-ora/v2 to v2.2.12
Some checks failed
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is failing
2021-10-27 21:20:54 +02:00
d53bf5fafe chore(deps): update module github.com/sijms/go-ora to v2
Some checks failed
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is failing
2021-10-24 18:06:21 +02:00
9b37cc1966 fix(ci): add renovate config
Some checks reported errors
continuous-integration/drone/push Build was killed
2021-10-24 18:01:36 +02:00
7a0eaa6764 fix(ci): adapt .drone.yml to latest version
All checks were successful
continuous-integration/drone/push Build is passing
2021-10-24 13:16:15 +02:00
760c55f48e fix(oracle): check via v$instance
All checks were successful
continuous-integration/drone/push Build is passing
2021-09-22 11:27:48 +02:00
081f147657 fix(ci): build images only for repo volker.raschek/db-wait
All checks were successful
continuous-integration/drone/push Build is passing
2021-09-22 11:25:36 +02:00
7afd418bb8 fix(ci): sync only for master branch
Some checks reported errors
continuous-integration/drone/push Build was killed
2021-09-22 11:21:43 +02:00
8 changed files with 526 additions and 31 deletions

View File

@ -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

View File

@ -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 /

View File

@ -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
View File

@ -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
View File

@ -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=

View File

@ -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

View File

@ -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
View 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"
]
}