1.0.0
This commit is contained in:
43
internal/client/client.go
Normal file
43
internal/client/client.go
Normal file
@@ -0,0 +1,43 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user