Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dependencies - update terraform-plugin-* dependencies #27936

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
47 changes: 25 additions & 22 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ require (
github.com/hashicorp/go-hclog v1.6.3
github.com/hashicorp/go-multierror v1.1.1
github.com/hashicorp/go-uuid v1.0.3
github.com/hashicorp/go-version v1.6.0
github.com/hashicorp/terraform-plugin-framework v1.8.0
github.com/hashicorp/terraform-plugin-framework-validators v0.12.0
github.com/hashicorp/terraform-plugin-go v0.23.0
github.com/hashicorp/terraform-plugin-mux v0.15.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0
github.com/hashicorp/go-version v1.7.0
github.com/hashicorp/terraform-plugin-framework v1.13.0
github.com/hashicorp/terraform-plugin-framework-validators v0.14.0
github.com/hashicorp/terraform-plugin-go v0.25.0
github.com/hashicorp/terraform-plugin-mux v0.17.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.35.0
github.com/hashicorp/terraform-plugin-testing v1.8.0
github.com/jackofallops/kermit v0.20241010.1180132
github.com/magodo/terraform-provider-azurerm-example-gen v0.0.0-20220407025246-3a3ee0ab24a8
Expand All @@ -36,8 +36,8 @@ require (
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3
github.com/tombuildsstuff/giovanni v0.27.0
github.com/tombuildsstuff/kermit v0.20240122.1123108
golang.org/x/crypto v0.23.0
golang.org/x/tools v0.19.0
golang.org/x/crypto v0.28.0
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d
gopkg.in/yaml.v3 v3.0.1
)

Expand All @@ -55,14 +55,14 @@ require (
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
github.com/hashicorp/go-plugin v1.6.0 // indirect
github.com/hashicorp/go-plugin v1.6.2 // indirect
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
github.com/hashicorp/hc-install v0.6.4 // indirect
github.com/hashicorp/hcl/v2 v2.20.1 // indirect
github.com/hashicorp/hc-install v0.9.0 // indirect
github.com/hashicorp/hcl/v2 v2.22.0 // indirect
github.com/hashicorp/hcl2 v0.0.0-20191002203319-fb75b3253c80 // indirect
github.com/hashicorp/logutils v1.0.0 // indirect
github.com/hashicorp/terraform-exec v0.21.0 // indirect
github.com/hashicorp/terraform-json v0.22.1 // indirect
github.com/hashicorp/terraform-json v0.23.0 // indirect
github.com/hashicorp/terraform-plugin-log v0.9.0 // indirect
github.com/hashicorp/terraform-registry-address v0.2.3 // indirect
github.com/hashicorp/terraform-svchost v0.1.1 // indirect
Expand All @@ -80,18 +80,21 @@ require (
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/zclconf/go-cty v1.14.4 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/oauth2 v0.17.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
github.com/zclconf/go-cty v1.15.0 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/grpc v1.63.2 // indirect
google.golang.org/protobuf v1.34.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/grpc v1.67.1 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
software.sslmate.com/src/go-pkcs12 v0.4.0 // indirect
)

go 1.22
go 1.22.0

toolchain go1.22.7
99 changes: 49 additions & 50 deletions go.sum

Large diffs are not rendered by default.

21 changes: 4 additions & 17 deletions internal/acceptance/testcase.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
package acceptance

import (
"context"
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/plancheck"
"github.com/hashicorp/terraform-plugin-testing/terraform"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/helpers"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/testclient"
"github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/types"
"github.com/hashicorp/terraform-provider-azurerm/internal/provider"
"github.com/hashicorp/terraform-provider-azurerm/internal/provider/framework"
)

func (td TestData) DataSourceTest(t *testing.T, steps []TestStep) {
Expand Down Expand Up @@ -168,31 +168,18 @@ func RunTestsInSequence(t *testing.T, tests map[string]map[string]func(t *testin

func (td TestData) runAcceptanceTest(t *testing.T, testCase resource.TestCase) {
testCase.ExternalProviders = td.externalProviders()
testCase.ProviderFactories = td.providers()
testCase.ProtoV5ProviderFactories = framework.ProtoV5ProviderFactoriesInit(context.Background(), "azurerm")

resource.ParallelTest(t, testCase)
}

func (td TestData) runAcceptanceSequentialTest(t *testing.T, testCase resource.TestCase) {
testCase.ExternalProviders = td.externalProviders()
testCase.ProviderFactories = td.providers()
testCase.ProtoV5ProviderFactories = framework.ProtoV5ProviderFactoriesInit(context.Background(), "azurerm")

resource.Test(t, testCase)
}

func (td TestData) providers() map[string]func() (*schema.Provider, error) {
return map[string]func() (*schema.Provider, error){
"azurerm": func() (*schema.Provider, error) { //nolint:unparam
azurerm := provider.TestAzureProvider()
return azurerm, nil
},
"azurerm-alt": func() (*schema.Provider, error) { //nolint:unparam
azurerm := provider.TestAzureProvider()
return azurerm, nil
},
}
}

func (td TestData) externalProviders() map[string]resource.ExternalProvider {
return map[string]resource.ExternalProvider{
"azuread": {
Expand Down
33 changes: 29 additions & 4 deletions internal/provider/framework/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework-validators/listvalidator"
"github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"
"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/ephemeral"
"github.com/hashicorp/terraform-plugin-framework/function"
"github.com/hashicorp/terraform-plugin-framework/provider"
"github.com/hashicorp/terraform-plugin-framework/provider/schema"
Expand All @@ -18,6 +19,8 @@ import (
providerfunction "github.com/hashicorp/terraform-provider-azurerm/internal/provider/function"
"github.com/hashicorp/terraform-provider-azurerm/internal/resourceproviders"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk/frameworkhelpers"

pluginsdkprovider "github.com/hashicorp/terraform-provider-azurerm/internal/provider"
)

type azureRmFrameworkProvider struct {
Expand All @@ -29,6 +32,8 @@ var _ provider.Provider = &azureRmFrameworkProvider{}

var _ provider.ProviderWithFunctions = &azureRmFrameworkProvider{}

var _ provider.ProviderWithEphemeralResources = &azureRmFrameworkProvider{}

func (p *azureRmFrameworkProvider) Functions(_ context.Context) []func() function.Function {
return []func() function.Function{
providerfunction.NewNormaliseResourceIDFunction,
Expand Down Expand Up @@ -492,11 +497,31 @@ func (p *azureRmFrameworkProvider) Configure(ctx context.Context, request provid
}

func (p *azureRmFrameworkProvider) DataSources(_ context.Context) []func() datasource.DataSource {
// We do not currently support any Native framework Data Sources
return nil
var output []func() datasource.DataSource

for _, service := range pluginsdkprovider.SupportedFrameworkServices() {
output = append(output, service.FrameworkDataSources()...)
}

return output
}

func (p *azureRmFrameworkProvider) Resources(_ context.Context) []func() resource.Resource {
// We do not currently support any Native framework Resources
return nil
var output []func() resource.Resource

for _, service := range pluginsdkprovider.SupportedFrameworkServices() {
output = append(output, service.FrameworkResources()...)
}

return output
}

func (p *azureRmFrameworkProvider) EphemeralResources(_ context.Context) []func() ephemeral.EphemeralResource {
var output []func() ephemeral.EphemeralResource

for _, service := range pluginsdkprovider.SupportedFrameworkServices() {
output = append(output, service.EphemeralResources()...)
}

return output
}
10 changes: 10 additions & 0 deletions internal/provider/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,3 +327,13 @@ func SupportedUntypedServices() []sdk.UntypedServiceRegistration {
return out
}()
}

func SupportedFrameworkServices() []sdk.FrameworkTypedServiceRegistration {
services := []sdk.FrameworkTypedServiceRegistration{
// Services with Framework Resources, Data Sources, or Ephemeral Resources to be listed here
// e.g.
// resource.Registration{}
}

return services
}
70 changes: 70 additions & 0 deletions internal/sdk/ephemeral_resource.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package sdk

import (
"context"
"fmt"

"github.com/hashicorp/terraform-plugin-framework/ephemeral"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
)

// EphemeralResource wraps the Framework implementation in an opinionated presentation for the AzureRM provider, where we
// always want a Configure to be present to be able to collect the appropriate metadata from the Provider via the Defaults()
// helper, and optionally override / add settings as needed.
type EphemeralResource interface {
ephemeral.EphemeralResourceWithConfigure
}

// EphemeralResourceWithClose extends the base interface for resources that have/need a Close() method
type EphemeralResourceWithClose interface {
EphemeralResource

ephemeral.EphemeralResourceWithClose
}

// EphemeralResourceWithRenew extends the base interface for resources that have/need a Renew() method
type EphemeralResourceWithRenew interface {
EphemeralResource

ephemeral.EphemeralResourceWithRenew
}

type EphemeralResourceWithConfigurationValidation interface {
EphemeralResource

ephemeral.EphemeralResourceWithConfigValidators
}

type EphemeralResourceMetadata struct {
Client *clients.Client

SubscriptionId string

Features features.UserFeatures
}

// Defaults configures the EphemeralResource Metadata for client access, Provider Features, and subscriptionId.
func (r *EphemeralResourceMetadata) Defaults(req ephemeral.ConfigureRequest, resp *ephemeral.ConfigureResponse) {
if req.ProviderData == nil {
return
}

c, ok := req.ProviderData.(*clients.Client)
if !ok {
resp.Diagnostics.AddError("Client Provider Data Error", fmt.Sprintf("invalid provider data supplied, got %+v", req.ProviderData))
return
}

r.Client = c
r.SubscriptionId = c.Account.SubscriptionId
r.Features = c.Features
}

// DecodeOpen performs a Get on the OpenRequest config and attempts to load it into the interface cfg. cfg *must* be a pointer to the struct.
// returns true if successful, false if there is an error diagnostic raised. Any error diags are written directly to the response
func (r *EphemeralResourceMetadata) DecodeOpen(ctx context.Context, req ephemeral.OpenRequest, resp *ephemeral.OpenResponse, cfg interface{}) bool {
resp.Diagnostics.Append(req.Config.Get(ctx, cfg)...)

return !resp.Diagnostics.HasError()
}
48 changes: 48 additions & 0 deletions internal/sdk/framework_data_source.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package sdk

import (
"context"
"fmt"
"time"

"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
)

type DataSourceMetadata struct {
Client *clients.Client

SubscriptionId string

TimeoutRead time.Duration

Features features.UserFeatures
}

// Defaults configures the Data Source Metadata for client access, Provider Features, and subscriptionId.
func (r *DataSourceMetadata) Defaults(req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) {
if req.ProviderData == nil {
return
}

c, ok := req.ProviderData.(*clients.Client)
if !ok {
resp.Diagnostics.AddError("Client Provider Data Error", fmt.Sprintf("invalid provider data supplied, got %+v", req.ProviderData))
return
}

r.Client = c
r.SubscriptionId = c.Account.SubscriptionId
r.Features = c.Features

r.TimeoutRead = 5 * time.Minute
}

// DecodeRead is a helper function to populate the Data Source model from the user config and writes any diags back to the ReadResponse
// Returns true if there are no Error Diagnostics.
func (r *DataSourceMetadata) DecodeRead(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse, config interface{}) bool {
resp.Diagnostics.Append(req.Config.Get(ctx, config)...)

return !resp.Diagnostics.HasError()
}
Loading