Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sauterp committed Jul 26, 2024
1 parent e6ebf61 commit 27cb540
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions pkg/resources/instance/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,21 +217,6 @@ func Resource() *schema.Resource {
}
}

func findInstanceType(ctx context.Context, c *v3.Client, x string) (*v3.InstanceType, error) {
res, err := c.ListInstanceTypes(ctx)
if err != nil {
return nil, err
}

for _, r := range res.InstanceTypes {
if r.ID.String() == x {
return c.GetInstanceType(ctx, r.ID)
}
}

return nil, v3.ErrNotFound
}

func rCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { //nolint:gocyclo
tflog.Debug(ctx, "beginning create", map[string]interface{}{
"id": utils.IDString(d, Name),
Expand Down Expand Up @@ -1022,7 +1007,12 @@ func rApply( //nolint:gocyclo
return diag.FromErr(err)
}

instanceType, err := findInstanceType(ctx, clientV3, instance.InstanceType.ID.String())
instanceTypes, err := clientV3.ListInstanceTypes(ctx)
if err != nil {
return diag.Errorf("unable to find instance type: %s", err)
}

instanceType, err := instanceTypes.FindInstanceType(instance.InstanceType.ID.String())
if err != nil {
return diag.Errorf("unable to find instance type: %s", err)
}
Expand Down

0 comments on commit 27cb540

Please sign in to comment.