Making all function names consistent
Before all providers were using the helper.Schema approach the helper function had these names. Now they all use names consistent with the Go naming conventions except for these last few…
This commit is contained in:
parent
69b2c245dd
commit
4ace4865d7
|
@ -96,7 +96,7 @@ func resourceConsulKeysCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
} else {
|
||||
log.Printf("[DEBUG] Resolving Consul datacenter...")
|
||||
var err error
|
||||
dc, err = get_dc(client)
|
||||
dc, err = getDC(client)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ func resourceConsulKeysCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
// Extract the keys
|
||||
keys := d.Get("key").(*schema.Set).List()
|
||||
for _, raw := range keys {
|
||||
key, path, sub, err := parse_key(raw)
|
||||
key, path, sub, err := parseKey(raw)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ func resourceConsulKeysCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("Failed to get Consul key '%s': %v", path, err)
|
||||
}
|
||||
value := attribute_value(sub, key, pair)
|
||||
value := attributeValue(sub, key, pair)
|
||||
vars[key] = value
|
||||
}
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ func resourceConsulKeysRead(d *schema.ResourceData, meta interface{}) error {
|
|||
// Extract the keys
|
||||
keys := d.Get("key").(*schema.Set).List()
|
||||
for _, raw := range keys {
|
||||
key, path, sub, err := parse_key(raw)
|
||||
key, path, sub, err := parseKey(raw)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ func resourceConsulKeysRead(d *schema.ResourceData, meta interface{}) error {
|
|||
return fmt.Errorf("Failed to get value for path '%s' from Consul: %v", path, err)
|
||||
}
|
||||
|
||||
value := attribute_value(sub, key, pair)
|
||||
value := attributeValue(sub, key, pair)
|
||||
vars[key] = value
|
||||
sub["value"] = value
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ func resourceConsulKeysDelete(d *schema.ResourceData, meta interface{}) error {
|
|||
// Extract the keys
|
||||
keys := d.Get("key").(*schema.Set).List()
|
||||
for _, raw := range keys {
|
||||
_, path, sub, err := parse_key(raw)
|
||||
_, path, sub, err := parseKey(raw)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -243,8 +243,8 @@ func resourceConsulKeysDelete(d *schema.ResourceData, meta interface{}) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// parse_key is used to parse a key into a name, path, config or error
|
||||
func parse_key(raw interface{}) (string, string, map[string]interface{}, error) {
|
||||
// parseKey is used to parse a key into a name, path, config or error
|
||||
func parseKey(raw interface{}) (string, string, map[string]interface{}, error) {
|
||||
sub, ok := raw.(map[string]interface{})
|
||||
if !ok {
|
||||
return "", "", nil, fmt.Errorf("Failed to unroll: %#v", raw)
|
||||
|
@ -262,9 +262,9 @@ func parse_key(raw interface{}) (string, string, map[string]interface{}, error)
|
|||
return key, path, sub, nil
|
||||
}
|
||||
|
||||
// attribute_value determines the value for a key, potentially
|
||||
// attributeValue determines the value for a key, potentially
|
||||
// using a default value if provided.
|
||||
func attribute_value(sub map[string]interface{}, key string, pair *consulapi.KVPair) string {
|
||||
func attributeValue(sub map[string]interface{}, key string, pair *consulapi.KVPair) string {
|
||||
// Use the value if given
|
||||
if pair != nil {
|
||||
return string(pair.Value)
|
||||
|
@ -284,8 +284,8 @@ func attribute_value(sub map[string]interface{}, key string, pair *consulapi.KVP
|
|||
return ""
|
||||
}
|
||||
|
||||
// get_dc is used to get the datacenter of the local agent
|
||||
func get_dc(client *consulapi.Client) (string, error) {
|
||||
// getDC is used to get the datacenter of the local agent
|
||||
func getDC(client *consulapi.Client) (string, error) {
|
||||
info, err := client.Agent().Self()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Failed to get datacenter from Consul agent: %v", err)
|
||||
|
|
|
@ -229,7 +229,7 @@ func resourceDigitalOceanDropletUpdate(d *schema.ResourceData, meta interface{})
|
|||
err = client.Resize(d.Id(), newSize.(string))
|
||||
|
||||
if err != nil {
|
||||
newErr := power_on_and_wait(d, meta)
|
||||
newErr := powerOnAndWait(d, meta)
|
||||
if newErr != nil {
|
||||
return fmt.Errorf(
|
||||
"Error powering on droplet (%s) after failed resize: %s", d.Id(), err)
|
||||
|
@ -243,7 +243,7 @@ func resourceDigitalOceanDropletUpdate(d *schema.ResourceData, meta interface{})
|
|||
d, newSize.(string), []string{"", oldSize.(string)}, "size", meta)
|
||||
|
||||
if err != nil {
|
||||
newErr := power_on_and_wait(d, meta)
|
||||
newErr := powerOnAndWait(d, meta)
|
||||
if newErr != nil {
|
||||
return fmt.Errorf(
|
||||
"Error powering on droplet (%s) after waiting for resize to finish: %s", d.Id(), err)
|
||||
|
@ -359,7 +359,7 @@ func WaitForDropletAttribute(
|
|||
stateConf := &resource.StateChangeConf{
|
||||
Pending: pending,
|
||||
Target: target,
|
||||
Refresh: new_droplet_state_refresh_func(d, attribute, meta),
|
||||
Refresh: newDropletStateRefreshFunc(d, attribute, meta),
|
||||
Timeout: 10 * time.Minute,
|
||||
Delay: 10 * time.Second,
|
||||
MinTimeout: 3 * time.Second,
|
||||
|
@ -370,7 +370,7 @@ func WaitForDropletAttribute(
|
|||
|
||||
// TODO This function still needs a little more refactoring to make it
|
||||
// cleaner and more efficient
|
||||
func new_droplet_state_refresh_func(
|
||||
func newDropletStateRefreshFunc(
|
||||
d *schema.ResourceData, attribute string, meta interface{}) resource.StateRefreshFunc {
|
||||
client := meta.(*digitalocean.Client)
|
||||
return func() (interface{}, string, error) {
|
||||
|
@ -405,7 +405,7 @@ func new_droplet_state_refresh_func(
|
|||
}
|
||||
|
||||
// Powers on the droplet and waits for it to be active
|
||||
func power_on_and_wait(d *schema.ResourceData, meta interface{}) error {
|
||||
func powerOnAndWait(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*digitalocean.Client)
|
||||
err := client.PowerOn(d.Id())
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ func resourceHerokuAddonCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
func resourceHerokuAddonRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*heroku.Service)
|
||||
|
||||
addon, err := resource_heroku_addon_retrieve(
|
||||
addon, err := resourceHerokuAddonRetrieve(
|
||||
d.Get("app").(string), d.Id(), client)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -153,7 +153,7 @@ func resourceHerokuAddonDelete(d *schema.ResourceData, meta interface{}) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func resource_heroku_addon_retrieve(app string, id string, client *heroku.Service) (*heroku.Addon, error) {
|
||||
func resourceHerokuAddonRetrieve(app string, id string, client *heroku.Service) (*heroku.Addon, error) {
|
||||
addon, err := client.AddonInfo(app, id)
|
||||
|
||||
if err != nil {
|
||||
|
|
|
@ -28,7 +28,7 @@ func (a *application) Update() error {
|
|||
errs = append(errs, err)
|
||||
}
|
||||
|
||||
a.Vars, err = retrieve_config_vars(a.Id, a.Client)
|
||||
a.Vars, err = retrieveConfigVars(a.Id, a.Client)
|
||||
if err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ func resourceHerokuAppCreate(d *schema.ResourceData, meta interface{}) error {
|
|||
log.Printf("[INFO] App ID: %s", d.Id())
|
||||
|
||||
if v, ok := d.GetOk("config_vars"); ok {
|
||||
err = update_config_vars(d.Id(), client, nil, v.([]interface{}))
|
||||
err = updateConfigVars(d.Id(), client, nil, v.([]interface{}))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -225,7 +225,7 @@ func resourceHerokuOrgAppCreate(d *schema.ResourceData, meta interface{}) error
|
|||
log.Printf("[INFO] App ID: %s", d.Id())
|
||||
|
||||
if v, ok := d.GetOk("config_vars"); ok {
|
||||
err = update_config_vars(d.Id(), client, nil, v.([]interface{}))
|
||||
err = updateConfigVars(d.Id(), client, nil, v.([]interface{}))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ func resourceHerokuOrgAppCreate(d *schema.ResourceData, meta interface{}) error
|
|||
|
||||
func resourceHerokuAppRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*heroku.Service)
|
||||
app, err := resource_heroku_app_retrieve(d.Id(), client)
|
||||
app, err := resourceHerokuAppRetrieve(d.Id(), client)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ func resourceHerokuAppUpdate(d *schema.ResourceData, meta interface{}) error {
|
|||
n = []interface{}{}
|
||||
}
|
||||
|
||||
err := update_config_vars(
|
||||
err := updateConfigVars(
|
||||
d.Id(), client, o.([]interface{}), n.([]interface{}))
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -327,7 +327,7 @@ func resourceHerokuAppDelete(d *schema.ResourceData, meta interface{}) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func resource_heroku_app_retrieve(id string, client *heroku.Service) (*application, error) {
|
||||
func resourceHerokuAppRetrieve(id string, client *heroku.Service) (*application, error) {
|
||||
app := application{Id: id, Client: client}
|
||||
|
||||
err := app.Update()
|
||||
|
@ -339,7 +339,7 @@ func resource_heroku_app_retrieve(id string, client *heroku.Service) (*applicati
|
|||
return &app, nil
|
||||
}
|
||||
|
||||
func retrieve_config_vars(id string, client *heroku.Service) (map[string]string, error) {
|
||||
func retrieveConfigVars(id string, client *heroku.Service) (map[string]string, error) {
|
||||
vars, err := client.ConfigVarInfo(id)
|
||||
|
||||
if err != nil {
|
||||
|
@ -350,7 +350,7 @@ func retrieve_config_vars(id string, client *heroku.Service) (map[string]string,
|
|||
}
|
||||
|
||||
// Updates the config vars for from an expanded configuration.
|
||||
func update_config_vars(
|
||||
func updateConfigVars(
|
||||
id string,
|
||||
client *heroku.Service,
|
||||
o []interface{},
|
||||
|
|
|
@ -123,7 +123,7 @@ func resourceMailgunDomainCreate(d *schema.ResourceData, meta interface{}) error
|
|||
log.Printf("[INFO] Domain ID: %s", d.Id())
|
||||
|
||||
// Retrieve and update state of domain
|
||||
_, err = resource_mailgin_domain_retrieve(d.Id(), client, d)
|
||||
_, err = resourceMailginDomainRetrieve(d.Id(), client, d)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -149,7 +149,7 @@ func resourceMailgunDomainDelete(d *schema.ResourceData, meta interface{}) error
|
|||
func resourceMailgunDomainRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*mailgun.Client)
|
||||
|
||||
_, err := resource_mailgin_domain_retrieve(d.Id(), client, d)
|
||||
_, err := resourceMailginDomainRetrieve(d.Id(), client, d)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -158,7 +158,7 @@ func resourceMailgunDomainRead(d *schema.ResourceData, meta interface{}) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func resource_mailgin_domain_retrieve(id string, client *mailgun.Client, d *schema.ResourceData) (*mailgun.DomainResponse, error) {
|
||||
func resourceMailginDomainRetrieve(id string, client *mailgun.Client, d *schema.ResourceData) (*mailgun.DomainResponse, error) {
|
||||
resp, err := client.RetrieveDomain(id)
|
||||
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue