blob: 929c6f213bf98f886fdb80aa4dbb035c47aa53db [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 Bazanski5a89d222020-08-22 18:57:30 +000020 # Add .Contain method to Namespaces, allowing for easy marking of particular
21 # kube objects as contained in that namespace.
22 Namespace(name): kube.Namespace(name) {
23 Contain(o):: o {
24 metadata+: {
25 namespace: name,
26 },
27 },
28 },
29
Sergiusz Bazanski114edc22020-02-18 22:54:18 +010030 CephObjectStoreUser(name): kube._Object("ceph.rook.io/v1", "CephObjectStoreUser", name) {
31 local user = self,
32 spec: error "spec must be defined",
33
34 // Name of the secret that contains the login data for this user.
35 // This secret is created in the same namespace as the ceph cluster, so
36 // unfortunately you can't really refer to it directly.
37 // We should write some automation to copy these secrets over in a
38 // secure way.
39 secret_name:: "rook-ceph-object-user-%s-%s" % [user.spec.store, user.spec.displayName],
40 },
Sergiusz Bazanskid436de22020-02-21 17:10:42 +010041
42 // Make OpenAPI v3 schema specification less painful.
43 OpenAPI:: {
44 Validation(obj):: {
45 openAPIV3Schema: obj.render,
46 },
47
Serge Bazanski0b6d5d52020-08-22 18:59:17 +000048 Required(inner):: inner {
49 required:: true,
50 },
51
Sergiusz Bazanskid436de22020-02-21 17:10:42 +010052 Dict:: {
53 local dict = self,
54 required:: false,
55
56 local requiredList = [
57 k for k in std.filter(function(k) dict[k].required, std.objectFields(dict))
58 ],
59
60 render:: {
61 properties: {
62 [k]: dict[k].render
63 for k in std.objectFields(dict)
64 },
65 } + (if std.length(requiredList) > 0 then {
66 required: requiredList,
67 } else {}),
68 },
69
70 Array(items):: {
71 required:: false,
72 render:: {
73 type: "array",
74 items: items.render,
75 },
76 },
77
78 Integer:: {
79 local integer = self,
80 required:: false,
81 render:: {
82 type: "integer",
83 } + (if integer.minimum != null then {
84 minimum: integer.minimum,
85 } else {}) + (if integer.maximum != null then {
86 maximum: integer.maximum,
87 } else {}),
88
89 minimum:: null,
90 maximum:: null,
91 },
92
93 String:: {
94 local string = self,
95 required:: false,
96 render:: {
97 type: "string",
98 } + (if string.pattern != null then {
99 pattern: string.pattern,
100 } else {}),
101
102 pattern:: null,
103 },
104
105 Boolean:: {
106 required:: false,
107 render:: {
108 type: "boolean",
109 },
110 },
111
112 Any:: {
113 required:: false,
114 render:: {},
115 },
116 },
Sergiusz Bazanski4d9e72c2019-01-13 22:06:33 +0100117}