(onDone func())
| 385 | } |
| 386 | |
| 387 | func (p *Plugin) showBootstrapSettingsForm(onDone func()) { |
| 388 | pages := p.app.Pages() |
| 389 | pages.RemovePage(menuPageName) |
| 390 | |
| 391 | cfg := p.app.Config() |
| 392 | if cfg == nil { |
| 393 | p.app.ShowMessageSafe("Configuration unavailable.") |
| 394 | if onDone != nil { |
| 395 | onDone() |
| 396 | } |
| 397 | return |
| 398 | } |
| 399 | |
| 400 | bootstrap := cfg.Plugins.Ansible.Bootstrap |
| 401 | form := components.NewStandardForm() |
| 402 | form.SetBorder(true) |
| 403 | form.SetBorderColor(theme.Colors.Border) |
| 404 | form.SetTitle(" Bootstrap Settings ") |
| 405 | form.SetTitleColor(theme.Colors.Primary) |
| 406 | |
| 407 | enabled := bootstrap.Enabled |
| 408 | username := strings.TrimSpace(bootstrap.Username) |
| 409 | uidRaw := "" |
| 410 | if bootstrap.UID > 0 { |
| 411 | uidRaw = strconv.Itoa(bootstrap.UID) |
| 412 | } |
| 413 | shell := strings.TrimSpace(bootstrap.Shell) |
| 414 | createHome := bootstrap.CreateHome |
| 415 | excludeWindowsGuests := bootstrap.ExcludeWindowsGuests |
| 416 | sshPublicKeyFile := strings.TrimSpace(bootstrap.SSHPublicKeyFile) |
| 417 | installAuthorizedKey := bootstrap.InstallAuthorizedKey |
| 418 | setPassword := bootstrap.SetPassword |
| 419 | password := strings.TrimSpace(bootstrap.Password) |
| 420 | grantSudo := bootstrap.GrantSudoNOPASSWD |
| 421 | sudoersMode := strings.TrimSpace(bootstrap.SudoersFileMode) |
| 422 | dryRunDefault := bootstrap.DryRunDefault |
| 423 | parallelismRaw := strconv.Itoa(bootstrap.Parallelism) |
| 424 | timeoutRaw := strings.TrimSpace(bootstrap.Timeout) |
| 425 | failFast := bootstrap.FailFast |
| 426 | |
| 427 | form.AddCheckbox("Enabled", enabled, func(checked bool) { enabled = checked }) |
| 428 | form.AddInputField("Username", username, 32, nil, func(text string) { username = strings.TrimSpace(text) }) |
| 429 | form.AddInputField("UID", uidRaw, 12, nil, func(text string) { uidRaw = strings.TrimSpace(text) }) |
| 430 | form.AddInputField("Shell", shell, 32, nil, func(text string) { shell = strings.TrimSpace(text) }) |
| 431 | form.AddCheckbox("Create Home", createHome, func(checked bool) { createHome = checked }) |
| 432 | form.AddCheckbox("Exclude Windows Guests", excludeWindowsGuests, func(checked bool) { |
| 433 | excludeWindowsGuests = checked |
| 434 | }) |
| 435 | form.AddInputField("SSH Public Key File", sshPublicKeyFile, 80, nil, func(text string) { |
| 436 | sshPublicKeyFile = strings.TrimSpace(text) |
| 437 | }) |
| 438 | form.AddCheckbox("Install Authorized Key", installAuthorizedKey, func(checked bool) { installAuthorizedKey = checked }) |
| 439 | form.AddCheckbox("Set Password", setPassword, func(checked bool) { setPassword = checked }) |
| 440 | form.AddPasswordField("Password", password, 64, '*', func(text string) { password = strings.TrimSpace(text) }) |
| 441 | form.AddCheckbox("Grant Sudo NOPASSWD", grantSudo, func(checked bool) { grantSudo = checked }) |
| 442 | form.AddInputField("Sudoers File Mode", sudoersMode, 16, nil, func(text string) { sudoersMode = strings.TrimSpace(text) }) |
| 443 | form.AddCheckbox("Dry Run Default", dryRunDefault, func(checked bool) { dryRunDefault = checked }) |
| 444 | form.AddInputField("Parallelism", parallelismRaw, 8, nil, func(text string) { parallelismRaw = strings.TrimSpace(text) }) |
no test coverage detected