contrib/kube-prometheus: Introduce a withImageRepository mixin

This mixin replaces all images prefixes by $repository to generate manifests
that will point to an internal registry.
This commit is contained in:
Damien Lespiau
2018-10-01 17:42:07 +01:00
parent 466cbe50b0
commit 253abe0f96

View File

@@ -0,0 +1,20 @@
local l = import 'lib/lib.libsonnet';
// withImageRepository is a mixin that replaces all images prefixes by repository. eg.
// quay.io/coreos/addon-resizer -> $repository/addon-resizer
// grafana/grafana -> grafana $repository/grafana
local withImageRepository(repository) = {
local oldRepos = super._config.imageRepos,
local substituteRepository(image, repository) =
if repository == null then image else repository + '/' + l.imageName(image),
_config+:: {
imageRepos:: {
[field]: substituteRepository(oldRepos[field], repository),
for field in std.objectFields(oldRepos)
}
},
};
{
withImageRepository:: withImageRepository,
}