blob: 48ab18ea3a5c6382abd3d1f43090e783a63eb5de [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
34func NewCreateEnvTask(
35 env Env,
36 publicIPs []net.IP,
37 nsCreator installer.NamespaceCreator,
38 repo installer.RepoIO,
39) Task {
Giorgi Lekveishvili77ee2dc2023-12-11 16:51:10 +040040 st := state{
41 publicIPs: publicIPs,
42 nsCreator: nsCreator,
43 repo: repo,
Giorgi Lekveishvili46743d42023-12-10 15:47:23 +040044 }
Giorgi Lekveishvili378ea882023-12-12 13:59:18 +040045 return newSequentialParentTask(
Giorgi Lekveishvili77ee2dc2023-12-11 16:51:10 +040046 "Create env",
Giorgi Lekveishvili378ea882023-12-12 13:59:18 +040047 append(
48 []Task{
49 SetupConfigRepoTask(env, &st),
50 NewActivateEnvTask(env, &st),
51 SetupZoneTask(env, &st),
52 },
53 SetupInfra(env, &st)...,
54 )...,
Giorgi Lekveishvili77ee2dc2023-12-11 16:51:10 +040055 )
Giorgi Lekveishvili46743d42023-12-10 15:47:23 +040056}