| Giorgi Lekveishvili | 46743d4 | 2023-12-10 15:47:23 +0400 | [diff] [blame] | 1 | package tasks |
| 2 | |
| 3 | import ( |
| Giorgi Lekveishvili | 46743d4 | 2023-12-10 15:47:23 +0400 | [diff] [blame] | 4 | "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 | |
| 12 | type state struct { |
| Giorgi Lekveishvili | 378ea88 | 2023-12-12 13:59:18 +0400 | [diff] [blame] | 13 | 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 Lekveishvili | 46743d4 | 2023-12-10 15:47:23 +0400 | [diff] [blame] | 24 | } |
| 25 | |
| Giorgi Lekveishvili | 46743d4 | 2023-12-10 15:47:23 +0400 | [diff] [blame] | 26 | type Env struct { |
| 27 | PCloudEnvName string |
| 28 | Name string |
| 29 | ContactEmail string |
| 30 | Domain string |
| 31 | AdminPublicKey string |
| 32 | } |
| 33 | |
| Giorgi Lekveishvili | cd9e42c | 2023-12-13 09:49:44 +0400 | [diff] [blame] | 34 | type DNSZoneRef struct { |
| 35 | Name string |
| 36 | Namespace string |
| 37 | } |
| 38 | |
| Giorgi Lekveishvili | 46743d4 | 2023-12-10 15:47:23 +0400 | [diff] [blame] | 39 | func NewCreateEnvTask( |
| 40 | env Env, |
| 41 | publicIPs []net.IP, |
| 42 | nsCreator installer.NamespaceCreator, |
| 43 | repo installer.RepoIO, |
| Giorgi Lekveishvili | cd9e42c | 2023-12-13 09:49:44 +0400 | [diff] [blame] | 44 | ) (Task, DNSZoneRef) { |
| Giorgi Lekveishvili | 77ee2dc | 2023-12-11 16:51:10 +0400 | [diff] [blame] | 45 | st := state{ |
| 46 | publicIPs: publicIPs, |
| 47 | nsCreator: nsCreator, |
| 48 | repo: repo, |
| Giorgi Lekveishvili | 46743d4 | 2023-12-10 15:47:23 +0400 | [diff] [blame] | 49 | } |
| Giorgi Lekveishvili | 378ea88 | 2023-12-12 13:59:18 +0400 | [diff] [blame] | 50 | return newSequentialParentTask( |
| Giorgi Lekveishvili | 77ee2dc | 2023-12-11 16:51:10 +0400 | [diff] [blame] | 51 | "Create env", |
| Giorgi Lekveishvili | 378ea88 | 2023-12-12 13:59:18 +0400 | [diff] [blame] | 52 | append( |
| 53 | []Task{ |
| 54 | SetupConfigRepoTask(env, &st), |
| 55 | NewActivateEnvTask(env, &st), |
| 56 | SetupZoneTask(env, &st), |
| 57 | }, |
| 58 | SetupInfra(env, &st)..., |
| 59 | )..., |
| Giorgi Lekveishvili | cd9e42c | 2023-12-13 09:49:44 +0400 | [diff] [blame] | 60 | ), DNSZoneRef{"dns-zone", env.Name} |
| Giorgi Lekveishvili | 46743d4 | 2023-12-10 15:47:23 +0400 | [diff] [blame] | 61 | } |