| 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 | network: #Network @name(Network) |
| 9 | subdomain: string @name(Subdomain) |
| gio | efa0ed4 | 2024-06-13 12:31:43 +0400 | [diff] [blame] | 10 | sshPort: int @name(SSH Port) @role(port) |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 11 | adminKey: string @name(Admin SSH Public Key) |
| 12 | |
| 13 | // TODO(gio): auto generate |
| 14 | ssKeys: #SSHKey |
| 15 | fluxKeys: #SSHKey |
| 16 | dAppKeys: #SSHKey |
| 17 | } |
| 18 | |
| 19 | name: "Dodo App" |
| 20 | namespace: "dodo-app" |
| 21 | readme: "Deploy app by pushing to Git repository" |
| 22 | description: "Deploy app by pushing to Git repository" |
| 23 | icon: "<svg xmlns='http://www.w3.org/2000/svg' width='50' height='50' viewBox='0 0 48 48'><path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' d='M2.837 27.257c3.363 2.45 11.566 3.523 12.546 1.4s.424-10.94.424-10.94s-1.763 1.192-2.302.147s.44-2.433 2.319-2.858c-1.96.05-2.221-.571-2.205-.93s.67-1.878 3.527-1.241c-1.6-.751-1.943-2.956 2.352-1.568c-1.421-.735-.36-2.825 1.649-.62c-.261-1.323 1.584-1.46 2.694.907M10.648 34.633a19 19 0 0 0-4.246.719'/><path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' d='M15.144 43.402c3.625-2.482 7.685-6.32 7.293-13.406s-1.6-6.368-.523-7.577s6.924-.99 10.712 3.353c.032-2.874-2.504-5.508-2.504-5.508a33 33 0 0 1 5.53.163c2.852.49 2.394 2.514 3.58 2.035s.971-3.472-.39-5.377c-1.666-2.33-3.223-2.83-6.358-2.188s-4.474.458-5.54-.587s-2.026-3.538-4.605-2.515c-2.935 1.164-4.398 2.438-3.767 5.04s2.34 4.558 2.972 6.844'/><path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' d='M22.001 16.552c-.925-.043-1.894.055-1.709 1.328'/><path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' d='M20.662 16.763c1.72 2.695 3.405 3.643 9.46 3.501'/><path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' d='M32.14 14.966c-1.223.879-2.18 3.781-2.496 5.307M23.1 14.908c.48 1.209 1.23.728 1.315.283a1.552 1.552 0 0 0-1.543-1.883m-.408 17.472c5.328 2.71 11.631.229 16.269-2.123c-1.176 4.572-5.911 5.585-8.916 6.107'/><path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' d='M29.099 37.115c4.376-.294 8.024-1.578 7.833-5.296'/><path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' d='M20.27 38.702c6.771 3.834 12.505.798 13.786-2.615'/><circle cx='24' cy='24' r='21.5' fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round'/></svg>" |
| 24 | _domain: "\(input.subdomain).\(input.network.domain)" |
| 25 | |
| 26 | images: { |
| 27 | softserve: { |
| 28 | repository: "charmcli" |
| 29 | name: "soft-serve" |
| 30 | tag: "v0.7.1" |
| 31 | pullPolicy: "IfNotPresent" |
| 32 | } |
| 33 | dodoApp: { |
| 34 | repository: "giolekva" |
| 35 | name: "pcloud-installer" |
| 36 | tag: "latest" |
| 37 | pullPolicy: "Always" |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | charts: { |
| 42 | softserve: { |
| gio | f884341 | 2024-05-22 16:38:05 +0400 | [diff] [blame] | 43 | kind: "GitRepository" |
| 44 | address: "https://github.com/giolekva/pcloud.git" |
| 45 | branch: "main" |
| 46 | path: "charts/soft-serve" |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 47 | } |
| 48 | dodoApp: { |
| gio | f884341 | 2024-05-22 16:38:05 +0400 | [diff] [blame] | 49 | kind: "GitRepository" |
| 50 | address: "https://github.com/giolekva/pcloud.git" |
| 51 | branch: "main" |
| 52 | path: "charts/dodo-app" |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 53 | } |
| 54 | } |
| 55 | |
| 56 | portForward: [#PortForward & { |
| 57 | allocator: input.network.allocatePortAddr |
| gio | efa0ed4 | 2024-06-13 12:31:43 +0400 | [diff] [blame] | 58 | reservator: input.network.reservePortAddr |
| gio | cdfa372 | 2024-06-13 20:10:14 +0400 | [diff] [blame] | 59 | deallocator: input.network.deallocatePortAddr |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 60 | sourcePort: input.sshPort |
| gio | 3e67ce1 | 2024-06-13 19:47:19 +0400 | [diff] [blame] | 61 | serviceName: "soft-serve" |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 62 | targetPort: 22 |
| 63 | }] |
| 64 | |
| 65 | helm: { |
| 66 | softserve: { |
| 67 | chart: charts.softserve |
| gio | f9f0bee | 2024-06-11 20:10:05 +0400 | [diff] [blame] | 68 | info: "Installing Git server" |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 69 | values: { |
| 70 | serviceType: "ClusterIP" |
| 71 | addressPool: "" |
| 72 | reservedIP: "" |
| gio | 266c04f | 2024-07-03 14:18:45 +0400 | [diff] [blame] | 73 | adminKey: strings.Join([input.fluxKeys.public, input.dAppKeys.public], "\n") |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 74 | privateKey: input.ssKeys.private |
| 75 | publicKey: input.ssKeys.public |
| 76 | ingress: { |
| 77 | enabled: false |
| 78 | } |
| 79 | image: { |
| 80 | repository: images.softserve.fullName |
| 81 | tag: images.softserve.tag |
| 82 | pullPolicy: images.softserve.pullPolicy |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | "dodo-app": { |
| 87 | chart: charts.dodoApp |
| gio | f9f0bee | 2024-06-11 20:10:05 +0400 | [diff] [blame] | 88 | info: "Installing supervisor" |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 89 | values: { |
| 90 | image: { |
| 91 | repository: images.dodoApp.fullName |
| 92 | tag: images.dodoApp.tag |
| 93 | pullPolicy: images.dodoApp.pullPolicy |
| 94 | } |
| 95 | repoAddr: "soft-serve.\(release.namespace).svc.cluster.local:22" |
| 96 | sshPrivateKey: base64.Encode(null, input.dAppKeys.private) |
| 97 | self: "dodo-app.\(release.namespace).svc.cluster.local" |
| 98 | namespace: release.namespace |
| 99 | envConfig: base64.Encode(null, json.Marshal(global)) |
| gio | 266c04f | 2024-07-03 14:18:45 +0400 | [diff] [blame] | 100 | appAdminKey: input.adminKey |
| 101 | gitRepoPublicKey: input.ssKeys.public |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 102 | } |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | resources: { |
| 107 | "config-kustomization": { |
| 108 | apiVersion: "kustomize.toolkit.fluxcd.io/v1" |
| 109 | kind: "Kustomization" |
| 110 | metadata: { |
| gio | 266c04f | 2024-07-03 14:18:45 +0400 | [diff] [blame] | 111 | name: "config" |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 112 | namespace: release.namespace |
| 113 | } |
| 114 | spec: { |
| 115 | interval: "1m" |
| gio | 266c04f | 2024-07-03 14:18:45 +0400 | [diff] [blame] | 116 | path: "./" |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 117 | sourceRef: { |
| 118 | kind: "GitRepository" |
| gio | 266c04f | 2024-07-03 14:18:45 +0400 | [diff] [blame] | 119 | name: "config" |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 120 | namespace: release.namespace |
| 121 | } |
| 122 | prune: true |
| 123 | } |
| 124 | } |
| 125 | "config-secret": { |
| 126 | apiVersion: "v1" |
| 127 | kind: "Secret" |
| 128 | type: "Opaque" |
| 129 | metadata: { |
| gio | 266c04f | 2024-07-03 14:18:45 +0400 | [diff] [blame] | 130 | name: "config" |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 131 | namespace: release.namespace |
| 132 | } |
| 133 | data: { |
| 134 | identity: base64.Encode(null, input.fluxKeys.private) |
| 135 | "identity.pub": base64.Encode(null, input.fluxKeys.public) |
| 136 | known_hosts: base64.Encode(null, "soft-serve.\(release.namespace).svc.cluster.local \(input.ssKeys.public)") |
| 137 | } |
| 138 | } |
| 139 | "config-source": { |
| 140 | apiVersion: "source.toolkit.fluxcd.io/v1" |
| 141 | kind: "GitRepository" |
| 142 | metadata: { |
| gio | 266c04f | 2024-07-03 14:18:45 +0400 | [diff] [blame] | 143 | name: "config" |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 144 | namespace: release.namespace |
| 145 | } |
| 146 | spec: { |
| 147 | interval: "1m0s" |
| gio | 266c04f | 2024-07-03 14:18:45 +0400 | [diff] [blame] | 148 | ref: branch: "master" |
| 149 | secretRef: name: "config" |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 150 | timeout: "60s" |
| gio | 266c04f | 2024-07-03 14:18:45 +0400 | [diff] [blame] | 151 | url: "ssh://soft-serve.\(release.namespace).svc.cluster.local:22/config" |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 152 | } |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | help: [{ |
| 157 | title: "How to use" |
| 158 | contents: """ |
| gio | caa365a | 2024-06-25 14:24:28 +0400 | [diff] [blame] | 159 | Clone: git clone ssh://\(_domain):\(input.sshPort)/app <button onClick='copyToClipboard(this, "git clone ssh://\(_domain):\(input.sshPort)/app")'><svg width='24px' height='24px' viewBox='-2.4 -2.4 28.80 28.80' fill='none' xmlns='http://www.w3.org/2000/svg'><g id='SVGRepo_bgCarrier' stroke-width='0'></g><g id='SVGRepo_tracerCarrier' stroke-linecap='round' stroke-linejoin='round'></g><g id='SVGRepo_iconCarrier'> <path fill-rule='evenodd' clip-rule='evenodd' d='M19.5 16.5L19.5 4.5L18.75 3.75H9L8.25 4.5L8.25 7.5L5.25 7.5L4.5 8.25V20.25L5.25 21H15L15.75 20.25V17.25H18.75L19.5 16.5ZM15.75 15.75L15.75 8.25L15 7.5L9.75 7.5V5.25L18 5.25V15.75H15.75ZM6 9L14.25 9L14.25 19.5L6 19.5L6 9Z' fill='#080341'></path> </g></svg></button> |
| 160 | Server public key: \(input.ssKeys.public) |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 161 | """ |
| 162 | }] |