| 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 | |
| 34 | func NewCreateEnvTask( |
| 35 | env Env, |
| 36 | publicIPs []net.IP, |
| 37 | nsCreator installer.NamespaceCreator, |
| 38 | repo installer.RepoIO, |
| 39 | ) Task { |
| Giorgi Lekveishvili | 77ee2dc | 2023-12-11 16:51:10 +0400 | [diff] [blame] | 40 | st := state{ |
| 41 | publicIPs: publicIPs, |
| 42 | nsCreator: nsCreator, |
| 43 | repo: repo, |
| Giorgi Lekveishvili | 46743d4 | 2023-12-10 15:47:23 +0400 | [diff] [blame] | 44 | } |
| Giorgi Lekveishvili | 378ea88 | 2023-12-12 13:59:18 +0400 | [diff] [blame^] | 45 | return newSequentialParentTask( |
| Giorgi Lekveishvili | 77ee2dc | 2023-12-11 16:51:10 +0400 | [diff] [blame] | 46 | "Create env", |
| Giorgi Lekveishvili | 378ea88 | 2023-12-12 13:59:18 +0400 | [diff] [blame^] | 47 | append( |
| 48 | []Task{ |
| 49 | SetupConfigRepoTask(env, &st), |
| 50 | NewActivateEnvTask(env, &st), |
| 51 | SetupZoneTask(env, &st), |
| 52 | }, |
| 53 | SetupInfra(env, &st)..., |
| 54 | )..., |
| Giorgi Lekveishvili | 77ee2dc | 2023-12-11 16:51:10 +0400 | [diff] [blame] | 55 | ) |
| Giorgi Lekveishvili | 46743d4 | 2023-12-10 15:47:23 +0400 | [diff] [blame] | 56 | } |