blob: 8d7254a5a9ecfbbc353b31e64efed1241af85030 [file] [log] [blame]
Sergiusz Bazanskie31d64f2019-10-02 20:59:26 +02001// Local extensions to kube.upstream.libsonnet.
Sergiusz Bazanski4d9e72c2019-01-13 22:06:33 +01002
Sergiusz Bazanskie31d64f2019-10-02 20:59:26 +02003local kube = import "kube.upstream.libsonnet";
Sergiusz Bazanski4d9e72c2019-01-13 22:06:33 +01004
Sergiusz Bazanskie31d64f2019-10-02 20:59:26 +02005kube {
6 ClusterIssuer(name): kube._Object("certmanager.k8s.io/v1alpha1", "ClusterIssuer", name) {
7 spec: error "spec must be defined",
Sergiusz Bazanski4d9e72c2019-01-13 22:06:33 +01008 },
Sergiusz Bazanskie31d64f2019-10-02 20:59:26 +02009 Issuer(name): kube._Object("certmanager.k8s.io/v1alpha1", "Issuer", name) {
10 spec: error "spec must be defined",
Sergiusz Bazanski4d9e72c2019-01-13 22:06:33 +010011 },
Sergiusz Bazanskie31d64f2019-10-02 20:59:26 +020012 Certificate(name): kube._Object("certmanager.k8s.io/v1alpha1", "Certificate", name) {
13 spec: error "spec must be defined",
Sergiusz Bazanski4d9e72c2019-01-13 22:06:33 +010014 },
Serge Bazanski394dd832020-08-22 18:56:53 +000015 # For use in PodSpec.volumes_
16 CertificateVolume(certificate): {
17 secret: { secretName: certificate.spec.secretName },
18 },
Sergiusz Bazanski114edc22020-02-18 22:54:18 +010019
Serge Bazanski41bbf142021-02-06 18:12:52 +000020 ValidatingWebhookConfiguration(name): kube._Object("admissionregistration.k8s.io/v1", "ValidatingWebhookConfiguration", name) {
21 webhooks_:: error "webhooks_ must be defined",
22 webhooks: kube.mapToNamedList(self.webhooks_),
23 },
24
Serge Bazanski5a89d222020-08-22 18:57:30 +000025 # Add .Contain method to Namespaces, allowing for easy marking of particular
26 # kube objects as contained in that namespace.
27 Namespace(name): kube.Namespace(name) {
28 Contain(o):: o {
29 metadata+: {
30 namespace: name,
31 },
32 },
33 },
34
Sergiusz Bazanski114edc22020-02-18 22:54:18 +010035 CephObjectStoreUser(name): kube._Object("ceph.rook.io/v1", "CephObjectStoreUser", name) {
36 local user = self,
37 spec: error "spec must be defined",
38
39 // Name of the secret that contains the login data for this user.
40 // This secret is created in the same namespace as the ceph cluster, so
41 // unfortunately you can't really refer to it directly.
42 // We should write some automation to copy these secrets over in a
43 // secure way.
44 secret_name:: "rook-ceph-object-user-%s-%s" % [user.spec.store, user.spec.displayName],
45 },
Sergiusz Bazanskid436de22020-02-21 17:10:42 +010046
47 // Make OpenAPI v3 schema specification less painful.
48 OpenAPI:: {
49 Validation(obj):: {
50 openAPIV3Schema: obj.render,
51 },
52
Serge Bazanski0b6d5d52020-08-22 18:59:17 +000053 Required(inner):: inner {
54 required:: true,
55 },
56
Sergiusz Bazanskid436de22020-02-21 17:10:42 +010057 Dict:: {
58 local dict = self,
59 required:: false,
60
61 local requiredList = [
62 k for k in std.filter(function(k) dict[k].required, std.objectFields(dict))
63 ],
64
65 render:: {
66 properties: {
67 [k]: dict[k].render
68 for k in std.objectFields(dict)
69 },
70 } + (if std.length(requiredList) > 0 then {
71 required: requiredList,
72 } else {}),
73 },
74
75 Array(items):: {
76 required:: false,
77 render:: {
78 type: "array",
79 items: items.render,
80 },
81 },
82
83 Integer:: {
84 local integer = self,
85 required:: false,
86 render:: {
87 type: "integer",
88 } + (if integer.minimum != null then {
89 minimum: integer.minimum,
90 } else {}) + (if integer.maximum != null then {
91 maximum: integer.maximum,
92 } else {}),
93
94 minimum:: null,
95 maximum:: null,
96 },
97
98 String:: {
99 local string = self,
100 required:: false,
101 render:: {
102 type: "string",
103 } + (if string.pattern != null then {
104 pattern: string.pattern,
105 } else {}),
106
107 pattern:: null,
108 },
109
110 Boolean:: {
111 required:: false,
112 render:: {
113 type: "boolean",
114 },
115 },
116
117 Any:: {
118 required:: false,
119 render:: {},
120 },
121 },
Sergiusz Bazanski4d9e72c2019-01-13 22:06:33 +0100122}