feat: implemented all features besides wireguard

This commit is contained in:
jb
2026-03-11 11:01:35 -03:00
parent 6870144f39
commit 085cda7251
11 changed files with 539 additions and 73 deletions
+70 -11
View File
@@ -1,37 +1,78 @@
package tui
import (
"charm.land/bubbles/v2/spinner"
tea "charm.land/bubbletea/v2"
)
type Model struct {
currentStep step
cursor int
width int
height int
spinner spinner.Model
loading bool
dockerInstalled bool
checkDockerDone bool
checkProgress float64
isPublicIP bool
downloadDone bool
downloadMessage string
downloadError error
loginData DockerLoginData
isPublicIP bool
loginForm FormStep
serverForm FormStep
dbForm FormStep
certForm FormStep
configValues ConfigValues
finishedFile bool
configFileError error
finishedDockerRun bool
dockerRunError error
err error
}
type DockerLoginData struct {
Login string
Password string
}
type ConfigValues struct {
Login map[string]string
Server map[string]string
Database map[string]string
Cert map[string]string
}
func InitialModel() Model {
s := spinner.New()
s.Spinner = spinner.Dot
s.Style = SpinnerStyle
return Model{
currentStep: StepCheckDocker,
loginForm: NewFormStep("Login no Repositório Docker", []FormField{
{
Id: "user",
Label: "Usuário",
Placeholder: "usuario",
Type: FieldTypeText,
},
{
Id: "password",
Label: "Senha",
Placeholder: "senhaForte123",
Type: FieldTypePassword,
},
}),
serverForm: NewFormStep("Servidor", []FormField{
{
Id: "port",
Label: "Porta",
Placeholder: "8081",
Default: "8081",
@@ -39,6 +80,7 @@ func InitialModel() Model {
CharLimit: 4,
},
{
Id: "timeout",
Label: "Timeout (Segundos)",
Placeholder: "30",
Default: "30",
@@ -46,6 +88,7 @@ func InitialModel() Model {
CharLimit: 3,
},
{
Id: "environment",
Label: "Ambiente",
Default: "production",
Type: FieldTypeSelect,
@@ -54,24 +97,28 @@ func InitialModel() Model {
}),
dbForm: NewFormStep("Banco de Dados", []FormField{
{
Id: "database_type",
Label: "Tipo do Banco",
Default: "postgres",
Type: FieldTypeSelect,
Options: []string{"postgres", "oracle"},
},
{
Id: "database_url",
Label: "URL de acesso",
Placeholder: "postgres://usuario:senha@banco:5432/app_dono_db",
Default: "postgres://usuario:senha@banco:5432/app_dono_db",
Type: FieldTypeText,
},
{
Id: "max_conns",
Label: "Conexões ativas (máximo)",
Placeholder: "10",
Default: "10",
Type: FieldTypeNumber,
},
{
Id: "min_conns",
Label: "Conexões ativas (mínimo)",
Placeholder: "2",
Default: "2",
@@ -80,33 +127,45 @@ func InitialModel() Model {
}),
certForm: NewFormStep("Certificado", []FormField{
{
Label: "Caminho para o arquivo do certificado",
Placeholder: "/caminho/para/certificado.crt",
Default: "/caminho/para/certificado.crt",
Id: "cert_dir_path",
Label: "Caminho para o diretório dos certificados (será montado no container)",
Placeholder: "/caminho/para/diretorio",
Default: "/caminho/para/diretorio",
Type: FieldTypeText,
},
{
Label: "Caminho para o arquivo da chave",
Placeholder: "/caminho/para/chave.key",
Default: "/caminho/para/chave.key",
Id: "cert_name",
Label: "Nome do arquivo do certificado",
Placeholder: "certificado.crt",
Default: "certificado.crt",
Type: FieldTypeText,
},
{
Label: "Caminho para o arquivo da autoridade certificadora",
Placeholder: "/caminho/para/chaveCA.crt",
Default: "/caminho/para/chaveCA.crt",
Id: "key_name",
Label: "Nome do arquivo da chave",
Placeholder: "chave.key",
Default: "chave.key",
Type: FieldTypeText,
},
{
Id: "ca_name",
Label: "Nome do arquivo da autoridade certificadora",
Placeholder: "chaveCA.crt",
Default: "chaveCA.crt",
Type: FieldTypeText,
},
{
Id: "server_name",
Label: "Nome do servidor",
Placeholder: "client",
Default: "client",
Type: FieldTypeText,
},
}),
spinner: s,
}
}
func (m Model) Init() tea.Cmd {
return tea.Batch(CheckDockerCmd(), tickCmd())
return tea.Batch(CheckDockerCmd(), TickCmd(), m.spinner.Tick)
}