Skip to content

Commit

Permalink
removed waiting time for function resource
Browse files Browse the repository at this point in the history
  • Loading branch information
dgomez04 committed Dec 3, 2024
1 parent d23cdc4 commit fcd33dd
Showing 1 changed file with 0 additions and 32 deletions.
32 changes: 0 additions & 32 deletions internal/providers/pluginfw/products/catalog/resource_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,15 @@ package catalog

import (
"context"
"fmt"
"time"

"github.com/databricks/databricks-sdk-go"
"github.com/databricks/databricks-sdk-go/apierr"
"github.com/databricks/databricks-sdk-go/retries"
"github.com/databricks/databricks-sdk-go/service/catalog"
"github.com/databricks/terraform-provider-databricks/common"
pluginfwcommon "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/common"
pluginfwcontext "github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/context"
"github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/converters"
"github.com/databricks/terraform-provider-databricks/internal/providers/pluginfw/tfschema"
"github.com/databricks/terraform-provider-databricks/internal/service/catalog_tf"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
Expand All @@ -29,28 +24,6 @@ func ResourceFunction() resource.Resource {
return &FunctionResource{}
}

func waitForFunction(ctx context.Context, w *databricks.WorkspaceClient, funcInfo *catalog.FunctionInfo) diag.Diagnostics {
const timeout = 5 * time.Minute

result, err := retries.Poll[catalog.FunctionInfo](ctx, timeout, func() (*catalog.FunctionInfo, *retries.Err) {
attempt, err := w.Functions.GetByName(ctx, funcInfo.FullName)
if err != nil {
if apierr.IsMissing(err) {
return nil, retries.Continue(fmt.Errorf("function %s is not yet available", funcInfo.FullName))
}
return nil, retries.Halt(fmt.Errorf("failed to get function: %s", err))
}
return attempt, nil
})

if err != nil {
return diag.Diagnostics{diag.NewErrorDiagnostic("failed to create function", err.Error())}
}

*funcInfo = *result
return nil
}

type FunctionResource struct {
Client *common.DatabricksClient
}
Expand Down Expand Up @@ -129,11 +102,6 @@ func (r *FunctionResource) Create(ctx context.Context, req resource.CreateReques
return
}

resp.Diagnostics.Append(waitForFunction(ctx, w, funcInfo)...)
if resp.Diagnostics.HasError() {
return
}

resp.Diagnostics.Append(converters.GoSdkToTfSdkStruct(ctx, funcInfo, &planFunc)...)
if resp.Diagnostics.HasError() {
return
Expand Down

0 comments on commit fcd33dd

Please sign in to comment.