From 6c9bd80b7f373edeac8a6d0f9b0ae6df2df18a96 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 29 Feb 2024 14:46:05 +0100 Subject: [PATCH 1/4] fix(deps): update module github.com/hashicorp/terraform-plugin-framework to v1.6.0 (#790) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- go.mod | 16 ++++++++-------- go.sum | 40 ++++++++++++++++++++-------------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/go.mod b/go.mod index ae4704a9d..d2d6d8433 100644 --- a/go.mod +++ b/go.mod @@ -8,9 +8,9 @@ require ( github.com/elastic/cloud-sdk-go v1.16.0 github.com/go-openapi/runtime v0.26.0 github.com/go-openapi/strfmt v0.21.7 - github.com/hashicorp/terraform-plugin-framework v1.5.0 + github.com/hashicorp/terraform-plugin-framework v1.6.0 github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 - github.com/hashicorp/terraform-plugin-go v0.20.0 + github.com/hashicorp/terraform-plugin-go v0.22.0 github.com/hashicorp/terraform-plugin-log v0.9.0 github.com/hashicorp/terraform-plugin-testing v1.5.1 github.com/mitchellh/mapstructure v1.5.0 @@ -76,16 +76,16 @@ require ( go.mongodb.org/mongo-driver v1.11.3 // indirect go.opentelemetry.io/otel v1.14.0 // indirect go.opentelemetry.io/otel/trace v1.14.0 // indirect - golang.org/x/crypto v0.14.0 // indirect + golang.org/x/crypto v0.15.0 // indirect golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect golang.org/x/mod v0.12.0 // indirect - golang.org/x/net v0.17.0 // indirect - golang.org/x/sys v0.13.0 // indirect + golang.org/x/net v0.18.0 // indirect + golang.org/x/sys v0.14.0 // indirect golang.org/x/text v0.14.0 // indirect google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect - google.golang.org/grpc v1.60.0 // indirect - google.golang.org/protobuf v1.31.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect + google.golang.org/grpc v1.61.1 // indirect + google.golang.org/protobuf v1.32.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 9691e7f93..cc7cabb33 100644 --- a/go.sum +++ b/go.sum @@ -125,8 +125,8 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= -github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= +github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -158,12 +158,12 @@ github.com/hashicorp/terraform-exec v0.19.0 h1:FpqZ6n50Tk95mItTSS9BjeOVUb4eg81Sp github.com/hashicorp/terraform-exec v0.19.0/go.mod h1:tbxUpe3JKruE9Cuf65mycSIT8KiNPZ0FkuTE3H4urQg= github.com/hashicorp/terraform-json v0.17.1 h1:eMfvh/uWggKmY7Pmb3T85u86E2EQg6EQHgyRwf3RkyA= github.com/hashicorp/terraform-json v0.17.1/go.mod h1:Huy6zt6euxaY9knPAFKjUITn8QxUFIe9VuSzb4zn/0o= -github.com/hashicorp/terraform-plugin-framework v1.5.0 h1:8kcvqJs/x6QyOFSdeAyEgsenVOUeC/IyKpi2ul4fjTg= -github.com/hashicorp/terraform-plugin-framework v1.5.0/go.mod h1:6waavirukIlFpVpthbGd2PUNYaFedB0RwW3MDzJ/rtc= +github.com/hashicorp/terraform-plugin-framework v1.6.0 h1:hMPWoCiNGR+yzoDlXtZ/meGlUOCn8r1OFuPG84MkhWg= +github.com/hashicorp/terraform-plugin-framework v1.6.0/go.mod h1:QRG6J+m5QBJum+lzKi0Ci2CB8a/xflS3T/aWoz8WD4Y= github.com/hashicorp/terraform-plugin-framework-validators v0.12.0 h1:HOjBuMbOEzl7snOdOoUfE2Jgeto6JOjLVQ39Ls2nksc= github.com/hashicorp/terraform-plugin-framework-validators v0.12.0/go.mod h1:jfHGE/gzjxYz6XoUwi/aYiiKrJDeutQNUtGQXkaHklg= -github.com/hashicorp/terraform-plugin-go v0.20.0 h1:oqvoUlL+2EUbKNsJbIt3zqqZ7wi6lzn4ufkn/UA51xQ= -github.com/hashicorp/terraform-plugin-go v0.20.0/go.mod h1:Rr8LBdMlY53a3Z/HpP+ZU3/xCDqtKNCkeI9qOyT10QE= +github.com/hashicorp/terraform-plugin-go v0.22.0 h1:1OS1Jk5mO0f5hrziWJGXXIxBrMe2j/B8E+DVGw43Xmc= +github.com/hashicorp/terraform-plugin-go v0.22.0/go.mod h1:mPULV91VKss7sik6KFEcEu7HuTogMLLO/EvWCuFkRVE= github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9TFvymaRGZED3FCV0= github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow= github.com/hashicorp/terraform-plugin-sdk/v2 v2.29.0 h1:wcOKYwPI9IorAJEBLzgclh3xVolO7ZorYd6U1vnok14= @@ -306,8 +306,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= -golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= +golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= @@ -324,8 +324,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.18.0 h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg= +golang.org/x/net v0.18.0/go.mod h1:/czyP5RqHAH4odGYxBJ1qz0+CE5WZ+2j1YgoEo8F2jQ= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -357,15 +357,15 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= +golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= -golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= +golang.org/x/term v0.14.0 h1:LGK9IlZ8T9jvdy6cTdfKUCltatMFOehAQo9SRC46UQ8= +golang.org/x/term v0.14.0/go.mod h1:TySc+nGkYR6qt8km8wUhuFRTVSMIX3XPR58y2lC8vww= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -393,14 +393,14 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 h1:6GQBEOdGkX6MMTLT9V+TjtIRZCw9VPD5Z+yHY9wMgS0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97/go.mod h1:v7nGkzlmW8P3n/bKmWBn2WpBjpOEx8Q6gMueudAmKfY= -google.golang.org/grpc v1.60.0 h1:6FQAR0kM31P6MRdeluor2w2gPaS4SVNrD/DNTxrQ15k= -google.golang.org/grpc v1.60.0/go.mod h1:OlCHIeLYqSSsLi6i49B5QGdzaMZK9+M7LXN2FKz4eGM= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 h1:Jyp0Hsi0bmHXG6k9eATXoYtjd6e2UzZ1SCn/wIupY14= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:oQ5rr10WTTMvP4A36n8JpR1OrO1BEiV4f78CneXZxkA= +google.golang.org/grpc v1.61.1 h1:kLAiWrZs7YeDM6MumDe7m3y4aM6wacLzM1Y/wiLP9XY= +google.golang.org/grpc v1.61.1/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= +google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= From 0f02f8ddd7f221add0d894de67acc3bc422aace2 Mon Sep 17 00:00:00 2001 From: Alexis Charveriat Date: Thu, 29 Feb 2024 15:39:21 +0100 Subject: [PATCH 2/4] Fixed error when universal profiling is activated (#783) * Fixed error when universal profiling is activated The `profiling` and `symbols` endpoints were not being read from the response payload, causing an error. * Added changelog file --------- Co-authored-by: Alexis Charveriat --- .changelog/783.txt | 3 ++ .../v2/integrations_server_payload.go | 6 ++- .../v2/integrations_server_read.go | 12 ++++- .../v2/integrations_server_read_test.go | 50 ++++++++++++++++--- .../integrationsserver/v2/schema.go | 6 ++- 5 files changed, 65 insertions(+), 12 deletions(-) create mode 100644 .changelog/783.txt diff --git a/.changelog/783.txt b/.changelog/783.txt new file mode 100644 index 000000000..9ca07c6c9 --- /dev/null +++ b/.changelog/783.txt @@ -0,0 +1,3 @@ +```release-note:feature +resource/deployment: Added support for symbols and profiling endpoints. +``` diff --git a/ec/ecresource/deploymentresource/integrationsserver/v2/integrations_server_payload.go b/ec/ecresource/deploymentresource/integrationsserver/v2/integrations_server_payload.go index 990f23689..1c66dbc66 100644 --- a/ec/ecresource/deploymentresource/integrationsserver/v2/integrations_server_payload.go +++ b/ec/ecresource/deploymentresource/integrationsserver/v2/integrations_server_payload.go @@ -47,8 +47,10 @@ type IntegrationsServerTF struct { } type EndpointsTF struct { - Fleet *string `tfsdk:"fleet"` - APM *string `tfsdk:"apm"` + Fleet *string `tfsdk:"fleet"` + APM *string `tfsdk:"apm"` + Symbols *string `tfsdk:"symbols"` + Profiling *string `tfsdk:"profiling"` } func (srv IntegrationsServerTF) payload(ctx context.Context, payload models.IntegrationsServerPayload) (*models.IntegrationsServerPayload, diag.Diagnostics) { diff --git a/ec/ecresource/deploymentresource/integrationsserver/v2/integrations_server_read.go b/ec/ecresource/deploymentresource/integrationsserver/v2/integrations_server_read.go index fd32071e3..3e82b5e83 100644 --- a/ec/ecresource/deploymentresource/integrationsserver/v2/integrations_server_read.go +++ b/ec/ecresource/deploymentresource/integrationsserver/v2/integrations_server_read.go @@ -43,8 +43,10 @@ type IntegrationsServer struct { } type Endpoints struct { - Fleet *string `tfsdk:"fleet"` - APM *string `tfsdk:"apm"` + Fleet *string `tfsdk:"fleet"` + APM *string `tfsdk:"apm"` + Symbols *string `tfsdk:"symbols"` + Profiling *string `tfsdk:"profiling"` } func ReadIntegrationsServers(in []*models.IntegrationsServerResourceInfo) (*IntegrationsServer, error) { @@ -121,6 +123,12 @@ func readEndpoints(in *models.IntegrationsServerResourceInfo) *Endpoints { case "fleet": endpoints.Fleet = url.URL hasValidEndpoints = true + case "symbols": + endpoints.Symbols = url.URL + hasValidEndpoints = true + case "profiling": + endpoints.Profiling = url.URL + hasValidEndpoints = true } } diff --git a/ec/ecresource/deploymentresource/integrationsserver/v2/integrations_server_read_test.go b/ec/ecresource/deploymentresource/integrationsserver/v2/integrations_server_read_test.go index ddeeecc1d..5e7ae836d 100644 --- a/ec/ecresource/deploymentresource/integrationsserver/v2/integrations_server_read_test.go +++ b/ec/ecresource/deploymentresource/integrationsserver/v2/integrations_server_read_test.go @@ -84,6 +84,14 @@ func Test_readIntegrationsServer(t *testing.T) { Service: ec.String("fleet"), URL: ec.String("https://fleet_endpoint.cloud.elastic.co"), }, + { + Service: ec.String("symbols"), + URL: ec.String("https://symbols_endpoint.cloud.elastic.co"), + }, + { + Service: ec.String("profiling"), + URL: ec.String("https://profiling_endpoint.cloud.elastic.co"), + }, }, }, PlanInfo: &models.IntegrationsServerPlansInfo{Current: &models.IntegrationsServerPlanInfo{ @@ -115,8 +123,10 @@ func Test_readIntegrationsServer(t *testing.T) { HttpEndpoint: ec.String("http://integrations_serverresource.cloud.elastic.co:9200"), HttpsEndpoint: ec.String("https://integrations_serverresource.cloud.elastic.co:9243"), Endpoints: &Endpoints{ - Fleet: ec.String("https://fleet_endpoint.cloud.elastic.co"), - APM: ec.String("https://apm_endpoint.cloud.elastic.co"), + Fleet: ec.String("https://fleet_endpoint.cloud.elastic.co"), + APM: ec.String("https://apm_endpoint.cloud.elastic.co"), + Symbols: ec.String("https://symbols_endpoint.cloud.elastic.co"), + Profiling: ec.String("https://profiling_endpoint.cloud.elastic.co"), }, InstanceConfigurationId: ec.String("aws.integrations_server.r4"), InstanceConfigurationVersion: ec.Int(5), @@ -153,6 +163,14 @@ func Test_readIntegrationsServer(t *testing.T) { Service: ec.String("fleet"), URL: ec.String("https://fleet_endpoint.cloud.elastic.co"), }, + { + Service: ec.String("symbols"), + URL: ec.String("https://symbols_endpoint.cloud.elastic.co"), + }, + { + Service: ec.String("profiling"), + URL: ec.String("https://profiling_endpoint.cloud.elastic.co"), + }, }, }, PlanInfo: &models.IntegrationsServerPlansInfo{Current: &models.IntegrationsServerPlanInfo{ @@ -207,6 +225,14 @@ func Test_readIntegrationsServer(t *testing.T) { Service: ec.String("fleet"), URL: ec.String("https://fleet_endpoint.cloud.elastic.co"), }, + { + Service: ec.String("symbols"), + URL: ec.String("https://symbols_endpoint.cloud.elastic.co"), + }, + { + Service: ec.String("profiling"), + URL: ec.String("https://profiling_endpoint.cloud.elastic.co"), + }, }, }, PlanInfo: &models.IntegrationsServerPlansInfo{Current: &models.IntegrationsServerPlanInfo{ @@ -247,8 +273,10 @@ func Test_readIntegrationsServer(t *testing.T) { HttpEndpoint: ec.String("http://integrations_serverresource.cloud.elastic.co:9200"), HttpsEndpoint: ec.String("https://integrations_serverresource.cloud.elastic.co:9243"), Endpoints: &Endpoints{ - Fleet: ec.String("https://fleet_endpoint.cloud.elastic.co"), - APM: ec.String("https://apm_endpoint.cloud.elastic.co"), + Fleet: ec.String("https://fleet_endpoint.cloud.elastic.co"), + APM: ec.String("https://apm_endpoint.cloud.elastic.co"), + Symbols: ec.String("https://symbols_endpoint.cloud.elastic.co"), + Profiling: ec.String("https://profiling_endpoint.cloud.elastic.co"), }, InstanceConfigurationId: ec.String("aws.integrations_server.r4"), Size: ec.String("1g"), @@ -289,6 +317,14 @@ func Test_readIntegrationsServer(t *testing.T) { Service: ec.String("fleet"), URL: ec.String("https://fleet_endpoint.cloud.elastic.co"), }, + { + Service: ec.String("symbols"), + URL: ec.String("https://symbols_endpoint.cloud.elastic.co"), + }, + { + Service: ec.String("profiling"), + URL: ec.String("https://profiling_endpoint.cloud.elastic.co"), + }, }, }, PlanInfo: &models.IntegrationsServerPlansInfo{Current: &models.IntegrationsServerPlanInfo{ @@ -330,8 +366,10 @@ func Test_readIntegrationsServer(t *testing.T) { HttpEndpoint: ec.String("http://integrations_serverresource.cloud.elastic.co:9200"), HttpsEndpoint: ec.String("https://integrations_serverresource.cloud.elastic.co:9243"), Endpoints: &Endpoints{ - Fleet: ec.String("https://fleet_endpoint.cloud.elastic.co"), - APM: ec.String("https://apm_endpoint.cloud.elastic.co"), + Fleet: ec.String("https://fleet_endpoint.cloud.elastic.co"), + APM: ec.String("https://apm_endpoint.cloud.elastic.co"), + Symbols: ec.String("https://symbols_endpoint.cloud.elastic.co"), + Profiling: ec.String("https://profiling_endpoint.cloud.elastic.co"), }, InstanceConfigurationId: ec.String("aws.integrations_server.r4"), Size: ec.String("1g"), diff --git a/ec/ecresource/deploymentresource/integrationsserver/v2/schema.go b/ec/ecresource/deploymentresource/integrationsserver/v2/schema.go index 46e54d1e8..f368da866 100644 --- a/ec/ecresource/deploymentresource/integrationsserver/v2/schema.go +++ b/ec/ecresource/deploymentresource/integrationsserver/v2/schema.go @@ -76,8 +76,10 @@ func IntegrationsServerSchema() schema.Attribute { Computed: true, Description: "URLs for the accessing the Fleet and APM API's within this Integrations Server resource.", AttributeTypes: map[string]attr.Type{ - "apm": types.StringType, - "fleet": types.StringType, + "apm": types.StringType, + "fleet": types.StringType, + "symbols": types.StringType, + "profiling": types.StringType, }, PlanModifiers: []planmodifier.Object{ objectplanmodifier.UseStateForUnknown(), From 8c29ee8f332bfd437a49f5da976e1db41cde0f48 Mon Sep 17 00:00:00 2001 From: Toby Brain Date: Wed, 6 Mar 2024 19:01:51 +1100 Subject: [PATCH 3/4] Stateless resources require kibana (#792) * Stateless resources require kibana * Changelog --- .changelog/792.txt | 3 +++ ec/ecresource/deploymentresource/apm/v2/schema.go | 6 ++++++ .../deploymentresource/enterprisesearch/v2/schema.go | 6 ++++++ .../deploymentresource/integrationsserver/v2/schema.go | 6 ++++++ 4 files changed, 21 insertions(+) create mode 100644 .changelog/792.txt diff --git a/.changelog/792.txt b/.changelog/792.txt new file mode 100644 index 000000000..78828d2a9 --- /dev/null +++ b/.changelog/792.txt @@ -0,0 +1,3 @@ +```release-note:feature +resource/deployment: Validate the Kibana is present when attempting to enable other stateless resources. +``` diff --git a/ec/ecresource/deploymentresource/apm/v2/schema.go b/ec/ecresource/deploymentresource/apm/v2/schema.go index 56947d659..95baa6e15 100644 --- a/ec/ecresource/deploymentresource/apm/v2/schema.go +++ b/ec/ecresource/deploymentresource/apm/v2/schema.go @@ -19,16 +19,22 @@ package v2 import ( "github.com/elastic/terraform-provider-ec/ec/internal/planmodifiers" + "github.com/hashicorp/terraform-plugin-framework-validators/objectvalidator" + "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" ) func ApmConfigSchema() schema.Attribute { return schema.SingleNestedAttribute{ Description: `Optionally define the Apm configuration options for the APM Server`, Optional: true, + Validators: []validator.Object{ + objectvalidator.AlsoRequires(path.MatchRoot("kibana")), + }, Attributes: map[string]schema.Attribute{ "docker_image": schema.StringAttribute{ Description: "Optionally override the docker image the APM nodes will use. This option will not work in ESS customers and should only be changed if you know what you're doing.", diff --git a/ec/ecresource/deploymentresource/enterprisesearch/v2/schema.go b/ec/ecresource/deploymentresource/enterprisesearch/v2/schema.go index 5c6edae65..69b400c02 100644 --- a/ec/ecresource/deploymentresource/enterprisesearch/v2/schema.go +++ b/ec/ecresource/deploymentresource/enterprisesearch/v2/schema.go @@ -19,17 +19,23 @@ package v2 import ( "github.com/elastic/terraform-provider-ec/ec/internal/planmodifiers" + "github.com/hashicorp/terraform-plugin-framework-validators/objectvalidator" + "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/boolplanmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" ) func EnterpriseSearchSchema() schema.Attribute { return schema.SingleNestedAttribute{ Description: "Enterprise Search cluster definition.", Optional: true, + Validators: []validator.Object{ + objectvalidator.AlsoRequires(path.MatchRoot("kibana")), + }, Attributes: map[string]schema.Attribute{ "elasticsearch_cluster_ref_id": schema.StringAttribute{ Optional: true, diff --git a/ec/ecresource/deploymentresource/integrationsserver/v2/schema.go b/ec/ecresource/deploymentresource/integrationsserver/v2/schema.go index f368da866..bf273f5e4 100644 --- a/ec/ecresource/deploymentresource/integrationsserver/v2/schema.go +++ b/ec/ecresource/deploymentresource/integrationsserver/v2/schema.go @@ -19,12 +19,15 @@ package v2 import ( "github.com/elastic/terraform-provider-ec/ec/internal/planmodifiers" + "github.com/hashicorp/terraform-plugin-framework-validators/objectvalidator" "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource/schema" "github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/objectplanmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" "github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier" + "github.com/hashicorp/terraform-plugin-framework/schema/validator" "github.com/hashicorp/terraform-plugin-framework/types" ) @@ -32,6 +35,9 @@ func IntegrationsServerSchema() schema.Attribute { return schema.SingleNestedAttribute{ Description: "Integrations Server cluster definition. Integrations Server replaces `apm` in Stack versions > 8.0", Optional: true, + Validators: []validator.Object{ + objectvalidator.AlsoRequires(path.MatchRoot("kibana")), + }, Attributes: map[string]schema.Attribute{ "elasticsearch_cluster_ref_id": schema.StringAttribute{ Optional: true, From cc5eba766e8b7187007f544c0c8cb642d1be0fa6 Mon Sep 17 00:00:00 2001 From: Toby Brain Date: Mon, 11 Mar 2024 16:35:06 +1100 Subject: [PATCH 4/4] Persist snapshot source in the read response (#788) * Persist snapshot source in the read response * Unit tests * Changelog --- .changelog/788.txt | 3 + .../deployment/v2/deployment_read.go | 27 +++++++- .../deployment/v2/deployment_read_test.go | 61 +++++++++++++++++++ .../elasticsearch/v2/schema.go | 4 +- ec/ecresource/deploymentresource/read.go | 1 + 5 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 .changelog/788.txt diff --git a/.changelog/788.txt b/.changelog/788.txt new file mode 100644 index 000000000..3b326a7f7 --- /dev/null +++ b/.changelog/788.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/deployment: Persist the snapshot source settings during reads. This fixes a [provider crash](https://github.com/elastic/terraform-provider-ec/issues/787) when creating a deployment from a snapshot. +``` diff --git a/ec/ecresource/deploymentresource/deployment/v2/deployment_read.go b/ec/ecresource/deploymentresource/deployment/v2/deployment_read.go index 8fbbd0622..f052872e6 100644 --- a/ec/ecresource/deploymentresource/deployment/v2/deployment_read.go +++ b/ec/ecresource/deploymentresource/deployment/v2/deployment_read.go @@ -21,15 +21,17 @@ import ( "context" "errors" "fmt" - "github.com/elastic/cloud-sdk-go/pkg/client/deployments" "slices" "strings" + "github.com/elastic/cloud-sdk-go/pkg/client/deployments" + "github.com/blang/semver" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" apmv2 "github.com/elastic/terraform-provider-ec/ec/ecresource/deploymentresource/apm/v2" + elasticsearchv1 "github.com/elastic/terraform-provider-ec/ec/ecresource/deploymentresource/elasticsearch/v1" elasticsearchv2 "github.com/elastic/terraform-provider-ec/ec/ecresource/deploymentresource/elasticsearch/v2" enterprisesearchv2 "github.com/elastic/terraform-provider-ec/ec/ecresource/deploymentresource/enterprisesearch/v2" integrationsserverv2 "github.com/elastic/terraform-provider-ec/ec/ecresource/deploymentresource/integrationsserver/v2" @@ -39,6 +41,7 @@ import ( "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" ) @@ -65,6 +68,28 @@ type Deployment struct { MigrateToLatestHardware *bool `tfsdk:"migrate_to_latest_hardware"` } +func (dep *Deployment) PersistSnapshotSource(ctx context.Context, esPlan *elasticsearchv2.ElasticsearchTF) diag.Diagnostics { + if dep == nil || dep.Elasticsearch == nil { + return nil + } + + if esPlan == nil || esPlan.SnapshotSource.IsNull() || esPlan.SnapshotSource.IsUnknown() { + return nil + } + + var snapshotSource *elasticsearchv1.ElasticsearchSnapshotSourceTF + if diags := tfsdk.ValueAs(ctx, esPlan.SnapshotSource, &snapshotSource); diags.HasError() { + return diags + } + + dep.Elasticsearch.SnapshotSource = &elasticsearchv2.ElasticsearchSnapshotSource{ + SourceElasticsearchClusterId: snapshotSource.SourceElasticsearchClusterId.ValueString(), + SnapshotName: snapshotSource.SnapshotName.ValueString(), + } + + return nil +} + // Nullify Elasticsearch topologies that have zero size and are not specified in plan func (dep *Deployment) NullifyUnusedEsTopologies(ctx context.Context, esPlan *elasticsearchv2.ElasticsearchTF) { if dep.Elasticsearch == nil { diff --git a/ec/ecresource/deploymentresource/deployment/v2/deployment_read_test.go b/ec/ecresource/deploymentresource/deployment/v2/deployment_read_test.go index 12144a093..f10ca629a 100644 --- a/ec/ecresource/deploymentresource/deployment/v2/deployment_read_test.go +++ b/ec/ecresource/deploymentresource/deployment/v2/deployment_read_test.go @@ -18,6 +18,7 @@ package v2 import ( + "context" "errors" "testing" @@ -25,11 +26,15 @@ import ( "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" apmv2 "github.com/elastic/terraform-provider-ec/ec/ecresource/deploymentresource/apm/v2" + elasticsearchv1 "github.com/elastic/terraform-provider-ec/ec/ecresource/deploymentresource/elasticsearch/v1" elasticsearchv2 "github.com/elastic/terraform-provider-ec/ec/ecresource/deploymentresource/elasticsearch/v2" enterprisesearchv2 "github.com/elastic/terraform-provider-ec/ec/ecresource/deploymentresource/enterprisesearch/v2" kibanav2 "github.com/elastic/terraform-provider-ec/ec/ecresource/deploymentresource/kibana/v2" observabilityv2 "github.com/elastic/terraform-provider-ec/ec/ecresource/deploymentresource/observability/v2" + "github.com/hashicorp/terraform-plugin-framework/tfsdk" + "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func Test_readDeployment(t *testing.T) { @@ -1723,3 +1728,59 @@ func Test_getDeploymentTemplateID(t *testing.T) { }) } } + +func Test_PersistSnapshotSource(t *testing.T) { + tests := []struct { + name string + deployment *Deployment + snapshotSource *elasticsearchv1.ElasticsearchSnapshotSource + expectedSourceElasticsearchClusterId string + expectedSnapshotName string + }{ + { + name: "should noop if deployment is nil", + }, + { + name: "should noop if the esplan snapshot source is null", + deployment: &Deployment{}, + }, + { + name: "should set the snapshot source cluster and snapshot name if specified in the plan", + deployment: &Deployment{ + Elasticsearch: &elasticsearchv2.Elasticsearch{}, + }, + snapshotSource: &elasticsearchv1.ElasticsearchSnapshotSource{ + SourceElasticsearchClusterId: "source-cluster-id", + SnapshotName: "snapshot-name", + }, + expectedSourceElasticsearchClusterId: "source-cluster-id", + expectedSnapshotName: "snapshot-name", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + var obj types.Object + if tt.snapshotSource != nil { + diags := tfsdk.ValueFrom(context.Background(), tt.snapshotSource, elasticsearchv2.ElasticsearchSnapshotSourceSchema().GetType(), &obj) + require.Nil(t, diags) + } + + esPlan := elasticsearchv2.ElasticsearchTF{ + SnapshotSource: obj, + } + + diags := tt.deployment.PersistSnapshotSource(context.Background(), &esPlan) + require.Nil(t, diags) + + var snapshotName, sourceESClusterID string + if tt.deployment != nil && tt.deployment.Elasticsearch != nil && tt.deployment.Elasticsearch.SnapshotSource != nil { + snapshotName = tt.deployment.Elasticsearch.SnapshotSource.SnapshotName + sourceESClusterID = tt.deployment.Elasticsearch.SnapshotSource.SourceElasticsearchClusterId + } + + require.Equal(t, tt.expectedSnapshotName, snapshotName) + require.Equal(t, tt.expectedSourceElasticsearchClusterId, sourceESClusterID) + }) + } +} diff --git a/ec/ecresource/deploymentresource/elasticsearch/v2/schema.go b/ec/ecresource/deploymentresource/elasticsearch/v2/schema.go index 9f01eb0ea..1f4ebc9ee 100644 --- a/ec/ecresource/deploymentresource/elasticsearch/v2/schema.go +++ b/ec/ecresource/deploymentresource/elasticsearch/v2/schema.go @@ -141,7 +141,7 @@ func ElasticsearchSchema() schema.Attribute { "snapshot": elasticsearchSnapshotSchema(), - "snapshot_source": elasticsearchSnapshotSourceSchema(), + "snapshot_source": ElasticsearchSnapshotSourceSchema(), "extension": elasticsearchExtensionSchema(), @@ -361,7 +361,7 @@ func elasticsearchSnapshotRepositoryReferenceSchema() schema.Attribute { } } -func elasticsearchSnapshotSourceSchema() schema.Attribute { +func ElasticsearchSnapshotSourceSchema() schema.Attribute { return schema.SingleNestedAttribute{ Description: `Restores data from a snapshot of another deployment. diff --git a/ec/ecresource/deploymentresource/read.go b/ec/ecresource/deploymentresource/read.go index 32e3cb118..61d450edc 100644 --- a/ec/ecresource/deploymentresource/read.go +++ b/ec/ecresource/deploymentresource/read.go @@ -177,6 +177,7 @@ func (r *Resource) read(ctx context.Context, id string, state *deploymentv2.Depl deployment.ProcessSelfInObservability() deployment.NullifyUnusedEsTopologies(ctx, baseElasticsearch) + diags.Append(deployment.PersistSnapshotSource(ctx, baseElasticsearch)...) if !deployment.HasNodeTypes() { // The MigrateDeploymentTemplate request can only be performed for deployments that use node roles.