コード例 #1
0
func resource_digitalocean_record_update(
	s *terraform.ResourceState,
	d *terraform.ResourceDiff,
	meta interface{}) (*terraform.ResourceState, error) {
	p := meta.(*ResourceProvider)
	client := p.client
	rs := s.MergeDiff(d)

	updateRecord := digitalocean.UpdateRecord{}

	if attr, ok := d.Attributes["name"]; ok {
		updateRecord.Name = attr.New
	}

	log.Printf("[DEBUG] record update configuration: %#v", updateRecord)

	err := client.UpdateRecord(rs.Attributes["domain"], rs.ID, &updateRecord)
	if err != nil {
		return rs, fmt.Errorf("Failed to update record: %s", err)
	}

	record, err := resource_digitalocean_record_retrieve(rs.Attributes["domain"], rs.ID, client)
	if err != nil {
		return rs, fmt.Errorf("Couldn't find record: %s", err)
	}

	return resource_digitalocean_record_update_state(rs, record)
}
コード例 #2
0
func resourceDigitalOceanRecordUpdate(d *schema.ResourceData, meta interface{}) error {
	client := meta.(*digitalocean.Client)

	var updateRecord digitalocean.UpdateRecord
	if v, ok := d.GetOk("name"); ok {
		updateRecord.Name = v.(string)
	}

	log.Printf("[DEBUG] record update configuration: %#v", updateRecord)
	err := client.UpdateRecord(d.Get("domain").(string), d.Id(), &updateRecord)
	if err != nil {
		return fmt.Errorf("Failed to update record: %s", err)
	}

	return resourceDigitalOceanRecordRead(d, meta)
}