Debian Codegraph @

case_studies/micromanage/lib/mmlib/v0.1.2/service/base.libsonnet

raw
1 {
2
3 // The base class of all Micromanage services. While it is not necessary to use this, it does
4 // provide the following useful features:
5 // - Utilities for generating unique names and easy referencing via those names.
6 // - Defaults for required fields.
7 // The function takes the outer service (or null) and a name that must be unique amongst its
8 // siblings.
9 Service(outer, name): {
10 // The final component of the full name.
11 name:: std.toString(name),
12
13 // The sequence of names leading from the outermost service to here.
14 nameArray:: (if outer == null then [] else outer.nameArray) + [self.name],
15
16 // The globally unique name of the service.
17 fullName:: std.join('-', self.nameArray),
18
19 // Generate a new name prefixed by the service's name.
20 prefixName(name):: std.join('-', self.nameArray + [std.toString(name)]),
21
22 // The environment in which this service will be deployed.
23 environment: 'default',
24
25 // The Terraform resources that will be deployed.
26 infrastructure: {},
27
28 // Any Terraform outputs that cannot be known until after deployment, such as generated
29 // addresses.
30 outputs: {},
31 } + {
32
33 // Prevent overriding the fundamental identity characteristics.
34 assert self.name == super.name,
35 assert self.nameArray == super.nameArray,
36 assert self.fullName == super.fullName,
37 assert self.prefixName('foo') == super.prefixName('foo'),
38 },
39 }