-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient.go
35 lines (26 loc) · 916 Bytes
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main
import (
"compute-api/compute"
"fmt"
"os"
)
const (
// EnvComputeUser is the name of the DD_COMPUTE_USER environment variable.
EnvComputeUser = "DD_COMPUTE_USER"
// EnvComputePassword is the name of the DD_COMPUTE_PASSWORD environment variable.
EnvComputePassword = "DD_COMPUTE_PASSWORD"
)
func createClient(options programOptions) (client *compute.Client, err error) {
username := os.Getenv(EnvComputeUser)
if isEmpty(username) {
err = fmt.Errorf("The %s environment variable is not defined. Please set it to the CloudControl user name you wish to use.", EnvComputeUser)
return
}
password := os.Getenv(EnvComputePassword)
if isEmpty(password) {
err = fmt.Errorf("The %s environment variable is not defined. Please set it to the CloudControl password you wish to use.", EnvComputePassword)
return
}
client = compute.NewClient(options.Region, username, password)
return
}