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

Feature/530/migrate to plugin framework #567

Merged
merged 107 commits into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
0627d93
Introduce mux and port the provider to v6.
dimuon Sep 6, 2022
2213f86
Update required version of CLI in examples
dimuon Sep 6, 2022
cf373db
Increase TF verson in github workflow
dimuon Sep 6, 2022
043bbe7
Merge pull request #1 from dimuon/feature/530/ec-deployment
dimuon Sep 7, 2022
2194ad3
Migrate data sources to terraform-provider-framework
pascal-hofmann Aug 31, 2022
1c61d77
Merge pull request #3 from dimuon/feature/530/port-datasources
dimuon Sep 8, 2022
a5de6e9
Migrate resource ec_deployment_traffic_filter_association to terrafor…
dimuon Sep 7, 2022
b7c8e23
Merge pull request #5 from dimuon/feature/530/ec-trafficfilterassoc-only
dimuon Sep 15, 2022
8a79970
Update to terraform-plugin-framework 0.12 and fix import order
pascal-hofmann Sep 15, 2022
6136a1c
Merge pull request #6 from dimuon/feature/530/terraform-plugin-framew…
dimuon Sep 15, 2022
c197f28
Migrate resource ec_deployment_traffic_filter to terraform-provider-f…
pascal-hofmann Sep 18, 2022
c4aebde
Merge pull request #8 from dimuon/feature/530/trafficfilterresource
dimuon Sep 21, 2022
2084e39
Use blocks and ListNestedAttributes for nested schemas in datasources
pascal-hofmann Sep 21, 2022
993d47d
Migrate resource ec_deployment_elasticsearch_keystore to terraform-pl…
pascal-hofmann Sep 23, 2022
b00e28a
Update dependencies and remove external provider workaround from migr…
pascal-hofmann Sep 23, 2022
07aecc1
Merge pull request #11 from dimuon/update-dependencies
dimuon Sep 23, 2022
f310127
Migrate resource ec_deployment_extension to terraform-plugin-framewor…
pascal-hofmann Oct 18, 2022
320fb77
Feature/530/migrate to plugin framework (#2)
dimuon Dec 7, 2022
40f4e5d
skip acceptance tests for checking upgrade from 0.4.1
dimuon Dec 7, 2022
9d7c37b
Merge remote-tracking branch 'upstream/master' into feature/530/migra…
dimuon Dec 7, 2022
0f9eab6
remove leftovers that came after 0.4.1
dimuon Dec 7, 2022
a52f732
update go.mod
dimuon Dec 7, 2022
548a37b
Update changelog
dimuon Dec 7, 2022
50623f9
address PR comments in README
dimuon Dec 7, 2022
e244094
remove obsolete space
dimuon Dec 7, 2022
58b16d5
Address PR comments in provider_config.go
dimuon Dec 13, 2022
51f1eaa
Improve default_value plan modifier
dimuon Dec 13, 2022
d449931
remove obsolete var
dimuon Dec 13, 2022
b51e74a
improve schemas
dimuon Dec 13, 2022
34daf0f
remove obsolete code
dimuon Dec 14, 2022
dd0508b
remove incorrect comment
dimuon Dec 14, 2022
947e8b2
remove obsolete var
dimuon Dec 14, 2022
dfd6060
address PR comments
dimuon Dec 14, 2022
7f676f5
Remove obsolete function
dimuon Dec 19, 2022
345a341
Move provider data to an anonymous struct
dimuon Dec 20, 2022
bd05967
unit test for provider Config
dimuon Dec 20, 2022
f90f2c8
improve provider tests + address PR comments
dimuon Dec 21, 2022
b0bda3b
Refactor provider + address PR comments
dimuon Dec 21, 2022
99b3745
address PR comments
dimuon Dec 21, 2022
8c396b2
use plan modifiers from Hashicorp where possible
dimuon Dec 21, 2022
0df8f99
refactor ExtractEndpointsTF
dimuon Dec 21, 2022
f194f76
conversion funcs renaming
dimuon Dec 21, 2022
0675863
remove obsolete comment
dimuon Dec 21, 2022
4fa42b2
Apply suggestions from code review
dimuon Dec 22, 2022
0556078
remove obsolete comments in v1 schemas
dimuon Dec 22, 2022
7277f41
split apm and deployment in deploymentresource to read and payload files
dimuon Dec 22, 2022
d992a89
renaming and removing obsolete code
dimuon Dec 22, 2022
8cf3c54
split elasticsearch to read and payload files
dimuon Dec 22, 2022
c8ad85e
split enterprise_search files to read and payload
dimuon Dec 22, 2022
f323cf1
split integrations_server files to read and payload
dimuon Dec 22, 2022
a312dca
split kibana files to read and payload
dimuon Dec 22, 2022
3000ee3
split observability files to read and payload
dimuon Dec 22, 2022
4ae31c9
fix description
dimuon Dec 22, 2022
a624e68
renaming and removing obsolete code
dimuon Dec 22, 2022
4edcc2d
Apply suggestions from code review
dimuon Dec 22, 2022
39a1c43
endpoints extractions: use the converter func instead of the one from…
dimuon Dec 22, 2022
ebc05cf
moving code around and some renaming
dimuon Dec 22, 2022
71c9660
fix lint errors
dimuon Dec 22, 2022
cca7a75
renaming
dimuon Dec 22, 2022
42a7c92
renaming and obsolete code removing
dimuon Dec 22, 2022
2d108e5
renaming according to PR comments
dimuon Dec 27, 2022
b460efb
renaming + incorrect comment removal
dimuon Dec 27, 2022
b1862d4
fix unit test
dimuon Dec 27, 2022
8c938b1
convert 'elasticsearch' 'autoscale' attribute to bool type
dimuon Dec 27, 2022
395a3bc
remove TODOs for DiffSupressFunc
dimuon Dec 27, 2022
894bdb5
unit test for handling traffic rules
dimuon Dec 27, 2022
6a92321
move files from utils to dedicated resource packages
dimuon Dec 28, 2022
a2ce9d4
unit tests for UseNodeRoles
dimuon Dec 28, 2022
663167f
(WIP) Bring back logic of migrating node_types to node_roles
dimuon Dec 30, 2022
f0ca456
Improve node_type detection
dimuon Jan 3, 2023
8f14a40
improve and rearrange node_types plan modifier
dimuon Jan 4, 2023
0e50ae7
enable test for UseNodeRoles + minor refactoring
dimuon Jan 4, 2023
e11db61
unit tests for node_types and node_roles modifiers
dimuon Jan 4, 2023
4800d9d
renaming + obsolete code removal
dimuon Jan 5, 2023
3b4e53c
unit test for topology plan modifer + some refactoring
dimuon Jan 5, 2023
8d90524
deploymentdatasource: change flatteners to return the result
dimuon Jan 11, 2023
7400f7c
remove obsolete utility funcs
dimuon Jan 11, 2023
c0924dd
renaming local var
dimuon Jan 11, 2023
6c507cf
fix converion to attr.Value in deploymentdatasource
dimuon Jan 12, 2023
fc8a6cf
deploymentresource read - remove conversion to TF types
dimuon Jan 13, 2023
8e8a85c
Fix description an error messages. Remove obsolete TODO
dimuon Jan 13, 2023
07a5908
minor improvements for deploymentresource tests
dimuon Jan 13, 2023
a36caba
Replace any interface arg with returned type in stackdatasource
dimuon Jan 13, 2023
d1208af
Renaming
dimuon Jan 13, 2023
dda3586
move ResourceKind to util
dimuon Jan 13, 2023
2b07835
Replace any interface arg with returned type in trafficfilterresource
dimuon Jan 13, 2023
b30c207
add missing file
dimuon Jan 13, 2023
42fd243
Update NOTICE
dimuon Jan 13, 2023
ed86516
Merge branch 'master' into feature/530/migrate-to-plugin-framework
dimuon Jan 13, 2023
c60b15c
Update NOTICE
dimuon Jan 13, 2023
d3263ff
Fixing description for Enterprise Search
dimuon Jan 16, 2023
ef276f8
Update README - add a note for updaint the TF client
dimuon Jan 18, 2023
a2d6a62
Fix examples
dimuon Jan 19, 2023
422d45e
Apply suggestions from code review
dimuon Jan 23, 2023
ef67aa5
Addres PR comments - fix descriptions and scope of definitions
dimuon Jan 23, 2023
2fef8e6
update comment
dimuon Jan 23, 2023
5e31465
fix description
dimuon Jan 24, 2023
75c16c3
remove incorrect comments
dimuon Jan 24, 2023
e221610
Remove obsolete plan modifier for elasticsearch topology zone_count
dimuon Jan 24, 2023
511a7b7
fix validations for elasticsearch remote_cluster
dimuon Jan 25, 2023
1bfd39e
fix regex expressions in acc tests for pre node_roles
dimuon Feb 6, 2023
b420c80
explicit separation between plan and state in read
dimuon Feb 7, 2023
06bf06e
Update TF Framework to 1.1.1
dimuon Feb 7, 2023
172c654
Merge remote-tracking branch 'upstream/master' into feature/530/migra…
dimuon Feb 22, 2023
432ce9b
Address PR review comments
dimuon Feb 23, 2023
9b6cc51
Revert "Update TF Framework to 1.1.1" and "Address PR review comments"
dimuon Feb 24, 2023
35c633c
Update README and CHANGELOG
dimuon Feb 27, 2023
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
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