-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
106 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
page_title: "Data Source: auth0_provider" | ||
description: |- | ||
A data source for retrieving basic information about the provider. | ||
--- | ||
|
||
# Data Source: auth0_provider | ||
|
||
A data source for retrieving basic information about the provider. | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Read-Only | ||
|
||
- `provider_version` (String) The version of the provider. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package provider | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/hashicorp/terraform-plugin-framework/datasource" | ||
"github.com/hashicorp/terraform-plugin-framework/datasource/schema" | ||
"github.com/hashicorp/terraform-plugin-framework/path" | ||
|
||
"github.com/auth0/terraform-provider-auth0/internal/config" | ||
) | ||
|
||
type providerDataSource struct { | ||
cfg *config.Config | ||
} | ||
|
||
// NewDataSource will return a new auth0_provider data source. | ||
func NewDataSource() datasource.DataSource { | ||
return &providerDataSource{} | ||
} | ||
|
||
// Configure will be called by the framework to configure the auth0_provider data source. | ||
func (r *providerDataSource) Configure(_ context.Context, request datasource.ConfigureRequest, _ *datasource.ConfigureResponse) { | ||
if request.ProviderData != nil { | ||
r.cfg = request.ProviderData.(*config.Config) | ||
} | ||
} | ||
|
||
// Metadata will be called by the framework to get the type name for the auth0_encryption_key_manager datasource. | ||
func (r *providerDataSource) Metadata(_ context.Context, _ datasource.MetadataRequest, response *datasource.MetadataResponse) { | ||
response.TypeName = "auth0_provider" | ||
} | ||
|
||
// Schema will be called by the framework to get the schema name for the auth0_encryption_key_manager datasource. | ||
func (r *providerDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, response *datasource.SchemaResponse) { | ||
if response != nil { | ||
response.Schema = schema.Schema{ | ||
Description: "A data source for retrieving basic information about the provider.", | ||
MarkdownDescription: "A data source for retrieving basic information about the provider.", | ||
Attributes: map[string]schema.Attribute{ | ||
"provider_version": schema.StringAttribute{ | ||
Computed: true, | ||
Description: "The version of the provider. ", | ||
MarkdownDescription: "The version of the provider. ", | ||
}, | ||
}, | ||
} | ||
} | ||
} | ||
|
||
// Read will be called by the framework to read an auth0_encryption_key_manager data source. | ||
func (r *providerDataSource) Read(ctx context.Context, _ datasource.ReadRequest, response *datasource.ReadResponse) { | ||
response.Diagnostics.Append(response.State.SetAttribute(ctx, path.Root("provider_version"), config.GetProviderVersion())...) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package provider_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
|
||
"github.com/auth0/terraform-provider-auth0/internal/acctest" | ||
) | ||
|
||
const testAccDataSourceProvider = ` | ||
data "auth0_provider" "my_provider" { | ||
} | ||
` | ||
|
||
func TestAccFrameworkDataSourceProvider(t *testing.T) { | ||
resource.UnitTest(t, resource.TestCase{ | ||
// This is primarily here to allow us to test the regular provider instantiation flow. | ||
ProtoV6ProviderFactories: acctest.TestProviderFactories(), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: acctest.ParseTestName(testAccDataSourceProvider, t.Name()), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttrSet("data.auth0_provider.my_provider", "provider_version"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters