3 ms·
> Or perhaps found relatively with self.out.out.out Jsonnet’s internal predecessor /counterpart/inspiration (Google BCL/GCL) has something like this and not in
by q3k 4y ago
> Or perhaps found relatively with self.out.out.out
Jsonnet’s internal predecessor /counterpart/inspiration (Google BCL/GCL) has something like this and not including it in Jsonnet is a feature :).
- ithkuil 4y agoyep, mixing lexical and dynamic scope was the hell indeed. A convention I use with jsonnet is to use locals to "anchor" some important objects in the lexical scope. My rule is to name the locals with exactly the same name as the field whose object they refer to. Example: { deployment: { local deployment = self, spec+: { replicas: 3, template+: { spec+: { local spec = self, containers: [ { name: 'foo', env: [ { name: 'REP', value: std.toString(deployment.spec.replicas) }, { name: 'SA', value: spec.serviceAccountName }, ], }, ], serviceAccountName: 'foo', } }, }, }, } Adding these locals gives the right amount of friction to avoid using this all the time, while at the same time having a predictable naming for the locals. The jsonnet LSP tool can easily resolve that local since it's only a lexical thing