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

View File

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

View File

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