| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 1 | import ( |
| 2 | "encoding/base64" |
| 3 | "encoding/json" |
| 4 | "strings" |
| 5 | ) |
| 6 | |
| 7 | input: { |
| 8 | repoAddr: string |
| 9 | sshPrivateKey: string |
| 10 | } |
| 11 | |
| 12 | #AppIngress: { |
| 13 | network: string |
| 14 | subdomain: string |
| 15 | auth: #Auth |
| 16 | } |
| 17 | |
| 18 | _goVer1220: "golang:1.22.0" |
| 19 | _goVer1200: "golang:1.20.0" |
| 20 | |
| 21 | #GoAppTmpl: { |
| 22 | type: _goVer1220 | _goVer1200 |
| 23 | run: string |
| 24 | ingress: #AppIngress |
| 25 | |
| 26 | runConfiguration: [{ |
| 27 | bin: "/usr/local/go/bin/go", |
| 28 | args: ["mod", "tidy"] |
| 29 | }, { |
| 30 | bin: "/usr/local/go/bin/go", |
| 31 | args: ["build", "-o", ".app", run] |
| 32 | }, { |
| 33 | bin: ".app", |
| 34 | args: [] |
| 35 | }] |
| 36 | } |
| 37 | |
| 38 | #GoApp1200: #GoAppTmpl & { |
| 39 | type: _goVer1200 |
| 40 | } |
| 41 | |
| 42 | #GoApp1220: #GoAppTmpl & { |
| 43 | type: _goVer1220 |
| 44 | } |
| 45 | |
| 46 | #GoApp: #GoApp1200 | #GoApp1220 |
| 47 | |
| 48 | app: #GoApp |
| 49 | |
| 50 | // output |
| 51 | |
| 52 | _app: app |
| 53 | ingress: { |
| 54 | app: { |
| 55 | network: networks[strings.ToLower(_app.ingress.network)] |
| 56 | subdomain: _app.ingress.subdomain |
| 57 | auth: _app.ingress.auth |
| 58 | service: { |
| 59 | name: "app-app" |
| 60 | port: name: "app" |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | images: { |
| 66 | app: { |
| 67 | repository: "giolekva" |
| 68 | name: "app-runner" |
| 69 | tag: strings.Replace(_app.type, ":", "-", -1) |
| 70 | pullPolicy: "Always" |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | charts: { |
| 75 | app: { |
| 76 | chart: "charts/app-runner" |
| 77 | sourceRef: { |
| 78 | kind: "GitRepository" |
| 79 | name: "pcloud" |
| 80 | namespace: global.id |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | helm: { |
| 86 | app: { |
| 87 | chart: charts.app |
| 88 | values: { |
| 89 | image: { |
| 90 | repository: images.app.fullName |
| 91 | tag: images.app.tag |
| 92 | pullPolicy: images.app.pullPolicy |
| 93 | } |
| 94 | appPort: 8080 |
| 95 | appDir: "/dodo-app" |
| 96 | repoAddr: input.repoAddr |
| 97 | sshPrivateKey: base64.Encode(null, input.sshPrivateKey) |
| 98 | runCfg: base64.Encode(null, json.Marshal(_app.runConfiguration)) |
| 99 | manager: "http://dodo-app.\(release.namespace).svc.cluster.local/register-worker" |
| 100 | } |
| 101 | } |
| 102 | } |