Skip to content

Commit

Permalink
update: source github.com/jsonnet-libs/k8s@c69bea2f
Browse files Browse the repository at this point in the history
  • Loading branch information
obliadp authored and jsonnet-libs-bot committed Dec 5, 2023
1 parent 44a9f3d commit 3e32f80
Show file tree
Hide file tree
Showing 1,077 changed files with 111,866 additions and 2 deletions.
84 changes: 84 additions & 0 deletions 1.28/_custom/apps.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
local d = import 'doc-util/main.libsonnet';
local gen = import '../gen.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 {}
),
},
};

{
[if std.objectHas(gen, 'extensions') then 'extensions']+: { // This was removed in v1.22
[if std.objectHas(gen.extensions, 'v1beta1') then 'v1beta1']+: patch,
},
apps+: {
v1+: patch,
v1beta1+: patch,
v1beta2+: patch,
},
}
33 changes: 33 additions & 0 deletions 1.28/_custom/autoscaling.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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,
v2beta1+: patch,
v2beta2+: patch,
},
}
28 changes: 28 additions & 0 deletions 1.28/_custom/batch.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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,
v1beta1+: patch,
v2alpha1+: patch,
},
}
Loading

0 comments on commit 3e32f80

Please sign in to comment.