feat: configured

BREAKING CHANGE: new api config function
This commit is contained in:
Giles 2020-09-23 19:58:49 +01:00
parent ebd87a2e0e
commit 527aa4128d
3 changed files with 122 additions and 119 deletions

View File

@ -6,7 +6,9 @@ local util = import 'lib/util.libsonnet';
local overide = function(overides, name)
({ [name]: {}} + overides)[name];
function(
function(config)
function(
name,
root,
buildSecrets,
@ -14,7 +16,7 @@ function(
secretSecrets,
droneSecrets,
imageOverides = {},
)
)
{
kind: 'pipeline',
type: 'docker',
@ -24,7 +26,7 @@ function(
depth: 0,
},
services: [
images.docker(overide(imageOverides, 'docker')) {
images(config).docker(overide(imageOverides, 'docker')) {
privileged: true,
volumes: [
{
@ -60,7 +62,7 @@ function(
)
)
(
images.ssh(overide(imageOverides, 'ssh')) {
images(config).ssh(overide(imageOverides, 'ssh')) {
settings +: {
script +: [
'rm -f env-%s' % name,
@ -70,18 +72,18 @@ function(
) {
name: 'print env',
},
images.scp(overide(imageOverides, 'scp'))(
images(config).scp(overide(imageOverides, 'scp'))(
'%(root)s%(name)s' % { root: root, name: name }
),
images.wait(overide(imageOverides, 'alpine'))(15),
build(overide(imageOverides, 'docker'))(buildSecrets),
images(config).wait(overide(imageOverides, 'alpine'))(15),
build(config)(overide(imageOverides, 'docker'))(buildSecrets),
compose(
std.map(
function(secret) environment.envSet(secret),
publicSecrets + secretSecrets + buildSecrets,
),
)(
images.ssh(overide(imageOverides, 'ssh')) {
images(config).ssh(overide(imageOverides, 'ssh')) {
name: 'deploy',
settings +: {
envs +: std.map(

View File

@ -1,9 +1,10 @@
local images = import 'images.libsonnet';
local environment = import 'node_modules/@sigyl/jsonnet-drone-environment/environment.libsonnet';
function(overide)
function(config)
function(overide)
function(secrets)
images.docker(overide) {
images(config).docker(overide) {
name +: 'build:',
environment +: environment.environmentSecrets(secrets),
volumes: [

View File

@ -1,11 +1,11 @@
{
function(config) {
docker(overide): {
name: 'docker',
image: 'docker:19.03.12-dind@sha256:8dded163e463f4a59bf305b3dca98e312b2cfb89a43da3872e48f95a7554c48f',
image: '%(registry)sdocker:19.03.12-dind@sha256:8dded163e463f4a59bf305b3dca98e312b2cfb89a43da3872e48f95a7554c48f' % config,
} + overide,
scp(overide): function(target) {
name: 'scp',
image: 'appleboy/drone-scp:1.6.2@sha256:bd37a55f4b97e7742b0de7333669b96220b3cc422d366e1fa8c34059b736ab47',
image: '%(registry)sappleboy/drone-scp:1.6.2@sha256:bd37a55f4b97e7742b0de7333669b96220b3cc422d366e1fa8c34059b736ab47' % config,
settings +: {
command_timeout: '2m',
target: target,
@ -15,7 +15,7 @@
},
} + overide,
ssh(overide): {
image: 'appleboy/drone-ssh:1.6.2@sha256:b801dc2cd238c192b6e99acfa7bc3f5b9a03f312bd2feb1e10b3a7a28a1b80ea',
image: '%(registry)sappleboy/drone-ssh:1.6.2@sha256:b801dc2cd238c192b6e99acfa7bc3f5b9a03f312bd2feb1e10b3a7a28a1b80ea' % config,
settings +: {
envs: [
'drone_tag',
@ -28,7 +28,7 @@
},
} + overide,
wait(overide): function(delay) {
image: 'alpine:3.12.0@sha256:90baa0922fe90624b05cb5766fa5da4e337921656c2f8e2b13bd3c052a0baac1',
image: '%(registry)salpine:3.12.0@sha256:90baa0922fe90624b05cb5766fa5da4e337921656c2f8e2b13bd3c052a0baac1',
name: 'wait',
commands: [
'sleep %s' % delay,