Debian Codegraph @

case_studies/micromanage/tests/google/test_single_instance.jsonnet

raw
1 local cmd = import "mmlib/v0.1.2/cmd/cmd.libsonnet";
2
3 {
4 environments: import "../testenv.libsonnet",
5
6 local SingleGoogleInstance(name) = {
7 local service = self,
8
9 environment: "google",
10
11 zone:: error "Must override zone.",
12 image:: error "Must override zone.",
13 machineType:: "g1-small",
14 cmds:: [],
15
16 externalIp:: false,
17 infrastructure: {
18 google_compute_instance: {
19 name: {
20 name: name,
21 machine_type: service.machineType,
22 zone: service.zone,
23 boot_disk: {
24 initialize_params: {
25 image: service.image,
26 },
27 },
28 network_interface: {
29 network: "default",
30 access_config:
31 if service.externalIp then [{}] else [],
32 },
33 metadata: {
34 },
35 cmds: service.cmds,
36 bootCmds: [],
37 },
38 },
39 },
40 outputs: {
41 [if service.externalIp then name + "-address"]:
42 "${google_compute_instance.%s.network_interface[0].access_config.0.nat_ip}" % name,
43 },
44 },
45
46 wheezy: SingleGoogleInstance('wheezy') {
47 image: "debian-9-stretch-v20191121",
48 zone: "us-central1-b",
49 },
50 ubuntu: SingleGoogleInstance('ubuntu') {
51 image: "ubuntu-1804-bionic-v20191113",
52 zone: "us-central1-c",
53 },
54 "core-os": SingleGoogleInstance('core-os') {
55 image: "coreos-stable-2303-3-0-v20191203",
56 zone: "us-central1-f",
57 externalIp: true,
58 cmds: [
59 "echo hi > /hi.txt",
60 cmd.LiteralFile {
61 to: "/var/log/bye.txt",
62 content: |||
63 bye
64 |||,
65 filePermissions: "700",
66 },
67 ],
68 },
69 custom: SingleGoogleInstance('custom') {
70 image: {
71 source: "ubuntu-1804-bionic-v20191113",
72 zone: "us-central1-f",
73 cmds: [
74 "echo hi > /hi.txt",
75 cmd.LiteralFile {
76 to: "/var/log/bye.txt",
77 content: |||
78 bye
79 |||,
80 filePermissions: "700",
81 },
82 ],
83 },
84 zone: "us-central1-f",
85 externalIp: true,
86 },
87 }