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

Plugin framework 1.2 #660

Merged
merged 6 commits into from
Jun 16, 2023
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changelog/659.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
```release-note:feature
datasource/privatelink: Adds data sources (`aws_privatelink_endpoint`, `azure_privatelink_endpoint`, and `gcp_private_service_connect_endpoint`) to lookup private networking endpoint information.
```
3 changes: 3 additions & 0 deletions .changelog/660.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:feature
Upgrades the provider to terraform-plugin-framework:1.2.0
```
8 changes: 4 additions & 4 deletions docs/resources/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ Optional:

Read-Only:

- `endpoints` (Object) URLs for the accessing the Fleet and APM API's within this Integrations Server resource. (see [below for nested schema](#nestedatt--integrations_server--endpoints))
- `endpoints` (Attributes) URLs for the accessing the Fleet and APM API's within this Integrations Server resource. (see [below for nested schema](#nestedatt--integrations_server--endpoints))
- `http_endpoint` (String)
- `https_endpoint` (String)
- `region` (String)
Expand All @@ -795,10 +795,10 @@ Optional:
<a id="nestedatt--integrations_server--endpoints"></a>
### Nested Schema for `integrations_server.endpoints`

Optional:
Read-Only:

- `apm` (String)
- `fleet` (String)
- `apm` (String) URL to access the APM server instance for this Integrations Server resource
- `fleet` (String) URL to access the Fleet server instance for this Integrations Server resource



Expand Down
2 changes: 1 addition & 1 deletion docs/resources/deployment_traffic_filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,13 @@ resource "ec_deployment_traffic_filter" "gcp_psc" {

- `name` (String) Name of the ruleset
- `region` (String) Filter region, the ruleset can only be attached to deployments in the specific region
- `rule` (Block Set, Min: 1) Set of rules, which the ruleset is made of. (see [below for nested schema](#nestedblock--rule))
- `type` (String) Type of the ruleset. It can be `ip`, `vpce`, `azure_private_endpoint`, or `gcp_private_service_connect_endpoint`

### Optional

- `description` (String) Ruleset description
- `include_by_default` (Boolean) Indicates that the ruleset should be automatically included in new deployments (Defaults to false)
- `rule` (Block Set) Set of rules, which the ruleset is made of. (see [below for nested schema](#nestedblock--rule))

### Read-Only

Expand Down
9 changes: 0 additions & 9 deletions ec/acc/datasource_stack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,26 +87,17 @@ func checkDataSourceStack(resName string, checks ...resource.TestCheckFunc) reso

// Elasticsearch
resource.TestCheckResourceAttrSet(resName, "elasticsearch.0.denylist.#"),
resource.TestCheckResourceAttrSet(resName, "elasticsearch.0.capacity_constraints_max"),
resource.TestCheckResourceAttrSet(resName, "elasticsearch.0.capacity_constraints_min"),
resource.TestCheckResourceAttrSet(resName, "elasticsearch.0.docker_image"),
resource.TestCheckResourceAttrSet(resName, "elasticsearch.0.plugins.#"),
resource.TestCheckResourceAttrSet(resName, "elasticsearch.0.default_plugins.#"),

// Kibana
resource.TestCheckResourceAttrSet(resName, "kibana.0.denylist.#"),
resource.TestCheckResourceAttrSet(resName, "kibana.0.capacity_constraints_max"),
resource.TestCheckResourceAttrSet(resName, "kibana.0.capacity_constraints_min"),
resource.TestCheckResourceAttrSet(resName, "kibana.0.docker_image"),

// APM
resource.TestCheckResourceAttrSet(resName, "apm.0.capacity_constraints_max"),
resource.TestCheckResourceAttrSet(resName, "apm.0.capacity_constraints_min"),
resource.TestCheckResourceAttrSet(resName, "apm.0.docker_image"),

// Enterprise Search
resource.TestCheckResourceAttrSet(resName, "enterprise_search.0.capacity_constraints_max"),
resource.TestCheckResourceAttrSet(resName, "enterprise_search.0.capacity_constraints_min"),
resource.TestCheckResourceAttrSet(resName, "enterprise_search.0.docker_image"),
}, checks...)...)
}
15 changes: 8 additions & 7 deletions ec/ecdatasource/deploymentdatasource/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (d DataSource) Read(ctx context.Context, request datasource.ReadRequest, re

res, err := deploymentapi.Get(deploymentapi.GetParams{
API: d.client,
DeploymentID: newState.ID.Value,
DeploymentID: newState.ID.ValueString(),
QueryParams: deputil.QueryParams{
ShowPlans: true,
ShowSettings: true,
Expand Down Expand Up @@ -99,17 +99,17 @@ func (d DataSource) Read(ctx context.Context, request datasource.ReadRequest, re
func modelToState(ctx context.Context, res *models.DeploymentGetResponse, state *modelV0) diag.Diagnostics {
var diagsnostics diag.Diagnostics

state.Name = types.String{Value: *res.Name}
state.Healthy = types.Bool{Value: *res.Healthy}
state.Alias = types.String{Value: res.Alias}
state.Name = types.StringValue(*res.Name)
state.Healthy = types.BoolValue(*res.Healthy)
state.Alias = types.StringValue(res.Alias)

es := res.Resources.Elasticsearch[0]
if es.Region != nil {
state.Region = types.String{Value: *es.Region}
state.Region = types.StringValue(*es.Region)
}

if !util.IsCurrentEsPlanEmpty(es) {
state.DeploymentTemplateID = types.String{Value: *es.Info.PlanInfo.Current.Plan.DeploymentTemplate.ID}
state.DeploymentTemplateID = types.StringValue(*es.Info.PlanInfo.Current.Plan.DeploymentTemplate.ID)
}

var diags diag.Diagnostics
Expand All @@ -136,7 +136,8 @@ func modelToState(ctx context.Context, res *models.DeploymentGetResponse, state
diagsnostics.Append(diags...)

if res.Metadata != nil {
state.Tags = converters.ModelsTagsToTypesMap(res.Metadata.Tags)
state.Tags, diags = converters.ModelsTagsToTypesMap(res.Metadata.Tags)
diagsnostics.Append(diags...)
}

return diagsnostics
Expand Down
229 changes: 105 additions & 124 deletions ec/ecdatasource/deploymentdatasource/datasource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
)

func Test_modelToState(t *testing.T) {
wantDeployment := newSampleDeployment()
wantDeployment := newSampleDeployment(t)
type args struct {
res *models.DeploymentGetResponse
}
Expand Down Expand Up @@ -130,7 +130,7 @@ func Test_modelToState(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
model := modelV0{
ID: types.String{Value: mock.ValidClusterID},
ID: types.StringValue(mock.ValidClusterID),
}
diags := modelToState(context.Background(), tt.args.res, &model)
if tt.err != nil {
Expand All @@ -144,140 +144,121 @@ func Test_modelToState(t *testing.T) {
}
}

func newSampleDeployment() modelV0 {
func newSampleDeployment(t *testing.T) modelV0 {
return modelV0{
ID: types.String{Value: mock.ValidClusterID},
Name: types.String{Value: "my_deployment_name"},
Alias: types.String{Value: "some-alias"},
DeploymentTemplateID: types.String{Value: "aws-io-optimized"},
Healthy: types.Bool{Value: true},
Region: types.String{Value: "us-east-1"},
TrafficFilter: util.StringListAsType([]string{"0.0.0.0/0", "192.168.10.0/24"}),
Observability: types.List{
ElemType: types.ObjectType{AttrTypes: observabilitySettingsAttrTypes()},
Elems: []attr.Value{
types.Object{
AttrTypes: observabilitySettingsAttrTypes(),
Attrs: map[string]attr.Value{
"deployment_id": types.String{Value: mock.ValidClusterID},
"ref_id": types.String{Value: "main-elasticsearch"},
"logs": types.Bool{Value: true},
"metrics": types.Bool{Value: true},
ID: types.StringValue(mock.ValidClusterID),
Name: types.StringValue("my_deployment_name"),
Alias: types.StringValue("some-alias"),
DeploymentTemplateID: types.StringValue("aws-io-optimized"),
Healthy: types.BoolValue(true),
Region: types.StringValue("us-east-1"),
TrafficFilter: util.StringListAsType(t, []string{"0.0.0.0/0", "192.168.10.0/24"}),
Observability: func() types.List {
res, diags := types.ListValueFrom(
context.Background(),
types.ObjectType{AttrTypes: observabilitySettingsAttrTypes()},
[]observabilitySettingsModel{
{
DeploymentID: types.StringValue(mock.ValidClusterID),
RefID: types.StringValue("main-elasticsearch"),
Logs: types.BoolValue(true),
Metrics: types.BoolValue(true),
},
},
},
},
Elasticsearch: types.List{
ElemType: types.ObjectType{AttrTypes: elasticsearchResourceInfoAttrTypes()},
Elems: []attr.Value{
types.Object{
AttrTypes: elasticsearchResourceInfoAttrTypes(),
Attrs: map[string]attr.Value{
"cloud_id": types.String{Value: ""},
"healthy": types.Bool{Value: true},
"autoscale": types.String{Value: ""},
"http_endpoint": types.String{Value: ""},
"https_endpoint": types.String{Value: ""},
"ref_id": types.String{Value: ""},
"resource_id": types.String{Value: ""},
"status": types.String{Value: ""},
"version": types.String{Value: ""},
"topology": types.List{
ElemType: types.ObjectType{AttrTypes: elasticsearchTopologyAttrTypes()},
Elems: []attr.Value{},
},
)
assert.Nil(t, diags)

return res
}(),
Elasticsearch: func() types.List {
topology, diags := types.ListValue(
types.ObjectType{AttrTypes: elasticsearchTopologyAttrTypes()},
[]attr.Value{},
)
assert.Nil(t, diags)

res, diags := types.ListValueFrom(
context.Background(),
types.ObjectType{AttrTypes: elasticsearchResourceInfoAttrTypes()},
[]elasticsearchResourceInfoModelV0{
{
Healthy: types.BoolValue(true),
Topology: topology,
},
},
},
},
Kibana: types.List{
ElemType: types.ObjectType{AttrTypes: kibanaResourceInfoAttrTypes()},
Elems: []attr.Value{
types.Object{
AttrTypes: kibanaResourceInfoAttrTypes(),
Attrs: map[string]attr.Value{
"elasticsearch_cluster_ref_id": types.String{Value: ""},
"healthy": types.Bool{Value: true},
"http_endpoint": types.String{Value: ""},
"https_endpoint": types.String{Value: ""},
"ref_id": types.String{Value: ""},
"resource_id": types.String{Value: ""},
"status": types.String{Value: ""},
"version": types.String{Value: ""},
"topology": types.List{
ElemType: types.ObjectType{AttrTypes: kibanaTopologyAttrTypes()},
Elems: []attr.Value{},
},
)
assert.Nil(t, diags)

return res
}(),
Kibana: func() types.List {
res, diags := types.ListValueFrom(
context.Background(),
types.ObjectType{AttrTypes: kibanaResourceInfoAttrTypes()},
[]kibanaResourceInfoModelV0{
{
Healthy: types.BoolValue(true),
Topology: types.ListNull(
types.ObjectType{AttrTypes: kibanaTopologyAttrTypes()},
),
},
},
},
},
Apm: types.List{
ElemType: types.ObjectType{AttrTypes: apmResourceInfoAttrTypes()},
Elems: []attr.Value{
types.Object{
AttrTypes: apmResourceInfoAttrTypes(),
Attrs: map[string]attr.Value{
"elasticsearch_cluster_ref_id": types.String{Value: ""},
"healthy": types.Bool{Value: true},
"http_endpoint": types.String{Value: ""},
"https_endpoint": types.String{Value: ""},
"ref_id": types.String{Value: ""},
"resource_id": types.String{Value: ""},
"status": types.String{Value: ""},
"version": types.String{Value: ""},
"topology": types.List{
ElemType: types.ObjectType{AttrTypes: apmTopologyAttrTypes()},
Elems: []attr.Value{},
},
)
assert.Nil(t, diags)

return res
}(),
Apm: func() types.List {
res, diags := types.ListValueFrom(
context.Background(),
types.ObjectType{AttrTypes: apmResourceInfoAttrTypes()},
[]apmResourceInfoModelV0{
{
Healthy: types.BoolValue(true),
Topology: types.ListNull(
types.ObjectType{AttrTypes: apmTopologyAttrTypes()},
),
},
},
},
},
IntegrationsServer: types.List{
ElemType: types.ObjectType{AttrTypes: integrationsServerResourceInfoAttrTypes()},
Elems: []attr.Value{
types.Object{
AttrTypes: integrationsServerResourceInfoAttrTypes(),
Attrs: map[string]attr.Value{
"elasticsearch_cluster_ref_id": types.String{Value: ""},
"healthy": types.Bool{Value: true},
"http_endpoint": types.String{Value: ""},
"https_endpoint": types.String{Value: ""},
"ref_id": types.String{Value: ""},
"resource_id": types.String{Value: ""},
"status": types.String{Value: ""},
"version": types.String{Value: ""},
"topology": types.List{
ElemType: types.ObjectType{AttrTypes: integrationsServerTopologyAttrTypes()},
Elems: []attr.Value{},
},
)
assert.Nil(t, diags)

return res
}(),
IntegrationsServer: func() types.List {
res, diags := types.ListValueFrom(
context.Background(),
types.ObjectType{AttrTypes: integrationsServerResourceInfoAttrTypes()},
[]integrationsServerResourceInfoModelV0{
{
Healthy: types.BoolValue(true),
Topology: types.ListNull(
types.ObjectType{AttrTypes: integrationsServerTopologyAttrTypes()},
),
},
},
},
},
EnterpriseSearch: types.List{
ElemType: types.ObjectType{AttrTypes: enterpriseSearchResourceInfoAttrTypes()},
Elems: []attr.Value{
types.Object{
AttrTypes: enterpriseSearchResourceInfoAttrTypes(),
Attrs: map[string]attr.Value{
"elasticsearch_cluster_ref_id": types.String{Value: ""},
"healthy": types.Bool{Value: true},
"http_endpoint": types.String{Value: ""},
"https_endpoint": types.String{Value: ""},
"ref_id": types.String{Value: ""},
"resource_id": types.String{Value: ""},
"status": types.String{Value: ""},
"version": types.String{Value: ""},
"topology": types.List{
ElemType: types.ObjectType{AttrTypes: enterpriseSearchTopologyAttrTypes()},
Elems: []attr.Value{},
},
)
assert.Nil(t, diags)

return res
}(),
EnterpriseSearch: func() types.List {
res, diags := types.ListValueFrom(
context.Background(),
types.ObjectType{AttrTypes: enterpriseSearchResourceInfoAttrTypes()},
[]enterpriseSearchResourceInfoModelV0{
{
Healthy: types.BoolValue(true),
Topology: types.ListNull(
types.ObjectType{AttrTypes: enterpriseSearchTopologyAttrTypes()},
),
},
},
},
},
Tags: util.StringMapAsType(map[string]string{"foo": "bar"}),
)
assert.Nil(t, diags)

return res
}(),
Tags: util.StringMapAsType(t, map[string]string{"foo": "bar"}),
}
}
Loading