getBootstrapOptions converts cobra flags to BootstrapOptions
(cmd *cobra.Command)
| 76 | |
| 77 | // getBootstrapOptions converts cobra flags to BootstrapOptions |
| 78 | func getBootstrapOptions(cmd *cobra.Command) bootstrap.BootstrapOptions { |
| 79 | configPath, _ := cmd.Flags().GetString("config") |
| 80 | profile, _ := cmd.Flags().GetString("profile") |
| 81 | noCache, _ := cmd.Flags().GetBool("no-cache") |
| 82 | version, _ := cmd.Flags().GetBool("version") |
| 83 | configWizard, _ := cmd.Flags().GetBool("config-wizard") |
| 84 | listProfiles, _ := cmd.Flags().GetBool("list-profiles") |
| 85 | |
| 86 | // Get config values from viper (which handles env vars) |
| 87 | addr := viper.GetString("addr") |
| 88 | user := viper.GetString("user") |
| 89 | password := viper.GetString("password") |
| 90 | tokenID := viper.GetString("token_id") |
| 91 | tokenSecret := viper.GetString("token_secret") |
| 92 | realm := viper.GetString("realm") |
| 93 | insecure := viper.GetBool("insecure") |
| 94 | apiPath := viper.GetString("api_path") |
| 95 | sshUser := viper.GetString("ssh_user") |
| 96 | vmSSHUser := viper.GetString("vm_ssh_user") |
| 97 | sshKeyfile := viper.GetString("ssh_keyfile") |
| 98 | vmSSHKeyfile := viper.GetString("vm_ssh_keyfile") |
| 99 | sshJumpHostAddr := viper.GetString("ssh_jumphost_addr") |
| 100 | sshJumpHostUser := viper.GetString("ssh_jumphost_user") |
| 101 | sshJumpHostKeyfile := viper.GetString("ssh_jumphost_keyfile") |
| 102 | sshJumpHostPort := viper.GetInt("ssh_jumphost_port") |
| 103 | debug := viper.GetBool("debug") |
| 104 | cacheDir := viper.GetString("cache_dir") |
| 105 | ageDir := viper.GetString("age_dir") |
| 106 | |
| 107 | // Handle show-icons flag - only override if explicitly set |
| 108 | var showIconsPtr *bool |
| 109 | if cmd.Flags().Changed("show-icons") { |
| 110 | showIcons, _ := cmd.Flags().GetBool("show-icons") |
| 111 | showIconsPtr = &showIcons |
| 112 | } |
| 113 | |
| 114 | return bootstrap.BootstrapOptions{ |
| 115 | ConfigPath: configPath, |
| 116 | Profile: profile, |
| 117 | NoCache: noCache, |
| 118 | Version: version, |
| 119 | ConfigWizard: configWizard, |
| 120 | ListProfiles: listProfiles, |
| 121 | FlagAddr: addr, |
| 122 | FlagUser: user, |
| 123 | FlagPassword: password, |
| 124 | FlagTokenID: tokenID, |
| 125 | FlagTokenSecret: tokenSecret, |
| 126 | FlagRealm: realm, |
| 127 | FlagInsecure: insecure, |
| 128 | FlagApiPath: apiPath, |
| 129 | FlagSSHUser: sshUser, |
| 130 | FlagVMSSHUser: vmSSHUser, |
| 131 | FlagSSHKeyfile: sshKeyfile, |
| 132 | FlagVMSSHKeyfile: vmSSHKeyfile, |
| 133 | FlagSSHJumpHostAddr: sshJumpHostAddr, |
| 134 | FlagSSHJumpHostUser: sshJumpHostUser, |
| 135 | FlagSSHJumpHostKeyfile: sshJumpHostKeyfile, |
no outgoing calls
no test coverage detected