Samuel A. Falvo II | 704a750 | 2013-07-10 15:23:43 -0700 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "os" |
| 6 | ) |
| 7 | |
| 8 | // getCredentials will verify existence of needed credential information |
| 9 | // provided through environment variables. This function will not return |
| 10 | // if at least one piece of required information is missing. |
| 11 | func getCredentials() (provider, username, password string) { |
| 12 | provider = os.Getenv("SDK_PROVIDER") |
| 13 | username = os.Getenv("SDK_USERNAME") |
| 14 | password = os.Getenv("SDK_PASSWORD") |
| 15 | |
| 16 | if (provider == "") || (username == "") || (password == "") { |
| 17 | fmt.Fprintf(os.Stderr, "One or more of the following environment variables aren't set:\n") |
| 18 | fmt.Fprintf(os.Stderr, " SDK_PROVIDER=\"%s\"\n", provider) |
| 19 | fmt.Fprintf(os.Stderr, " SDK_USERNAME=\"%s\"\n", username) |
| 20 | fmt.Fprintf(os.Stderr, " SDK_PASSWORD=\"%s\"\n", password) |
| 21 | os.Exit(1) |
| 22 | } |
| 23 | |
| 24 | return |
| 25 | } |