Home

gen @e423ae92176cc817abac3a983cb7990c809d063e - refs - log -
-
https://git.jolheiser.com/gen.git
Generate Go flags and Nix module
gen / testdata / kitchen.cue
- raw -
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Exercises the features the ugit schema doesn't.
package kitchen

#Duration: string @go(type=time.Duration, parse=time.ParseDuration, import=time)
#Level: *"low" | "mid" | "high"

// Service name, shown in logs.
//
// A second paragraph only goes into the Nix description.
name: string

// Worker count.
workers: int & >=1 & <=64 | *4

// Retries; negative means forever.
retries: int & >=-1 | *3

// Sampling ratio.
ratio: float & >0 & <=1 | *0.5

// Any number.
scale: number | *1

// Request timeout.
timeout: #Duration | *"30s"

// Backoff steps.
backoff: [...#Duration] | *["1s", "5s"]

// Priority.
priority: 1 | 2 | 3 | *2

level: #Level

// Tags to attach.
tags: [...string & =~"^[a-z]+$"]

// Ports to probe.
probes: [...int & >0 & <65536] | *[80, 443]

// Optional webhook.
webhook?: string & =~"^https://"

// Uses an RE2-only pattern.
id: string & =~"^\\d+$" | *"1"

// Optional, with a field-level Nix type and apply.
owner?: string @nix(type=kitchen.owner, apply=kitchen.ownerString, import="kitchen extra")

// Ends up in Go only.
secret?: string @nix(skip)

"with": {
	// A Nix keyword as a key, and an `if` below it.
	"if": bool
	// A key that needs quoting in Nix.
	"has space": string | *"x" @go(name=HasSpace)
}

db: {
	// Database URL.
	url: string | *"postgres://localhost/app" @nix(default="postgres:///app")
}