Skip to content

Commit

Permalink
Merge pull request #6 from dimuon/feature/530/terraform-plugin-framew…
Browse files Browse the repository at this point in the history
…ork-0.12

Update to terraform-plugin-framework 0.12 and fix import order
  • Loading branch information
dimuon authored Sep 15, 2022
2 parents b7c8e23 + 8a79970 commit 6136a1c
Show file tree
Hide file tree
Showing 130 changed files with 579 additions and 330 deletions.
1 change: 1 addition & 0 deletions ec/acc/acc_prereq.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (

"github.com/elastic/cloud-sdk-go/pkg/api"
"github.com/elastic/cloud-sdk-go/pkg/auth"

"github.com/elastic/terraform-provider-ec/ec"
)

Expand Down
5 changes: 3 additions & 2 deletions ec/acc/deployment_checks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ package acc
import (
"fmt"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"

"github.com/elastic/cloud-sdk-go/pkg/api"
"github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi"
"github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/deputil"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)

func testAccCheckDeploymentExists(name string) resource.TestCheckFunc {
Expand Down
3 changes: 2 additions & 1 deletion ec/acc/deployment_destroy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ package acc
import (
"fmt"

"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"

"github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi"
"github.com/elastic/cloud-sdk-go/pkg/multierror"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)

func testAccDeploymentDestroy(s *terraform.State) error {
Expand Down
3 changes: 2 additions & 1 deletion ec/acc/deployment_elasticsearch_kesytore_destroy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ package acc
import (
"fmt"

"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"

"github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/eskeystoreapi"
"github.com/elastic/cloud-sdk-go/pkg/multierror"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)

func testAccDeploymentElasticsearchKeystoreDestroy(s *terraform.State) error {
Expand Down
3 changes: 2 additions & 1 deletion ec/acc/deployment_elasticsearch_kesytore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ import (
"fmt"
"testing"

"github.com/elastic/cloud-sdk-go/pkg/multierror"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"

"github.com/elastic/cloud-sdk-go/pkg/multierror"
)

func TestAccDeploymentElasticsearchKeystore_full(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion ec/acc/deployment_extension_bundle_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ import (
"path/filepath"
"testing"

"github.com/elastic/cloud-sdk-go/pkg/client/extensions"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"

"github.com/elastic/cloud-sdk-go/pkg/client/extensions"
)

func TestAccDeploymentExtension_bundleFile(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion ec/acc/deployment_extension_destroy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ package acc
import (
"fmt"

"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"

"github.com/elastic/cloud-sdk-go/pkg/api/apierror"
"github.com/elastic/cloud-sdk-go/pkg/client/extensions"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)

func testAccExtensionDestroy(s *terraform.State) error {
Expand Down
2 changes: 1 addition & 1 deletion ec/acc/deployment_failed_upgrade_retry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"regexp"
"testing"

semver "github.com/blang/semver/v4"
"github.com/blang/semver/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)
Expand Down
3 changes: 2 additions & 1 deletion ec/acc/deployment_sweep_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ import (
"sync"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"

"github.com/elastic/cloud-sdk-go/pkg/api"
"github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi"
"github.com/elastic/cloud-sdk-go/pkg/models"
"github.com/elastic/cloud-sdk-go/pkg/multierror"
"github.com/elastic/cloud-sdk-go/pkg/plan"
"github.com/elastic/cloud-sdk-go/pkg/plan/planutil"
"github.com/elastic/cloud-sdk-go/pkg/util/ec"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func init() {
Expand Down
5 changes: 3 additions & 2 deletions ec/acc/deployment_traffic_filter_checks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ package acc
import (
"fmt"

"github.com/elastic/cloud-sdk-go/pkg/api"
"github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/trafficfilterapi"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"

"github.com/elastic/cloud-sdk-go/pkg/api"
"github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/trafficfilterapi"
)

func testAccCheckDeploymentTrafficFilterExists(name string) resource.TestCheckFunc {
Expand Down
3 changes: 2 additions & 1 deletion ec/acc/deployment_traffic_filter_destroy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ package acc
import (
"fmt"

"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"

"github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/trafficfilterapi"
"github.com/elastic/cloud-sdk-go/pkg/multierror"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
)

func testAccDeploymentTrafficFilterDestroy(s *terraform.State) error {
Expand Down
3 changes: 2 additions & 1 deletion ec/acc/deployment_traffic_filter_sweep_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ import (
"strings"
"sync"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"

"github.com/elastic/cloud-sdk-go/pkg/api"
"github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/trafficfilterapi"
"github.com/elastic/cloud-sdk-go/pkg/multierror"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)

func init() {
Expand Down
3 changes: 2 additions & 1 deletion ec/acc/deployment_with_extension_bundle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ import (
"path/filepath"
"testing"

"github.com/elastic/cloud-sdk-go/pkg/multierror"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"

"github.com/elastic/cloud-sdk-go/pkg/multierror"
)

func TestAccDeployment_withExtension(t *testing.T) {
Expand Down
39 changes: 25 additions & 14 deletions ec/ecdatasource/deploymentdatasource/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import (

"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/provider"
"github.com/hashicorp/terraform-plugin-framework/types"

"github.com/elastic/cloud-sdk-go/pkg/api"
"github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi"
"github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/deputil"
"github.com/elastic/cloud-sdk-go/pkg/models"
Expand All @@ -35,33 +35,44 @@ import (
"github.com/elastic/terraform-provider-ec/ec/internal/util"
)

var _ provider.DataSourceType = (*DataSourceType)(nil)
var _ datasource.DataSource = &DataSource{}
var _ datasource.DataSourceWithConfigure = &DataSource{}
var _ datasource.DataSourceWithGetSchema = &DataSource{}
var _ datasource.DataSourceWithMetadata = &DataSource{}

type DataSourceType struct{}
type DataSource struct {
client *api.API
}

func (s DataSourceType) NewDataSource(ctx context.Context, in provider.Provider) (datasource.DataSource, diag.Diagnostics) {
p, diags := internal.ConvertProviderType(in)
func (d *DataSource) Configure(ctx context.Context, request datasource.ConfigureRequest, response *datasource.ConfigureResponse) {
client, diags := internal.ConvertProviderData(request.ProviderData)
response.Diagnostics.Append(diags...)
d.client = client
}

return &deploymentDataSource{
p: p,
}, diags
func (d *DataSource) Metadata(ctx context.Context, request datasource.MetadataRequest, response *datasource.MetadataResponse) {
response.TypeName = request.ProviderTypeName + "_deployment"
}

var _ datasource.DataSource = (*deploymentDataSource)(nil)
func (d DataSource) Read(ctx context.Context, request datasource.ReadRequest, response *datasource.ReadResponse) {
// Prevent panic if the provider has not been configured.
if d.client == nil {
response.Diagnostics.AddError(
"Unconfigured API Client",
"Expected configured API client. Please report this issue to the provider developers.",
)

type deploymentDataSource struct {
p internal.Provider
}
return
}

func (d deploymentDataSource) Read(ctx context.Context, request datasource.ReadRequest, response *datasource.ReadResponse) {
var newState modelV0
response.Diagnostics.Append(request.Config.Get(ctx, &newState)...)
if response.Diagnostics.HasError() {
return
}

res, err := deploymentapi.Get(deploymentapi.GetParams{
API: d.p.GetClient(),
API: d.client,
DeploymentID: newState.ID.Value,
QueryParams: deputil.QueryParams{
ShowPlans: true,
Expand Down
9 changes: 6 additions & 3 deletions ec/ecdatasource/deploymentdatasource/datasource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@ package deploymentdatasource

import (
"context"
"github.com/elastic/terraform-provider-ec/ec/internal/util"
"testing"

"github.com/stretchr/testify/assert"

"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/types"
"testing"

"github.com/elastic/cloud-sdk-go/pkg/api/mock"
"github.com/elastic/cloud-sdk-go/pkg/models"
"github.com/elastic/cloud-sdk-go/pkg/util/ec"
"github.com/stretchr/testify/assert"

"github.com/elastic/terraform-provider-ec/ec/internal/util"
)

func Test_modelToState(t *testing.T) {
Expand Down
4 changes: 3 additions & 1 deletion ec/ecdatasource/deploymentdatasource/flatteners_apm.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ package deploymentdatasource

import (
"context"
"github.com/elastic/cloud-sdk-go/pkg/models"

"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/types"

"github.com/elastic/cloud-sdk-go/pkg/models"

"github.com/elastic/terraform-provider-ec/ec/internal/util"
)

Expand Down
3 changes: 2 additions & 1 deletion ec/ecdatasource/deploymentdatasource/flatteners_apm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ package deploymentdatasource

import (
"context"
"testing"

"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/stretchr/testify/assert"
"testing"

"github.com/elastic/cloud-sdk-go/pkg/api/mock"
"github.com/elastic/cloud-sdk-go/pkg/models"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ import (
"fmt"
"strconv"

"github.com/elastic/cloud-sdk-go/pkg/models"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/types"

"github.com/elastic/cloud-sdk-go/pkg/models"

"github.com/elastic/terraform-provider-ec/ec/internal/util"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ import (
"context"
"testing"

"github.com/elastic/cloud-sdk-go/pkg/api/mock"
"github.com/elastic/cloud-sdk-go/pkg/models"
"github.com/elastic/cloud-sdk-go/pkg/util/ec"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/stretchr/testify/assert"

"github.com/elastic/cloud-sdk-go/pkg/api/mock"
"github.com/elastic/cloud-sdk-go/pkg/models"
"github.com/elastic/cloud-sdk-go/pkg/util/ec"
)

func Test_flattenElasticsearchResources(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ package deploymentdatasource

import (
"context"
"github.com/elastic/cloud-sdk-go/pkg/models"

"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/types"

"github.com/elastic/cloud-sdk-go/pkg/models"

"github.com/elastic/terraform-provider-ec/ec/internal/util"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ import (
"context"
"testing"

"github.com/elastic/cloud-sdk-go/pkg/api/mock"
"github.com/elastic/cloud-sdk-go/pkg/models"
"github.com/elastic/cloud-sdk-go/pkg/util/ec"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/stretchr/testify/assert"

"github.com/elastic/cloud-sdk-go/pkg/api/mock"
"github.com/elastic/cloud-sdk-go/pkg/models"
"github.com/elastic/cloud-sdk-go/pkg/util/ec"
)

func Test_flattenEnterpriseSearchResource(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ package deploymentdatasource

import (
"context"
"github.com/elastic/cloud-sdk-go/pkg/models"

"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/types"

"github.com/elastic/cloud-sdk-go/pkg/models"

"github.com/elastic/terraform-provider-ec/ec/internal/util"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ import (
"context"
"testing"

"github.com/elastic/cloud-sdk-go/pkg/api/mock"
"github.com/elastic/cloud-sdk-go/pkg/models"
"github.com/elastic/cloud-sdk-go/pkg/util/ec"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/stretchr/testify/assert"

"github.com/elastic/cloud-sdk-go/pkg/api/mock"
"github.com/elastic/cloud-sdk-go/pkg/models"
"github.com/elastic/cloud-sdk-go/pkg/util/ec"
)

func Test_flattenIntegrationsServerResource(t *testing.T) {
Expand Down
4 changes: 3 additions & 1 deletion ec/ecdatasource/deploymentdatasource/flatteners_kibana.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ package deploymentdatasource

import (
"context"
"github.com/elastic/cloud-sdk-go/pkg/models"

"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/types"

"github.com/elastic/cloud-sdk-go/pkg/models"

"github.com/elastic/terraform-provider-ec/ec/internal/util"
)

Expand Down
Loading

0 comments on commit 6136a1c

Please sign in to comment.