Skip to content

Commit

Permalink
update: source github.com/jsonnet-libs/k8s@294857ff
Browse files Browse the repository at this point in the history
  • Loading branch information
adinhodovic authored and jsonnet-libs-bot committed Mar 5, 2024
1 parent 90d0fae commit bf9a62c
Show file tree
Hide file tree
Showing 1,091 changed files with 112,226 additions and 2 deletions.
79 changes: 79 additions & 0 deletions 1.29/_custom/apps.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
local gen = import '../gen.libsonnet';
local d = import 'doc-util/main.libsonnet';

local patch = {
daemonSet+: {
'#new'+: d.func.withArgs([
d.arg('name', d.T.string),
d.arg('containers', d.T.array),
d.arg('podLabels', d.T.object, {}),
]),
new(
name,
containers=[],
podLabels={}
)::
local labels = { name: name } + podLabels;
super.new(name)
+ super.spec.template.spec.withContainers(containers)
+ super.spec.template.metadata.withLabels(labels)
+ super.spec.selector.withMatchLabels(labels),
},
deployment+: {
'#new'+: d.func.withArgs([
d.arg('name', d.T.string),
d.arg('replicas', d.T.int, 1),
d.arg('containers', d.T.array),
d.arg('podLabels', d.T.object, {}),
]),
new(
name,
replicas=1,
containers=error 'containers unset',
podLabels={},
)::
local labels = { name: name } + podLabels;
super.new(name)
+ (if replicas == null then {} else super.spec.withReplicas(replicas))
+ super.spec.template.spec.withContainers(containers)
+ super.spec.template.metadata.withLabels(labels)
+ super.spec.selector.withMatchLabels(labels),
},

statefulSet+: {
'#new'+: d.func.withArgs([
d.arg('name', d.T.string),
d.arg('replicas', d.T.int, 1),
d.arg('containers', d.T.array),
d.arg('volumeClaims', d.T.array, []),
d.arg('podLabels', d.T.object, {}),
]),
new(
name,
replicas=1,
containers=error 'containers unset',
volumeClaims=[],
podLabels={},
)::
local labels = { name: name } + podLabels;
super.new(name)
+ super.spec.withReplicas(replicas)
+ super.spec.template.spec.withContainers(containers)
+ super.spec.template.metadata.withLabels(labels)
+ super.spec.selector.withMatchLabels(labels)

// remove volumeClaimTemplates if empty
// (otherwise it will create a diff all the time)
+ (
if std.length(volumeClaims) > 0
then super.spec.withVolumeClaimTemplates(volumeClaims)
else {}
),
},
};

{
apps+: {
v1+: patch,
},
}
31 changes: 31 additions & 0 deletions 1.29/_custom/autoscaling.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
local d = import 'doc-util/main.libsonnet';

local withApiVersion = {
'#withApiVersion':: d.fn(help='API version of the referent', args=[d.arg(name='apiversion', type=d.T.string)]),
withApiVersion(apiversion): { apiVersion: apiversion },
};


local withScaleTargetRef = {
'#withScaleTargetRef':: d.fn(help='Set spec.ScaleTargetRef to `object`', args=[d.arg(name='object', type=d.T.object)]),
withScaleTargetRef(object):
{ spec+: { scaleTargetRef+: {
apiVersion: object.apiVersion,
kind: object.kind,
name: object.metadata.name,
} } },
};

local patch = {
crossVersionObjectReference+: withApiVersion,
horizontalPodAutoscaler+: {
spec+: withScaleTargetRef,
},
};

{
autoscaling+: {
v1+: patch,
v2+: patch,
},
}
26 changes: 26 additions & 0 deletions 1.29/_custom/batch.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
local d = import 'doc-util/main.libsonnet';

local patch = {
cronJob+: {
'#new'+: d.func.withArgs([
d.arg('name', d.T.string),
d.arg('schedule', d.T.string),
d.arg('containers', d.T.array),
]),
new(
name,
schedule='',
containers=[]
)::
super.new(name)
+ super.spec.withSchedule(schedule)
+ super.spec.jobTemplate.spec.template.spec.withContainers(containers)
+ super.spec.jobTemplate.spec.template.metadata.withLabels({ name: name }),
},
};

{
batch+: {
v1+: patch,
},
}
Loading

0 comments on commit bf9a62c

Please sign in to comment.