Skip to content

Commit

Permalink
improve func names
Browse files Browse the repository at this point in the history
  • Loading branch information
tcarreira committed Aug 16, 2022
1 parent 6c14b03 commit 69c3570
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
9 changes: 4 additions & 5 deletions internal/provider/resource_rpaas_autoscale.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (

func resourceRpaasAutoscale() *schema.Resource {
return &schema.Resource{
CreateContext: resourceRpaasAutoscaleUpdate,
CreateContext: resourceRpaasAutoscaleUpsert,
ReadContext: resourceRpaasAutoscaleRead,
UpdateContext: resourceRpaasAutoscaleUpdate,
UpdateContext: resourceRpaasAutoscaleUpsert,
DeleteContext: resourceRpaasAutoscaleDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
Expand Down Expand Up @@ -56,8 +56,7 @@ func resourceRpaasAutoscale() *schema.Resource {
}
}

func resourceRpaasAutoscaleUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
// Create or Update
func resourceRpaasAutoscaleUpsert(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
provider := meta.(*rpaasProvider)

instance := d.Get("instance").(string)
Expand Down Expand Up @@ -85,7 +84,7 @@ func resourceRpaasAutoscaleUpdate(ctx context.Context, d *schema.ResourceData, m
}

err = rpaasRetry(ctx, d, func() error {
return rpaasClient.UpdateAutoscale(ctx, args)
return rpaasClient.UpdateAutoscale(ctx, args) // UpdateAutoscale is really an Upsert
})

if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions internal/provider/resource_rpaas_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ var validBlocks = []string{"root", "http", "server", "lua-server", "lua-worker"}

func resourceRpaasBlock() *schema.Resource {
return &schema.Resource{
CreateContext: resourceRpaasBlockCreate,
CreateContext: resourceRpaasBlockUpsert,
ReadContext: resourceRpaasBlockRead,
UpdateContext: resourceRpaasBlockCreate,
UpdateContext: resourceRpaasBlockUpsert,
DeleteContext: resourceRpaasBlockDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
Expand Down Expand Up @@ -66,7 +66,7 @@ func resourceRpaasBlock() *schema.Resource {
}
}

func resourceRpaasBlockCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func resourceRpaasBlockUpsert(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
provider := meta.(*rpaasProvider)

instance := d.Get("instance").(string)
Expand All @@ -85,7 +85,7 @@ func resourceRpaasBlockCreate(ctx context.Context, d *schema.ResourceData, meta
}

err = rpaasRetry(ctx, d, func() error {
return rpaasClient.UpdateBlock(ctx, args)
return rpaasClient.UpdateBlock(ctx, args) // UpdateBlock is really an Upsert
})

if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions internal/provider/resource_rpaas_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import (

func resourceRpaasRoute() *schema.Resource {
return &schema.Resource{
CreateContext: resourceRpaasRouteCreate,
CreateContext: resourceRpaasRouteUpsert,
ReadContext: resourceRpaasRouteRead,
UpdateContext: resourceRpaasRouteCreate,
UpdateContext: resourceRpaasRouteUpsert,
DeleteContext: resourceRpaasRouteDelete,
Importer: &schema.ResourceImporter{
StateContext: schema.ImportStatePassthroughContext,
Expand Down Expand Up @@ -66,7 +66,7 @@ func resourceRpaasRoute() *schema.Resource {
}
}

func resourceRpaasRouteCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
func resourceRpaasRouteUpsert(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
provider := meta.(*rpaasProvider)

serviceName := d.Get("service_name").(string)
Expand All @@ -93,7 +93,7 @@ func resourceRpaasRouteCreate(ctx context.Context, d *schema.ResourceData, meta
}

err = rpaasRetry(ctx, d, func() error {
return rpaasClient.UpdateRoute(ctx, args)
return rpaasClient.UpdateRoute(ctx, args) // UpdateRoute is really an Upsert
})
if err != nil {
return diag.Errorf("Unable to create/update route %s for instance %s: %v", path, instance, err)
Expand Down

0 comments on commit 69c3570

Please sign in to comment.