aboutsummaryrefslogtreecommitdiff
path: root/deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_custom
diff options
context:
space:
mode:
Diffstat (limited to 'deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_custom')
-rw-r--r--deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_custom/apps.libsonnet83
-rw-r--r--deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_custom/batch.libsonnet27
-rw-r--r--deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_custom/core.libsonnet214
-rw-r--r--deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_custom/list.libsonnet27
-rw-r--r--deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_custom/mapContainers.libsonnet74
-rw-r--r--deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_custom/rbac.libsonnet43
6 files changed, 468 insertions, 0 deletions
diff --git a/deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_custom/apps.libsonnet b/deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_custom/apps.libsonnet
new file mode 100644
index 0000000..2b5b681
--- /dev/null
+++ b/deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_custom/apps.libsonnet
@@ -0,0 +1,83 @@
+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 = podLabels { name: name };
+ 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 = podLabels { name: name };
+ super.new(name)
+ + 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 = podLabels { name: name };
+ 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 {}
+ ),
+ },
+};
+
+{
+ extensions+: { // old, remove asap
+ v1beta1+: patch,
+ },
+ apps+: {
+ v1+: patch,
+ v1beta1+: patch,
+ v1beta2+: patch,
+ },
+}
diff --git a/deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_custom/batch.libsonnet b/deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_custom/batch.libsonnet
new file mode 100644
index 0000000..c4ccdfc
--- /dev/null
+++ b/deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_custom/batch.libsonnet
@@ -0,0 +1,27 @@
+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+: {
+ v1beta1+: patch,
+ v2alpha1+: patch,
+ },
+}
diff --git a/deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_custom/core.libsonnet b/deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_custom/core.libsonnet
new file mode 100644
index 0000000..b342d37
--- /dev/null
+++ b/deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_custom/core.libsonnet
@@ -0,0 +1,214 @@
+local d = import 'doc-util/main.libsonnet';
+
+{
+ core+: {
+ v1+: {
+ configMap+: {
+ local withData(data) = if data != {} then super.withData(data) else {},
+ withData:: withData,
+
+ local withDataMixin(data) = if data != {} then super.withDataMixin(data) else {},
+ withDataMixin:: withDataMixin,
+
+ '#new': d.fn('new creates a new `ConfigMap` of given `name` and `data`', [d.arg('name', d.T.string), d.arg('data', d.T.object)]),
+ new(name, data={})::
+ super.new(name)
+ + super.metadata.withName(name)
+ + withData(data),
+ },
+
+ container+: {
+ '#new': d.fn('new returns a new `container` of given `name` and `image`', [d.arg('name', d.T.string), d.arg('image', d.T.string)]),
+ new(name, image):: super.withName(name) + super.withImage(image),
+
+ withEnvMixin(env)::
+ // if an envvar has an empty value ("") we want to remove that property
+ // because k8s will remove that and then it would always
+ // show up as a difference.
+ local removeEmptyValue(obj) =
+ if std.objectHas(obj, 'value') && std.length(obj.value) == 0 then
+ {
+ [k]: obj[k]
+ for k in std.objectFields(obj)
+ if k != 'value'
+ }
+ else
+ obj;
+ super.withEnvMixin([
+ removeEmptyValue(envvar)
+ for envvar in env
+ ]),
+
+ '#withEnvMap': d.fn(
+ '`withEnvMap` works like `withEnvMixin` but accepts a key/value map, this map is converted a list of core.v1.envVar(key, value)`',
+ [d.arg('env', d.T.object)]
+ ),
+ withEnvMap(env)::
+ self.withEnvMixin([
+ $.core.v1.envVar.new(k, env[k])
+ for k in std.objectFields(env)
+ ]),
+ },
+
+ containerPort+: {
+ // using a local here to re-use new, because it is lexically scoped,
+ // while `self` is not
+ local new(containerPort) = super.withContainerPort(containerPort),
+ local newNamed(containerPort, name) = new(containerPort) + super.withName(name),
+ '#new': d.fn('new returns a new `containerPort`', [d.arg('containerPort', d.T.int)]),
+ new:: new,
+ '#newNamed': d.fn('newNamed works like `new`, but also sets the `name`', [d.arg('containerPort', d.T.int), d.arg('name', d.T.string)]),
+ newNamed:: newNamed,
+ '#newUDP': d.fn('newUDP works like `new`, but also sets protocal to UDP', [d.arg('containerPort', d.T.int)]),
+ newUDP(containerPort):: new(containerPort) + super.withProtocol('UDP'),
+ '#newNamedUDP': d.fn('newNamedUDP works like `newNamed`, but also sets protocal to UDP', [d.arg('containerPort', d.T.int), d.arg('name', d.T.string)]),
+ newNamedUDP(containerPort, name):: newNamed(containerPort, name) + super.withProtocol('UDP'),
+ },
+
+ envVar+: {
+ '#new': d.fn('new returns a new `envVar` of given `name` and `value`', [d.arg('name', d.T.string), d.arg('value', d.T.string)]),
+ new(name, value):: super.withName(name) + super.withValue(value),
+
+ '#fromSecretRef': d.fn('fromSecretRef creates a `envVar` from a secret reference', [
+ d.arg('name', d.T.string),
+ d.arg('secretRefName', d.T.string),
+ d.arg('secretRefKey', d.T.string),
+ ]),
+ fromSecretRef(name, secretRefName, secretRefKey)::
+ super.withName(name)
+ + super.valueFrom.secretKeyRef.withName(secretRefName)
+ + super.valueFrom.secretKeyRef.withKey(secretRefKey),
+
+ '#fromFieldPath': d.fn('fromFieldPath creates a `envVar` from a field path', [
+ d.arg('name', d.T.string),
+ d.arg('fieldPath', d.T.string),
+ ]),
+ fromFieldPath(name, fieldPath)::
+ super.withName(name)
+ + super.valueFrom.fieldRef.withFieldPath(fieldPath),
+ },
+
+ keyToPath+:: {
+ '#new': d.fn('new creates a new `keyToPath`', [d.arg('key', d.T.string), d.arg('path', d.T.string)]),
+ new(key, path):: super.withKey(key) + super.withPath(path),
+ },
+
+ persistentVolume+: {
+ '#new':: d.fn(help='new returns an instance of Persistentvolume', args=[d.arg(name='name', type=d.T.string)]),
+ new(name=''): {
+ apiVersion: 'v1',
+ kind: 'PersistentVolume',
+ } + (
+ if name != ''
+ then self.metadata.withName(name=name)
+ else {}
+ ),
+ },
+
+ secret+:: {
+ '#new'+: d.func.withArgs([
+ d.arg('name', d.T.string),
+ d.arg('data', d.T.object),
+ d.arg('type', d.T.string, 'Opaque'),
+ ]),
+ new(name, data, type='Opaque')::
+ super.new(name)
+ + super.withData(data)
+ + super.withType(type),
+ },
+
+ service+:: {
+ '#new'+: d.func.withArgs([
+ d.arg('name', d.T.string),
+ d.arg('selector', d.T.object),
+ d.arg('ports', d.T.array),
+ ]),
+ new(name, selector, ports)::
+ super.new(name)
+ + super.spec.withSelector(selector)
+ + super.spec.withPorts(ports),
+ },
+
+ servicePort+:: {
+ local new(port, targetPort) = super.withPort(port) + super.withTargetPort(targetPort),
+ '#new': d.fn('new returns a new `servicePort`', [
+ d.arg('port', d.T.int),
+ d.arg('targetPort', d.T.any),
+ ]),
+ new:: new,
+
+ '#newNamed': d.fn('newNamed works like `new`, but also sets the `name`', [
+ d.arg('name', d.T.string),
+ d.arg('port', d.T.int),
+ d.arg('targetPort', d.T.any),
+ ]),
+ newNamed(name, port, targetPort)::
+ new(port, targetPort) + super.withName(name),
+ },
+
+ volume+:: {
+ '#fromConfigMap': d.fn('Creates a new volume from a `ConfigMap`', [
+ d.arg('name', d.T.string),
+ d.arg('configMapName', d.T.string),
+ d.arg('configMapItems', d.T.array),
+ ]),
+ fromConfigMap(name, configMapName, configMapItems=[])::
+ super.withName(name)
+ + super.configMap.withName(configMapName)
+ + (
+ if configMapItems != []
+ then super.configMap.withItems(configMapItems)
+ else {}
+ ),
+
+ '#fromEmptyDir': d.fn('Creates a new volume of type `emptyDir`', [
+ d.arg('name', d.T.string),
+ d.arg('emptyDir', d.T.object, {}),
+ ]),
+ fromEmptyDir(name, emptyDir={})::
+ super.withName(name) + { emptyDir: emptyDir },
+
+ '#fromPersistentVolumeClaim': d.fn('Creates a new volume using a `PersistentVolumeClaim`.', [
+ d.arg('name', d.T.string),
+ d.arg('claimName', d.T.string),
+ ]),
+ fromPersistentVolumeClaim(name, claimName='', emptyDir='')::
+ // Note: emptyDir is inherited from ksonnet-lib, this provides backwards compatibility
+ local claim =
+ if (claimName == '' && emptyDir != '')
+ then emptyDir
+ else
+ if claimName == ''
+ then error 'claimName not set'
+ else claimName;
+ super.withName(name) + super.persistentVolumeClaim.withClaimName(claim),
+
+ '#fromHostPath': d.fn('Creates a new volume using a `hostPath`', [
+ d.arg('name', d.T.string),
+ d.arg('hostPath', d.T.string),
+ ]),
+ fromHostPath(name, hostPath)::
+ super.withName(name) + super.hostPath.withPath(hostPath),
+
+ '#fromSecret': d.fn('Creates a new volume from a `Secret`', [
+ d.arg('name', d.T.string),
+ d.arg('secretName', d.T.string),
+ ]),
+ fromSecret(name, secretName)::
+ super.withName(name) + super.secret.withSecretName(secretName),
+ },
+
+ volumeMount+:: {
+ '#new': d.fn('new creates a new `volumeMount`', [
+ d.arg('name', d.T.string),
+ d.arg('mountPath', d.T.string),
+ d.arg('readOnly', d.T.bool),
+ ]),
+ new(name, mountPath, readOnly=false)::
+ super.withName(name)
+ + super.withMountPath(mountPath)
+ + (if readOnly then self.withReadOnly(readOnly) else {}),
+ },
+ },
+ },
+}
diff --git a/deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_custom/list.libsonnet b/deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_custom/list.libsonnet
new file mode 100644
index 0000000..44a151c
--- /dev/null
+++ b/deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_custom/list.libsonnet
@@ -0,0 +1,27 @@
+local d = import 'doc-util/main.libsonnet';
+
+{
+ core+: {
+ v1+: {
+ list: {
+ '#':: d.pkg(name='list', url='', help='List represents a generic list of items.'),
+ '#new': d.fn(
+ '`new` returns an instance of List.',
+ [d.arg('items', d.T.array)]
+ ),
+ new(items):: {
+ apiVersion: 'v1',
+ kind: 'List',
+ } + self.withItems(items),
+ '#withItems': d.fn(
+ '`withItems` List of items to populate the items in a list.',
+ [d.arg('items', d.T.array)]
+ ),
+ withItems(items)::
+ if std.isArray(v=items)
+ then { items+: items }
+ else { items+: [items] },
+ },
+ },
+ },
+}
diff --git a/deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_custom/mapContainers.libsonnet b/deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_custom/mapContainers.libsonnet
new file mode 100644
index 0000000..66d4e44
--- /dev/null
+++ b/deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_custom/mapContainers.libsonnet
@@ -0,0 +1,74 @@
+local d = import 'doc-util/main.libsonnet';
+
+local patch = {
+ '#mapContainers': d.fn(
+ |||
+ `mapContainers` applies the function f to each container.
+ It works exactly as `std.map`, but on the containers of this object.
+
+ **Signature of `f`**:
+ ```ts
+ f(container: Object) Object
+ ```
+ |||,
+ [d.arg('f', d.T.func)]
+ ),
+ mapContainers(f):: {
+ local podContainers = super.spec.template.spec.containers,
+ spec+: {
+ template+: {
+ spec+: {
+ containers: std.map(f, podContainers),
+ },
+ },
+ },
+ },
+
+ '#mapContainersWithName': d.fn('`mapContainersWithName` is like `mapContainers`, but only applies to those containers in the `names` array',
+ [d.arg('names', d.T.array), d.arg('f', d.T.func)]),
+ mapContainersWithName(names, f)::
+ local nameSet = if std.type(names) == 'array' then std.set(names) else std.set([names]);
+ local inNameSet(name) = std.length(std.setInter(nameSet, std.set([name]))) > 0;
+
+ self.mapContainers(function(c) if std.objectHas(c, 'name') && inNameSet(c.name) then f(c) else c),
+};
+
+// batch.job and batch.cronJob have the podSpec at a different location
+local cronPatch = patch {
+ mapContainers(f):: {
+ local podContainers = super.spec.jobTemplate.spec.template.spec.containers,
+ spec+: {
+ jobTemplate+: {
+ spec+: {
+ template+: {
+ spec+: {
+ containers: std.map(f, podContainers),
+ },
+ },
+ },
+ },
+ },
+ },
+};
+
+{
+ core+: { v1+: {
+ pod+: patch,
+ podTemplate+: patch,
+ replicationController+: patch,
+ } },
+ batch+: {
+ v1+: {
+ job+: patch,
+ },
+ v1beta1+: {
+ cronJob+: cronPatch,
+ },
+ },
+ apps+: { v1+: {
+ daemonSet+: patch,
+ deployment+: patch,
+ replicaSet+: patch,
+ statefulSet+: patch,
+ } },
+}
diff --git a/deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_custom/rbac.libsonnet b/deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_custom/rbac.libsonnet
new file mode 100644
index 0000000..69327fb
--- /dev/null
+++ b/deploy/vendor/github.com/jsonnet-libs/k8s-alpha/1.19/_custom/rbac.libsonnet
@@ -0,0 +1,43 @@
+local d = import 'doc-util/main.libsonnet';
+
+local bindRoleDoc = d.fn(
+ '`bindRole` returns a roleRef for a Role or ClusterRole object.',
+ [d.arg('role', d.T.object)]
+);
+
+local bindRole(role) = {
+ roleRef: {
+ name: role.metadata.name,
+ kind: role.kind,
+ apiGroup: std.split(role.apiVersion, '/')[0],
+ },
+};
+
+local patch = {
+ roleBinding+: {
+ '#bindRole': bindRoleDoc,
+ bindRole(role):: bindRole(role),
+ },
+ clusterRoleBinding+: {
+ '#bindRole': bindRoleDoc,
+ bindRole(role):: bindRole(role),
+ },
+ subject+: {
+ '#fromServiceAccount': d.fn(
+ '`fromServiceAccount` returns a subject for a service account.',
+ [d.arg('service_account', d.T.object)]
+ ),
+ fromServiceAccount(service_account)::
+ super.withKind('ServiceAccount') +
+ super.withName(service_account.metadata.name) +
+ super.withNamespace(service_account.metadata.namespace),
+ },
+};
+
+{
+ rbac+: {
+ v1+: patch,
+ v1alpha1+: patch,
+ v1beta1+: patch,
+ },
+}