You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.3 KiB

package client
import (
"context"
"fmt"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-log/tflog"
decort "repository.basistech.ru/BASIS/decort-golang-sdk"
)
func DataSource(ctx context.Context, req *datasource.ConfigureRequest, resp *datasource.ConfigureResponse) *decort.DecortClient {
if req.ProviderData == nil {
tflog.Error(ctx, "Provider Configure is nill")
return nil
}
client, ok := req.ProviderData.(*decort.DecortClient)
if !ok {
resp.Diagnostics.AddError(
"Unexpected Data Source Configure Type",
fmt.Sprintf("Expected *decort.DecortClient, got: %T. Please report this issue to the provider developers.", req.ProviderData),
)
return nil
}
return client
}
func Resource(ctx context.Context, req *resource.ConfigureRequest, resp *resource.ConfigureResponse) *decort.DecortClient {
if req.ProviderData == nil {
tflog.Error(ctx, "Provider Configure is nill")
return nil
}
client, ok := req.ProviderData.(*decort.DecortClient)
if !ok {
resp.Diagnostics.AddError(
"Unexpected Data Source Configure Type",
fmt.Sprintf("Expected *decort.DecortClient, got: %T. Please report this issue to the provider developers.", req.ProviderData),
)
return nil
}
return client
}