51 lines
1.4 KiB
Go
51 lines
1.4 KiB
Go
package ganeti
|
|
|
|
import (
|
|
"context"
|
|
|
|
rapi "burntworld.ca/go-rapi-client"
|
|
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
|
|
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
|
|
)
|
|
|
|
func resourceInstance() *schema.Resource {
|
|
return &schema.Resource{
|
|
CreateContext: resourceInstanceCreate,
|
|
ReadContext: resourceInstanceRead,
|
|
UpdateContext: resourceInstanceUpdate,
|
|
DeleteContext: resourceInstanceDelete,
|
|
}
|
|
}
|
|
|
|
func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
|
// Warning or errors can be collected in a slice type
|
|
var diags diag.Diagnostics
|
|
return diags
|
|
}
|
|
|
|
func resourceInstanceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
|
// Warning or errors can be collected in a slice type
|
|
var diags diag.Diagnostics
|
|
client := m.(*rapi.Client)
|
|
instances, err := client.GetInstancesBulk()
|
|
if err != nil {
|
|
return diag.FromErr(err)
|
|
}
|
|
|
|
if err = d.Set("instances", instances); err != nil {
|
|
return diag.FromErr(err)
|
|
}
|
|
return diags
|
|
}
|
|
|
|
func resourceInstanceUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
|
return resourceInstanceRead(ctx, d, m)
|
|
}
|
|
|
|
func resourceInstanceDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
|
|
// Warning or errors can be collected in a slice type
|
|
var diags diag.Diagnostics
|
|
|
|
return diags
|
|
}
|