func providerConfigure(d *schema.ResourceData) (interface{}, error) { un := d.Get("username").(string) pw := d.Get("password").(string) config, err := api.NewConfig(un, pw) if err != nil { return nil, fmt.Errorf("Failed to create CLC config with provided details: %v", err) } config.UserAgent = fmt.Sprintf("terraform-clc terraform/%s", terraform.Version) // user requested alias override or sub-account if al := d.Get("account").(string); al != "" { config.Alias = al } client := clc.New(config) if err := client.Authenticate(); err != nil { return nil, fmt.Errorf("Failed authenticated with provided credentials: %v", err) } alerts, err := client.Alert.GetAll() if err != nil { return nil, fmt.Errorf("Failed to connect to the CLC api because %s", err) } for _, a := range alerts.Items { log.Printf("[WARN] Received alert: %v", a) } return client, nil }
func providerConfigure(d *schema.ResourceData) (interface{}, error) { un := d.Get("username").(string) pw := d.Get("password").(string) ac := d.Get("account").(string) url := d.Get("url").(string) config, config_err := api.NewConfig(un, pw, ac, url) if config_err != nil { return nil, fmt.Errorf("Failed to create CLC config with provided details: %v", config_err) } client := clc.New(config) err := client.Authenticate() if err != nil { return nil, fmt.Errorf("Failed authenticated with provided credentials: %v", err) } alerts, err := client.Alert.GetAll() if err != nil { return nil, fmt.Errorf("Failed to connect to the CLC api because %s", err) } for _, a := range alerts.Items { log.Printf("[WARN] Received alert: %v", a) } return client, nil }