Mostly working in k8s

This commit is contained in:
Cyber MacGeddon 2024-10-14 19:16:17 +01:00
parent 3b3809f7af
commit a880ca23a5

View file

@ -10,14 +10,28 @@
reservations: {}, reservations: {},
ports: [], ports: [],
volumes: [], volumes: [],
environment: {}, environment: [],
with_image:: function(x) self + { image: x }, with_image:: function(x) self + { image: x },
with_command:: function(x) self + { command: x }, with_command:: function(x) self + { command: x },
with_environment:: function(x) self + { with_environment:: function(x) self + {
environment: super.environment + x, environment: super.environment + [
{
name: v.key, value: v.value
}
for v in std.objectKeysValues(x)
],
},
with_environment_valueFrom:: function(x) self + {
environment: super.environment + [
{
name: v.key, value: v.value
}
for v in std.objectKeysValues(x)
],
}, },
with_limits:: function(c, m) self + { limits: { cpu: c, memory: m } }, with_limits:: function(c, m) self + { limits: { cpu: c, memory: m } },
@ -43,8 +57,17 @@
with_env_var_secrets:: with_env_var_secrets::
function(vars) function(vars)
std.foldl( std.foldl(
function(obj, x) obj.with_environment( function(obj, x) obj + obj.with_environment_valueFrom(
{ [x]: "${" + x + "}" } {
[x]: {
valueFrom: {
secretKeyRef: {
name: vars.name,
key: x,
}
}
}
}
), ),
vars.variables, vars.variables,
self self
@ -112,15 +135,9 @@
else {}) + else {}) +
(if ! std.isEmpty(container.environment) then (if ! std.isEmpty(container.environment) then
{ env: [ { {
name: e.key, value: e.value env: container.environment,
} }
for e in
std.objectKeysValues(
container.environment
)
]
}
else {}) + else {}) +
(if std.length(container.volumes) > 0 then (if std.length(container.volumes) > 0 then
@ -309,6 +326,7 @@
with_size:: function(size) self + { size: size }, with_size:: function(size) self + { size: size },
add:: function() [ add:: function() [
/*
{ {
apiVersion: "v1", apiVersion: "v1",
kind: "Secret", kind: "Secret",
@ -319,6 +337,7 @@
data: { data: {
} }
}, },
*/
], ],
volRef:: function() { volRef:: function() {