Discover modules > github.com/xchangeee/syslet/schema > tools
v0.2.0
#SysdefLock: ¶

This definition provides a shortcut to lock the given network/container/volumes.

Locking means that we disallow removal, and for volumes, we also set reclaim policy to retain so data wont be accidentally deleted.

"in"!: ¶
networks: [...string] ¶
[...]: string
containers: [...string] ¶
[...]: string
volumes: [...string] ¶
[...]: string
out: ¶
networks: {for name in X1.networks {"\(name)": spec: {removalAllowed: false}}} ¶
containers: {for name in X1.containers {"\(name)": spec: {removalAllowed: false}}} ¶
volumes: {for name in X1.volumes {"\(name)": spec: {removalAllowed: false, reclaimPolicy: "Retain"}}} ¶
#SysdefAssignNetwork: ¶

This definition provides a shortcut to assign containers to networks. The network name is the first level, the container name the second level.

There is nothing special about this, you can also assign containers to networks directly in the container definition, but when there are many containers and complex definitions its harder to get an overview of what container is in what network.

"in"!: ¶
[string]: [...string] ¶
[...]: string
out: ¶
containers:
click to see definition
{
	for network, containerList in X1
	for name in containerList {
		"\(name)": spec: unit: Container: Network: [
			for net, members in X1
			if list.Contains(members, name) {"\(net).network"},
		]
	}
}
¶
#SysdefSecretsFromEmbeddedFiles: ¶

Accepts a struct from @embed(glob=creds-*.enc.yaml,type=text,allowEmptyGlob) and returns a struct with matching secret specs. The name is taken from the file name, stripping the creds- prefix and the enc.yaml suffix.

The files must be in the same directory as the CUE file: for a glob into a subdirectory, @embed keeps the directory in the key, so the prefix isn't stripped and the spec name contains the path.

"in"!: ¶
[string]: string ¶
secrets:
click to see definition
{
	for path, content in X1
	let name = strings.TrimSuffix(strings.TrimPrefix(path, "creds-"), ".enc.yaml") {
		(name): core.#SysdefSecret & {
			spec: ciphertext: content
		}
	}
}
¶
#SysletJsonFromSysdef: ¶

Renders the provided sysdef struct in syslet json format, to be consumed by syslet via file or stdin.

"in": core.#Sysdef ¶
specRendered: json.Marshal(_specList) ¶

Source files

  • tools.cue