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/ops/sso/kube/sso.libsonnet b/ops/sso/kube/sso.libsonnet
index 12c111f..c4b9b8c 100644
--- a/ops/sso/kube/sso.libsonnet
+++ b/ops/sso/kube/sso.libsonnet
@@ -3,8 +3,8 @@
local kube = import "../../../kube/hscloud.libsonnet";
{
- local app = self,
- local cfg = app.cfg,
+ local top = self,
+ local cfg = top.cfg,
cfg:: {
namespace: "sso",
@@ -19,7 +19,7 @@
},
},
- local ns = kube.Namespace(app.cfg.namespace),
+ local ns = kube.Namespace(top.cfg.namespace),
deployment: ns.Contain(kube.Deployment("sso")) {
spec+: {
@@ -95,7 +95,7 @@
},
svc: ns.Contain(kube.Service("sso")) {
- target:: app.deployment,
+ target:: top.deployment,
spec+: {
ports: [
{ name: "http", port: 5000, targetPort: 5000, protocol: "TCP" },
@@ -106,6 +106,6 @@
ingress: ns.Contain(kube.SimpleIngress("sso")) {
hosts:: [cfg.domain],
- target_service:: app.svc,
+ target_service:: top.svc,
},
}