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/hswaw/paperless/paperless.libsonnet b/hswaw/paperless/paperless.libsonnet
index 7e63c79..c58ecae 100644
--- a/hswaw/paperless/paperless.libsonnet
+++ b/hswaw/paperless/paperless.libsonnet
@@ -11,7 +11,7 @@
local redis = import "../../kube/redis.libsonnet";
{
- local app = self,
+ local top = self,
local cfg = self.cfg,
cfg:: {
@@ -69,7 +69,7 @@
template+: {
spec+: {
volumes_: {
- data: kube.PersistentVolumeClaimVolume(app.dataVolume),
+ data: kube.PersistentVolumeClaimVolume(top.dataVolume),
},
securityContext: {
@@ -131,13 +131,13 @@
PAPERLESS_SECRET_KEY: { secretKeyRef: { name: "paperless", key: "secret_key" } },
- A_REDIS_PASSWORD: app.redis.cfg.password,
+ A_REDIS_PASSWORD: top.redis.cfg.password,
PAPERLESS_REDIS: "redis://:$(A_REDIS_PASSWORD)@redis:6379",
PAPERLESS_DBHOST: "postgres",
- PAPERLESS_DBNAME: app.postgres.cfg.database,
- PAPERLESS_DBUSER: app.postgres.cfg.username,
- PAPERLESS_DBPASS: app.postgres.cfg.password,
+ PAPERLESS_DBNAME: top.postgres.cfg.database,
+ PAPERLESS_DBUSER: top.postgres.cfg.username,
+ PAPERLESS_DBPASS: top.postgres.cfg.password,
PAPERLESS_ENABLE_HTTP_REMOTE_USER: "true",
PAPERLESS_HTTP_REMOTE_USER_HEADER_NAME: "HTTP_X_FORWARDED_USER",
@@ -162,11 +162,11 @@
},
service: ns.Contain(kube.Service("paperless")) {
- target:: app.deploy,
+ target:: top.deploy,
},
ingress: ns.Contain(kube.SimpleIngress("paperless")) {
hosts:: [cfg.domain],
- target_service:: app.service,
+ target_service:: top.service,
},
}