cmd

package
v0.0.0-...-bf70cd4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "VBoxManage",
	Short: "Oracle VM VirtualBox Command Line Management Interface Version 5.0.20",
	Long: `Oracle VM VirtualBox Command Line Management Interface Version 5.0.20
(C) 2005-2016 Oracle Corporation
All rights reserved.`,

	Run: func(cmd *cobra.Command, args []string) {
		if version {
			host := viper.GetString("server.host")
			port := viper.GetString("server.port")

			home, err := homedir.Dir()
			if err != nil {
				log.Fatal(errors.Wrap(err, "could not detect users home directory"))
			}

			caCert, err := ioutil.ReadFile(filepath.Join(home, ".vmproxy", "cert.pem"))
			if err != nil {
				log.Fatal(err)
			}
			caCertPool := x509.NewCertPool()
			caCertPool.AppendCertsFromPEM(caCert)

			client := &http.Client{
				Transport: &http.Transport{
					TLSClientConfig: &tls.Config{
						RootCAs: caCertPool,
					},
				},
			}

			req, err := http.NewRequest("GET", "https://"+host+":"+port+"/vbox/version", nil)

			resp, err := client.Do(req)
			assert(err)

			respBody, _ := ioutil.ReadAll(resp.Body)

			fmt.Print(string(respBody))
		} else {
			cmd.Help()
			os.Exit(0)
		}
	},
}

RootCmd represents the base command when called without any subcommands

View Source
var Type string

Type vm start mode

Functions

func Execute

func Execute()

Execute adds all child commands to the root command sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL