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

Experiment/topologies map #578

Draft
wants to merge 113 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
113 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
0d104c2
(WIP) use types.Set for topologies (unit tests fails)
dimuon Jan 18, 2023
ef276f8
Update README - add a note for updaint the TF client
dimuon Jan 18, 2023
910ebc0
Fixes for topologies as a set
dimuon Jan 18, 2023
48d04c3
Fix elasticsearch topology description and remove obsolete func
dimuon Jan 18, 2023
3d6835c
Fixes for NullifyUnusedEsTopologies
dimuon Jan 19, 2023
a2d6a62
Fix examples
dimuon Jan 19, 2023
422d45e
Apply suggestions from code review
dimuon Jan 23, 2023
d53e596
makes elasticsearch topology required
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
9422638
(WIP) use map for Elasticsearch topologies
dimuon Jan 24, 2023
e221610
Remove obsolete plan modifier for elasticsearch topology zone_count
dimuon Jan 24, 2023
89760d2
Fix and enable plan modifiers for topology attributes
dimuon Jan 24, 2023
8fc4f66
Merge remote-tracking branch 'origin/feature/530/migrate-to-plugin-fr…
dimuon Jan 25, 2023
82e869c
stop exporting a function
dimuon Jan 25, 2023
53397aa
fix unit tests
dimuon Jan 25, 2023
189d2d9
fix acceptance tests and examples
dimuon Jan 25, 2023
f974720
remove obsolete code
dimuon Jan 25, 2023
2a17c5b
fix errors in acceptance tests
dimuon Jan 26, 2023
b81d334
fix regex expressions in acc tests for pre node_roles
dimuon Feb 6, 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
Prev Previous commit
Next Next commit
split apm and deployment in deploymentresource to read and payload files
dimuon committed Dec 22, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 7277f4194d5f0420cab9ec593d5eebe78b1e6779
Original file line number Diff line number Diff line change
@@ -23,9 +23,6 @@ import (
"github.com/elastic/cloud-sdk-go/pkg/models"
v1 "github.com/elastic/terraform-provider-ec/ec/ecresource/deploymentresource/apm/v1"
topologyv1 "github.com/elastic/terraform-provider-ec/ec/ecresource/deploymentresource/topology/v1"
"github.com/elastic/terraform-provider-ec/ec/ecresource/deploymentresource/utils"
"github.com/elastic/terraform-provider-ec/ec/internal/converters"
"github.com/elastic/terraform-provider-ec/ec/internal/util"
"github.com/hashicorp/terraform-plugin-framework/diag"
"github.com/hashicorp/terraform-plugin-framework/tfsdk"
"github.com/hashicorp/terraform-plugin-framework/types"
@@ -45,73 +42,6 @@ type ApmTF struct {
Config types.Object `tfsdk:"config"`
}

type Apm struct {
ElasticsearchClusterRefId *string `tfsdk:"elasticsearch_cluster_ref_id"`
RefId *string `tfsdk:"ref_id"`
ResourceId *string `tfsdk:"resource_id"`
Region *string `tfsdk:"region"`
HttpEndpoint *string `tfsdk:"http_endpoint"`
HttpsEndpoint *string `tfsdk:"https_endpoint"`
InstanceConfigurationId *string `tfsdk:"instance_configuration_id"`
Size *string `tfsdk:"size"`
SizeResource *string `tfsdk:"size_resource"`
ZoneCount int `tfsdk:"zone_count"`
Config *ApmConfig `tfsdk:"config"`
}

func ReadApms(in []*models.ApmResourceInfo) (*Apm, error) {
for _, model := range in {
if util.IsCurrentApmPlanEmpty(model) || utils.IsApmResourceStopped(model) {
continue
}

apm, err := ReadApm(model)
if err != nil {
return nil, err
}

return apm, nil
}

return nil, nil
}

func ReadApm(in *models.ApmResourceInfo) (*Apm, error) {
var apm Apm

apm.RefId = in.RefID
apm.ResourceId = in.Info.ID
apm.Region = in.Region
plan := in.Info.PlanInfo.Current.Plan

topologies, err := ReadApmTopologies(plan.ClusterTopology)
if err != nil {
return nil, err
}

if len(topologies) > 0 {
apm.InstanceConfigurationId = topologies[0].InstanceConfigurationId
apm.Size = topologies[0].Size
apm.SizeResource = topologies[0].SizeResource
apm.ZoneCount = topologies[0].ZoneCount
}

apm.ElasticsearchClusterRefId = in.ElasticsearchClusterRefID

apm.HttpEndpoint, apm.HttpsEndpoint = converters.ExtractEndpoints(in.Info.Metadata)

configs, err := readApmConfigs(plan.Apm)
if err != nil {
return nil, err
}

if len(configs) > 0 {
apm.Config = &configs[0]
}

return &apm, nil
}

func (apm ApmTF) Payload(ctx context.Context, payload models.ApmPayload) (*models.ApmPayload, diag.Diagnostics) {
var diags diag.Diagnostics

@@ -170,7 +100,7 @@ func ApmPayload(ctx context.Context, apmObj types.Object, template *models.Deplo
return nil, nil
}

templatePayload := ApmResource(template)
templatePayload := payloadFromTemplate(template)

if templatePayload == nil {
diags.AddError("apm payload error", "apm specified but deployment template is not configured for it. Use a different template if you wish to add apm")
@@ -186,9 +116,9 @@ func ApmPayload(ctx context.Context, apmObj types.Object, template *models.Deplo
return payload, nil
}

// ApmResource returns the ApmPayload from a deployment
// payloadFromTemplate returns the ApmPayload from a deployment
// template or an empty version of the payload.
func ApmResource(template *models.DeploymentTemplateInfoV2) *models.ApmPayload {
func payloadFromTemplate(template *models.DeploymentTemplateInfoV2) *models.ApmPayload {
if template == nil || len(template.DeploymentTemplate.Resources.Apm) == 0 {
return nil
}
92 changes: 92 additions & 0 deletions ec/ecresource/deploymentresource/apm/v2/apm_read.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package v2

import (
"github.com/elastic/cloud-sdk-go/pkg/models"
"github.com/elastic/terraform-provider-ec/ec/ecresource/deploymentresource/utils"
"github.com/elastic/terraform-provider-ec/ec/internal/converters"
"github.com/elastic/terraform-provider-ec/ec/internal/util"
)

type Apm struct {
ElasticsearchClusterRefId *string `tfsdk:"elasticsearch_cluster_ref_id"`
RefId *string `tfsdk:"ref_id"`
ResourceId *string `tfsdk:"resource_id"`
Region *string `tfsdk:"region"`
HttpEndpoint *string `tfsdk:"http_endpoint"`
HttpsEndpoint *string `tfsdk:"https_endpoint"`
InstanceConfigurationId *string `tfsdk:"instance_configuration_id"`
Size *string `tfsdk:"size"`
SizeResource *string `tfsdk:"size_resource"`
ZoneCount int `tfsdk:"zone_count"`
Config *ApmConfig `tfsdk:"config"`
}

func ReadApms(in []*models.ApmResourceInfo) (*Apm, error) {
for _, model := range in {
if util.IsCurrentApmPlanEmpty(model) || utils.IsApmResourceStopped(model) {
continue
}

apm, err := ReadApm(model)
if err != nil {
return nil, err
}

return apm, nil
}

return nil, nil
}

func ReadApm(in *models.ApmResourceInfo) (*Apm, error) {
var apm Apm

apm.RefId = in.RefID
apm.ResourceId = in.Info.ID
apm.Region = in.Region
plan := in.Info.PlanInfo.Current.Plan

topologies, err := ReadApmTopologies(plan.ClusterTopology)
if err != nil {
return nil, err
}

if len(topologies) > 0 {
apm.InstanceConfigurationId = topologies[0].InstanceConfigurationId
apm.Size = topologies[0].Size
apm.SizeResource = topologies[0].SizeResource
apm.ZoneCount = topologies[0].ZoneCount
}

apm.ElasticsearchClusterRefId = in.ElasticsearchClusterRefID

apm.HttpEndpoint, apm.HttpsEndpoint = converters.ExtractEndpoints(in.Info.Metadata)

configs, err := readApmConfigs(plan.Apm)
if err != nil {
return nil, err
}

if len(configs) > 0 {
apm.Config = &configs[0]
}

return &apm, nil
}
Loading