forked from prometheus-operator/kube-prometheus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sync-to-internal-registry.jsonnet
29 lines (23 loc) · 867 Bytes
/
sync-to-internal-registry.jsonnet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
local l = import 'kube-prometheus/addons/config-mixins.libsonnet';
local kp = import 'kube-prometheus/main.libsonnet';
local config = kp.values.common;
local makeImages(config) = [
{
name: config.images[image],
}
for image in std.objectFields(config.images)
];
local upstreamImage(image) = '%s' % [image.name];
local downstreamImage(registry, image) = '%s/%s' % [registry, l.imageName(image.name)];
local pullPush(image, newRegistry) = [
'docker pull %s' % upstreamImage(image),
'docker tag %s %s' % [upstreamImage(image), downstreamImage(newRegistry, image)],
'docker push %s' % downstreamImage(newRegistry, image),
];
local images = makeImages(config);
local output(repository) = std.flattenArrays([
pullPush(image, repository)
for image in images
]);
function(repository='my-registry.com/repository')
std.join('\n', output(repository))