kube: standardize on a `local top = self` convention
A convention is introduced to specify `local top = self` declaration at the top of an app/service/component's jsonnet, representing the top-level object. Reasoning is as following:
- `top` is more universal/unambiguous than `app`
- `top` is usually shorter than $NAME
- a conventional `top` instead of $NAME (coupled with other conventions introduced) makes app jsonnets wonderfully copy-paste'able, aiding in learning and quickly building
Change-Id: I7ece83ce7e97021ad98a6abb3500fb9839936811
Reviewed-on: https://gerrit.hackerspace.pl/c/hscloud/+/1805
Reviewed-by: q3k <q3k@hackerspace.pl>
diff --git a/app/matrix/lib/matrix-ng.libsonnet b/app/matrix/lib/matrix-ng.libsonnet
index 620a8d5..44e97a9 100644
--- a/app/matrix/lib/matrix-ng.libsonnet
+++ b/app/matrix/lib/matrix-ng.libsonnet
@@ -98,8 +98,8 @@
local coturn = import "./coturn.libsonnet";
{
- local app = self,
- local cfg = app.cfg,
+ local top = self,
+ local cfg = top.cfg,
cfg:: {
namespace: error "cfg.namespace must be set",
# webDomain is the domain name at which element will run
@@ -336,16 +336,16 @@
synapse: synapse {
ns: ns,
- postgres: if cfg.postgres.enable then app.postgres3 else {
+ postgres: if cfg.postgres.enable then top.postgres3 else {
# If not using on-cluster postgres, pass the config postgres object
# as the postgres object into the synapse lib. It's a bit ugly (we
# should have some common 'config' type instead) but it's good
# enough.
cfg: cfg.postgres,
- }, redis: app.redis,
- appservices: app.appservices,
- cfg+: app.cfg {
- image: app.cfg.images.synapse,
+ }, redis: top.redis,
+ appservices: top.appservices,
+ cfg+: top.cfg {
+ image: top.cfg.images.synapse,
macaroonSecretKey: { secretKeyRef: { name: "synapse", key: "macaroon_secret_key" } },
registrationSharedSecret: { secretKeyRef: { name: "synapse", key: "registration_shared_secret" } },
@@ -361,7 +361,7 @@
// until it spits you a registration YAML and you feed that to a secret.
appservices: {},
- ingress: app.namespace.Contain(kube.Ingress("matrix")) {
+ ingress: top.namespace.Contain(kube.Ingress("matrix")) {
metadata+: {
annotations+: {
"kubernetes.io/tls-acme": "true",
@@ -382,19 +382,19 @@
host: cfg.webDomain,
http: {
paths: [
- { path: path, backend: app.synapse.genericWorker.svc.name_port }
- for path in app.synapse.genericWorker.paths
+ { path: path, backend: top.synapse.genericWorker.svc.name_port }
+ for path in top.synapse.genericWorker.paths
] + [
- { path: "/", backend: app.riot.svc.name_port },
- { path: "/_matrix/media/", backend: if cfg.mediaRepo.route then app.mediaRepo.svc.name_port else app.synapse.mediaWorker.svc.name_port },
- { path: "/_matrix/", backend: app.synapse.main.svc.name_port },
+ { path: "/", backend: top.riot.svc.name_port },
+ { path: "/_matrix/media/", backend: if cfg.mediaRepo.route then top.mediaRepo.svc.name_port else top.synapse.mediaWorker.svc.name_port },
+ { path: "/_matrix/", backend: top.synapse.main.svc.name_port },
# Used by OpenID Connect login flow
- { path: "/_synapse/", backend: app.synapse.main.svc.name_port },
+ { path: "/_synapse/", backend: top.synapse.main.svc.name_port },
] + (if cfg.cas.enable then [
- { path: "/_cas", backend: app.cas.svc.name_port },
+ { path: "/_cas", backend: top.cas.svc.name_port },
] else []) + (if cfg.wellKnown then [
- { path: "/.well-known/matrix", backend: app.wellKnown.svc.name_port },
+ { path: "/.well-known/matrix", backend: top.wellKnown.svc.name_port },
] else [])
},
}