Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.

Commit

Permalink
further cleanup of CUE
Browse files Browse the repository at this point in the history
  • Loading branch information
manveru committed Apr 19, 2021
1 parent 243bd79 commit 55ee710
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 149 deletions.
154 changes: 69 additions & 85 deletions deploy.cue
Original file line number Diff line number Diff line change
Expand Up @@ -4,120 +4,94 @@ import (
"github.com/input-output-hk/mantis-ops/pkg/schemas/nomad:types"
jobDef "github.com/input-output-hk/mantis-ops/pkg/jobs:jobs"
"list"
"strings"
)

#defaultJobs: {
}

_Namespace: [Name=_]: {
vars: {
namespace: =~"^mantis-[a-z-]+$"
namespace: Name
let datacenter = "eu-central-1" | "us-east-2" | "eu-west-1"
datacenters: list.MinItems(1) | [...datacenter] | *["eu-central-1", "us-east-2"]
#fqdn: "mantis.ws"
}
jobs: [string]: types.#stanza.job
#namespaces: {
"mantis-unstable": jobs: #defaultJobs
"mantis-testnet": jobs: #defaultJobs
"mantis-staging": jobs: #defaultJobs
}

#namespaces: _Namespace

#defaults: {
#revisions: {
mantisOpsRev: "97dfa8601097e8e0cf52d2f62d2f57b5ddb8cd81"
mantisRev: "fdeb1c33f6e0fc24680e256fe1b8d920b04950a8"
morphoRev: "e47b74d5e7a78bf665758927336a28a915b3e596"
}

bootstrapNodes: {
"mantis-unstable": [
"enode://f92aa66337ab1993cc7269d4295d296aefe6199b34e900eac08c514c947ec7340d46a5648ffc2da10325dbaba16bdf92aa9c0b5e51d97a7818c3f495d478ddad@mantis-testnet-0.mantis.ws:9001?discport=9501",
"enode://d8a010f019db37dcaf2e1fb98d4fcbf1f57dbd7e2a7f065e92fbe77dca8b9120d6e79f1617e98fa6134e6af8858ac8f3735b1e70a5708eb14f228080356eb0a7@mantis-testnet-1.mantis.ws:9002?discport=9502",
"enode://442e2bd50eece65f90dee0d5c6075da4e1b4bc62e36b261a52e7f393dae6a68241e4dbad868c7ecc14fed277ed72e99a289a811b6172f35fb18bdca0b7a5602c@mantis-testnet-2.mantis.ws:9003?discport=9503",
"enode://ff86741b7b35087b2b53f44a612b233336490d5fae10b1434619b7714fe2d5346c71427a5e126cd27b9422a4d4376c1534ef66e88c5e62d6441d2541f63de0cf@mantis-testnet-3.mantis.ws:9004?discport=9504",
"enode://af97643f364b805d5b0e32b5356578a16afcc4fb9d1b6622998e9441eeb7795e8daf8e6b0ff3330da9879034112be56954f9269164513ece0f7394b805be3633@mantis-testnet-4.mantis.ws:9005?discport=9505",
]
"mantis-testnet": [
"enode://f92aa66337ab1993cc7269d4295d296aefe6199b34e900eac08c514c947ec7340d46a5648ffc2da10325dbaba16bdf92aa9c0b5e51d97a7818c3f495d478ddad@mantis-testnet-0.mantis.ws:9001?discport=9501",
"enode://d8a010f019db37dcaf2e1fb98d4fcbf1f57dbd7e2a7f065e92fbe77dca8b9120d6e79f1617e98fa6134e6af8858ac8f3735b1e70a5708eb14f228080356eb0a7@mantis-testnet-1.mantis.ws:9002?discport=9502",
"enode://442e2bd50eece65f90dee0d5c6075da4e1b4bc62e36b261a52e7f393dae6a68241e4dbad868c7ecc14fed277ed72e99a289a811b6172f35fb18bdca0b7a5602c@mantis-testnet-2.mantis.ws:9003?discport=9503",
"enode://ff86741b7b35087b2b53f44a612b233336490d5fae10b1434619b7714fe2d5346c71427a5e126cd27b9422a4d4376c1534ef66e88c5e62d6441d2541f63de0cf@mantis-testnet-3.mantis.ws:9004?discport=9504",
"enode://af97643f364b805d5b0e32b5356578a16afcc4fb9d1b6622998e9441eeb7795e8daf8e6b0ff3330da9879034112be56954f9269164513ece0f7394b805be3633@mantis-testnet-4.mantis.ws:9005?discport=9505",
]
"mantis-staging": [
"enode://39b925ba0beffdb80859a0ab34895c98bb61bd20d686ccd27f8c5a04dddc82b712081fd11bfd43f3bc08b00423a5ff8fee70b8a22dcc95e85537b2084dc6816a@mantis-staging-0.mantis.ws:33000?discport=33500",
"enode://cbd80c7f72a889101b7f23d51be2de7e3f1f46ad3b25c438e959e24e08f03bd9fe833460e84b60174d4eb120af3b127389c4606f81c842943c4922cab384a234@mantis-staging-1.mantis.ws:33001?discport=33501",
"enode://0e63642be49c5a092569aa01663fcda1505362cd0ac41e24ff9296ab80c97af135fb6fb247273631a3a11257774f39ed882d72a20fd45131e53e9015adf6b9e5@mantis-staging-2.mantis.ws:33002?discport=33502",
"enode://3ee3641a25cfc611ba54a898260af7768ecf0643f06aefedf853864ed433d5ad6265eeb24abcc4d6f6ee90a1eac6c1fbf157fc05fd8e28e194dfc864cb56058e@mantis-staging-3.mantis.ws:33003?discport=33503",
"enode://907842e336fc757bbfde70368aef329714aa627e72e5da687f31b097fa71a59f36404aebbc83885c9b515270042e025a6788b700c314ee8bc68099dcff32afcd@mantis-staging-4.mantis.ws:33004?discport=33504",
]
}

#defaultJobs: {
explorer: #explorer
faucet: #faucet
miner: #miner
passive: #passive
morpho: #morpho
}

#faucet: jobDef.#Faucet & {
#mantisOpsRev: #defaults.mantisOpsRev
#mantisOpsRev: #revisions.mantisOpsRev
}

#explorer: jobDef.#Explorer & {
#mantisOpsRev: #defaults.mantisOpsRev
#mantisOpsRev: #revisions.mantisOpsRev
}

#miner: jobDef.#Mantis & {
#role: "miner"
#mantisRev: #defaults.mantisRev
#mantisRev: #revisions.mantisRev
}

#passive: jobDef.#Mantis & {
#role: "passive"
#mantisRev: #defaults.mantisRev
#mantisRev: #revisions.mantisRev
}

#morpho: jobDef.#Morpho & {
#morphoRev: #defaults.morphoRev
#mantisRev: #defaults.mantisRev
#morphoRev: #revisions.morphoRev
#mantisRev: #revisions.mantisRev
}

#namespaces: {
"mantis-unstable": {
vars: {
#networkConfig: """
mantis.blockchains.testnet-internal-nomad.bootstrap-nodes = [
"enode://f92aa66337ab1993cc7269d4295d296aefe6199b34e900eac08c514c947ec7340d46a5648ffc2da10325dbaba16bdf92aa9c0b5e51d97a7818c3f495d478ddad@mantis-testnet-0.mantis.ws:9001?discport=9501",
"enode://d8a010f019db37dcaf2e1fb98d4fcbf1f57dbd7e2a7f065e92fbe77dca8b9120d6e79f1617e98fa6134e6af8858ac8f3735b1e70a5708eb14f228080356eb0a7@mantis-testnet-1.mantis.ws:9002?discport=9502",
"enode://442e2bd50eece65f90dee0d5c6075da4e1b4bc62e36b261a52e7f393dae6a68241e4dbad868c7ecc14fed277ed72e99a289a811b6172f35fb18bdca0b7a5602c@mantis-testnet-2.mantis.ws:9003?discport=9503",
"enode://ff86741b7b35087b2b53f44a612b233336490d5fae10b1434619b7714fe2d5346c71427a5e126cd27b9422a4d4376c1534ef66e88c5e62d6441d2541f63de0cf@mantis-testnet-3.mantis.ws:9004?discport=9504",
"enode://af97643f364b805d5b0e32b5356578a16afcc4fb9d1b6622998e9441eeb7795e8daf8e6b0ff3330da9879034112be56954f9269164513ece0f7394b805be3633@mantis-testnet-4.mantis.ws:9005?discport=9505",
]
"""
}
jobs: {
explorer: #explorer
faucet: #faucet
miner: #miner & {#count: 5}
passive: #passive & {#count: 5}
morpho: #morpho & {#count: 5}
}
}
"mantis-testnet": {
vars: {
#networkConfig: """
mantis.blockchains.testnet-internal-nomad.bootstrap-nodes = [
"enode://f92aa66337ab1993cc7269d4295d296aefe6199b34e900eac08c514c947ec7340d46a5648ffc2da10325dbaba16bdf92aa9c0b5e51d97a7818c3f495d478ddad@mantis-testnet-0.mantis.ws:9001?discport=9501",
"enode://d8a010f019db37dcaf2e1fb98d4fcbf1f57dbd7e2a7f065e92fbe77dca8b9120d6e79f1617e98fa6134e6af8858ac8f3735b1e70a5708eb14f228080356eb0a7@mantis-testnet-1.mantis.ws:9002?discport=9502",
"enode://442e2bd50eece65f90dee0d5c6075da4e1b4bc62e36b261a52e7f393dae6a68241e4dbad868c7ecc14fed277ed72e99a289a811b6172f35fb18bdca0b7a5602c@mantis-testnet-2.mantis.ws:9003?discport=9503",
"enode://ff86741b7b35087b2b53f44a612b233336490d5fae10b1434619b7714fe2d5346c71427a5e126cd27b9422a4d4376c1534ef66e88c5e62d6441d2541f63de0cf@mantis-testnet-3.mantis.ws:9004?discport=9504",
"enode://af97643f364b805d5b0e32b5356578a16afcc4fb9d1b6622998e9441eeb7795e8daf8e6b0ff3330da9879034112be56954f9269164513ece0f7394b805be3633@mantis-testnet-4.mantis.ws:9005?discport=9505",
]
"""
}

jobs: {
explorer: #explorer
faucet: #faucet
miner: #miner & {#count: 5}
passive: #passive & {#count: 5}
morpho: #morpho & {#count: 5}
}
}
"mantis-staging": {
vars: {
#networkConfig: """
mantis.blockchains.testnet-internal-nomad.bootstrap-nodes = [
"enode://39b925ba0beffdb80859a0ab34895c98bb61bd20d686ccd27f8c5a04dddc82b712081fd11bfd43f3bc08b00423a5ff8fee70b8a22dcc95e85537b2084dc6816a@mantis-staging-0.mantis.ws:33000?discport=33500",
"enode://cbd80c7f72a889101b7f23d51be2de7e3f1f46ad3b25c438e959e24e08f03bd9fe833460e84b60174d4eb120af3b127389c4606f81c842943c4922cab384a234@mantis-staging-1.mantis.ws:33001?discport=33501",
"enode://0e63642be49c5a092569aa01663fcda1505362cd0ac41e24ff9296ab80c97af135fb6fb247273631a3a11257774f39ed882d72a20fd45131e53e9015adf6b9e5@mantis-staging-2.mantis.ws:33002?discport=33502",
"enode://3ee3641a25cfc611ba54a898260af7768ecf0643f06aefedf853864ed433d5ad6265eeb24abcc4d6f6ee90a1eac6c1fbf157fc05fd8e28e194dfc864cb56058e@mantis-staging-3.mantis.ws:33003?discport=33503",
"enode://907842e336fc757bbfde70368aef329714aa627e72e5da687f31b097fa71a59f36404aebbc83885c9b515270042e025a6788b700c314ee8bc68099dcff32afcd@mantis-staging-4.mantis.ws:33004?discport=33504",
]
"""
}
jobs: {
explorer: #explorer
faucet: #faucet
miner: #miner & {#count: 5}
passive: #passive & {#count: 5}
morpho: #morpho & {#count: 5}
}
_Namespace: [Name=_]: {
vars: {
namespace: =~"^mantis-[a-z-]+$"
namespace: Name
let datacenter = "eu-central-1" | "us-east-2" | "eu-west-1"
datacenters: list.MinItems(1) | [...datacenter] | *["eu-central-1", "us-east-2"]
#fqdn: "mantis.ws"
#networkConfig: """
mantis.blockchains.testnet-internal-nomad.bootstrap-nodes = [
\(strings.Join(#bootstrapNodes[Name], ",\n"))
]
"""
}
// "mantis-iele": jobs: #defaultJobs
// "mantis-qa-load": jobs: #defaultJobs
// "mantis-qa-fastsync": jobs: #defaultJobs
jobs: [string]: types.#stanza.job
}

#namespaces: _Namespace

for nsName, nsValue in #namespaces {
rendered: "\(nsName)": {
for jName, jValue in nsValue.jobs {
Expand All @@ -137,3 +111,13 @@ for nsName, nsValue in #namespaces {
}
}
}

#bootstrapNodes: {
for name, values in #namespaces {
"\(name)": [
for enode in bootstrapNodes[name] {
"\"\(enode)\""
},
]
}
}
44 changes: 0 additions & 44 deletions docker_images.cue

This file was deleted.

2 changes: 2 additions & 0 deletions jobs/explorer.cue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
}

group: explorer: {
count: 1

service: "\(#name)": {
address_mode: "host"
port: "explorer"
Expand Down
2 changes: 2 additions & 0 deletions jobs/faucet.cue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import (
}

group: faucet: {
count: 1

network: {
mode: "host"
port: {
Expand Down
18 changes: 9 additions & 9 deletions jobs/mantis.cue
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
)

#Mantis: types.#stanza.job & {
#count: uint
#role: "passive" | "miner" | "backup"
#mantisRev: string
#fqdn: string
#networkConfig: string
#count: uint | *5
#role: "passive" | "miner" | "backup"
#mantisRev: string
#fqdn: string
#networkConfig: string

let ref = {networkConfig: #networkConfig, mantisRev: #mantisRev, role: #role}

Expand Down Expand Up @@ -59,10 +59,10 @@ import (
}

task: mantis: tasks.#Mantis & {
#namespace: namespace
#mantisRev: ref.mantisRev
#role: ref.role
#networkConfig: ref.networkConfig
#namespace: namespace
#mantisRev: ref.mantisRev
#role: ref.role
#networkConfig: ref.networkConfig
}

task: promtail: tasks.#Promtail
Expand Down
3 changes: 1 addition & 2 deletions jobs/morpho.cue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

#Morpho: types.#stanza.job & {
#index: uint
#count: uint
#count: uint | *5
#mantisRev: string
#morphoRev: string
#fqdn: string
Expand Down Expand Up @@ -52,7 +52,6 @@ import (
sticky: true
}


network: {
mode: "host"
port: {
Expand Down
7 changes: 0 additions & 7 deletions run_tool.cue
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,3 @@ command: render: {
), "", " ")
}
}

command: images: {
build: exec.Run & {
cmd: "nix build -o docker_images.cue .#dockerImagesCue"
stdout: string
}
}
4 changes: 2 additions & 2 deletions schemas/nomad/types.cue
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ import (
TaskGroup: {
Affinities: [...Affinity]
Constraints: [...Constraint]
Count: int & >0
Count: uint
Meta: [string]: string
Name: string
RestartPolicy: *null | #json.RestartPolicy
Expand Down Expand Up @@ -518,7 +518,7 @@ let durationType = string & =~"^[1-9]\\d*[hms]$"
network: #stanza.network
service: [string]: #stanza.service
task: [string]: #stanza.task
count: uint | *1
count: uint
volume: [string]: #stanza.volume
restart: #stanza.restart & {#type: #type}
vault: *null | #stanza.vault
Expand Down

0 comments on commit 55ee710

Please sign in to comment.