blob: 2dd8da567f4fd08896cae7e9d646ca868838f843 [file] [log] [blame]
Giorgi Lekveishvili46743d42023-12-10 15:47:23 +04001package tasks
2
3import (
Giorgi Lekveishvili46743d42023-12-10 15:47:23 +04004 "net"
5
6 "github.com/charmbracelet/keygen"
7
8 "github.com/giolekva/pcloud/core/installer"
9 "github.com/giolekva/pcloud/core/installer/soft"
10)
11
12type state struct {
Giorgi Lekveishvili378ea882023-12-12 13:59:18 +040013 publicIPs []net.IP
14 nsCreator installer.NamespaceCreator
15 repo installer.RepoIO
16 ssAdminKeys *keygen.KeyPair
17 ssClient *soft.Client
18 fluxUserName string
19 keys *keygen.KeyPair
20 appManager *installer.AppManager
21 appsRepo installer.AppRepository[installer.App]
22 nsGen installer.NamespaceGenerator
23 emptySuffixGen installer.SuffixGenerator
Giorgi Lekveishvili46743d42023-12-10 15:47:23 +040024}
25
Giorgi Lekveishvili46743d42023-12-10 15:47:23 +040026type Env struct {
27 PCloudEnvName string
28 Name string
29 ContactEmail string
30 Domain string
31 AdminPublicKey string
32}
33
Giorgi Lekveishvilicd9e42c2023-12-13 09:49:44 +040034type DNSZoneRef struct {
35 Name string
36 Namespace string
37}
38
Giorgi Lekveishvili46743d42023-12-10 15:47:23 +040039func NewCreateEnvTask(
40 env Env,
41 publicIPs []net.IP,
42 nsCreator installer.NamespaceCreator,
43 repo installer.RepoIO,
Giorgi Lekveishvilicd9e42c2023-12-13 09:49:44 +040044) (Task, DNSZoneRef) {
Giorgi Lekveishvili77ee2dc2023-12-11 16:51:10 +040045 st := state{
46 publicIPs: publicIPs,
47 nsCreator: nsCreator,
48 repo: repo,
Giorgi Lekveishvili46743d42023-12-10 15:47:23 +040049 }
Giorgi Lekveishvili378ea882023-12-12 13:59:18 +040050 return newSequentialParentTask(
Giorgi Lekveishvili77ee2dc2023-12-11 16:51:10 +040051 "Create env",
Giorgi Lekveishvili378ea882023-12-12 13:59:18 +040052 append(
53 []Task{
54 SetupConfigRepoTask(env, &st),
55 NewActivateEnvTask(env, &st),
56 SetupZoneTask(env, &st),
57 },
58 SetupInfra(env, &st)...,
59 )...,
Giorgi Lekveishvilicd9e42c2023-12-13 09:49:44 +040060 ), DNSZoneRef{"dns-zone", env.Name}
Giorgi Lekveishvili46743d42023-12-10 15:47:23 +040061}