feat: make images overideable

BREAKING CHANGE:
This commit is contained in:
Giles Bradshaw 2020-08-28 12:22:28 +01:00
parent 3055b928e9
commit dca47ea050
4 changed files with 47 additions and 42 deletions

View File

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

View File

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

View File

@ -1,12 +1,12 @@
local settings = import 'settings.libsonnet';
{
docker: {
docker(overide): {
name: 'docker',
image: 'docker:dind',
},
scp(target): settings.ssh {
image: 'docker:19.03.12-dind@sha256:8dded163e463f4a59bf305b3dca98e312b2cfb89a43da3872e48f95a7554c48f',
} + overide,
scp(overide): function(target) settings.ssh {
name: 'scp',
image: 'appleboy/drone-scp:1.6.2',
image: 'appleboy/drone-scp:1.6.2@sha256:bd37a55f4b97e7742b0de7333669b96220b3cc422d366e1fa8c34059b736ab47',
settings +: {
command_timeout: '2m',
target: target,
@ -14,9 +14,9 @@ local settings = import 'settings.libsonnet';
'.',
],
},
},
ssh: settings.ssh {
image: 'appleboy/drone-ssh:1.6.2',
} + overide,
ssh(overide): settings.ssh {
image: 'appleboy/drone-ssh:1.6.2@sha256:b801dc2cd238c192b6e99acfa7bc3f5b9a03f312bd2feb1e10b3a7a28a1b80ea',
settings +: {
envs: [
'drone_tag',
@ -27,12 +27,12 @@ local settings = import 'settings.libsonnet';
],
script: [],
},
},
wait(delay): {
image: 'alpine',
} + overide,
wait(overide): function(delay) {
image: 'alpine:3.12.0@sha256:90baa0922fe90624b05cb5766fa5da4e337921656c2f8e2b13bd3c052a0baac1',
name: 'wait',
commands: [
'sleep %s' % delay,
],
}
} + overide
}

View File

@ -2,10 +2,11 @@ local environment = import 'node_modules/@sigyl/jsonnet-drone-environment/enviro
{
ssh: {
settings +: {
host: environment.fromSecret('ssh-host'),
port: environment.fromSecret('ssh-port'),
username: environment.fromSecret('ssh-user'),
key: environment.fromSecret('ssh-key'),
host: '${SSH_HOST}',
username: '${SSH_USER}',
key: '${SSH_KEY}',
port: '${SSH_PORT}',
passphrase: '${SSH_PASSPHRASE}',
},
},
}