// Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 package provider import ( "context" "github.com/hashicorp/terraform-plugin-framework/datasource" "github.com/hashicorp/terraform-plugin-framework/provider" "github.com/hashicorp/terraform-plugin-framework/provider/schema" "github.com/hashicorp/terraform-plugin-framework/resource" ) // Ensure hashicupsProvider satisfies various provider interfaces. var _ provider.Provider = &hashicupsProvider{} // New is a helper function to simplify provider server and testing implementation. func New(version string) func() provider.Provider { return func() provider.Provider { return &hashicupsProvider{ version: version, } } } // hashicupsProvider defines the provider implementation. type hashicupsProvider struct { // version is set to the provider version on release, "dev" when the // provider is built and ran locally, and "test" when running acceptance // testing. version string } func (p *hashicupsProvider) Metadata(_ context.Context, _ provider.MetadataRequest, resp *provider.MetadataResponse) { resp.TypeName = "hashicups" resp.Version = p.version } func (p *hashicupsProvider) Schema(_ context.Context, _ provider.SchemaRequest, resp *provider.SchemaResponse) { resp.Schema = schema.Schema{} } func (p *hashicupsProvider) Configure(_ context.Context, _ provider.ConfigureRequest, _ *provider.ConfigureResponse) { } func (p *hashicupsProvider) DataSources(_ context.Context) []func() datasource.DataSource { return nil } func (p *hashicupsProvider) Resources(_ context.Context) []func() resource.Resource { return nil } //// Ensure hashicupsProvider satisfies various provider interfaces. //var _ provider.Provider = &hashicupsProvider{} //var _ provider.ProviderWithFunctions = &hashicupsProvider{} // //// hashicupsProvider defines the provider implementation. //type hashicupsProvider struct { // // version is set to the provider version on release, "dev" when the // // provider is built and ran locally, and "test" when running acceptance // // testing. // version string //} // //// ScaffoldingProviderModel describes the provider data model. //type ScaffoldingProviderModel struct { // Endpoint types.String `tfsdk:"endpoint"` //} // //func (p *hashicupsProvider) Metadata(ctx context.Context, req provider.MetadataRequest, resp *provider.MetadataResponse) { // resp.TypeName = "scaffolding" // resp.Version = p.version //} // //func (p *hashicupsProvider) Schema(ctx context.Context, req provider.SchemaRequest, resp *provider.SchemaResponse) { // resp.Schema = schema.Schema{ // Attributes: map[string]schema.Attribute{ // "endpoint": schema.StringAttribute{ // MarkdownDescription: "Example provider attribute", // Optional: true, // }, // }, // } //} // //func (p *hashicupsProvider) Configure(ctx context.Context, req provider.ConfigureRequest, resp *provider.ConfigureResponse) { // var data ScaffoldingProviderModel // // resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) // // if resp.Diagnostics.HasError() { // return // } // // // Configuration values are now available. // // if data.Endpoint.IsNull() { /* ... */ } // // // Example client configuration for data sources and resources // client := http.DefaultClient // resp.DataSourceData = client // resp.ResourceData = client //} // //func (p *hashicupsProvider) Resources(ctx context.Context) []func() resource.Resource { // return []func() resource.Resource{ // NewExampleResource, // } //} // //func (p *hashicupsProvider) DataSources(ctx context.Context) []func() datasource.DataSource { // return []func() datasource.DataSource{ // NewExampleDataSource, // } //} // //func (p *hashicupsProvider) Functions(ctx context.Context) []func() function.Function { // return []func() function.Function{ // NewExampleFunction, // } //} // //func New(version string) func() provider.Provider { // return func() provider.Provider { // return &hashicupsProvider{ // version: version, // } // } //}