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 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", Type: FieldTypeNumber, CharLimit: 4, }, { Id: "timeout", Label: "Timeout (Segundos)", Placeholder: "30", Default: "30", Type: FieldTypeNumber, CharLimit: 3, }, { Id: "environment", Label: "Ambiente", Default: "production", Type: FieldTypeSelect, Options: []string{"development", "production"}, }, }), 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", Type: FieldTypeNumber, }, }), certForm: NewFormStep("Certificado", []FormField{ { 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, }, { Id: "cert_name", Label: "Nome do arquivo do certificado", Placeholder: "certificado.crt", Default: "certificado.crt", Type: FieldTypeText, }, { 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(), m.spinner.Tick) }