Skip to content

Commit 4eb575c

Browse files
coderGo93Edgar López
andauthored
INTMDB-169: delete encoding url path in private endpoint service (#393)
* chore: updated client mongodb with recent release * refactor: deleted encoding url path in private endpoint service because it's already encoding in client Co-authored-by: Edgar López <[email protected]>
1 parent fea51f6 commit 4eb575c

4 files changed

+6
-15
lines changed

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,6 @@ go.mongodb.org/atlas v0.6.1-0.20210106014125-8dd299fe028a h1:5gYtQbQA6MCmHkOe7nA
609609
go.mongodb.org/atlas v0.6.1-0.20210106014125-8dd299fe028a/go.mod h1:CIaBeO8GLHhtYLw7xSSXsw7N90Z4MFY87Oy9qcPyuEs=
610610
go.mongodb.org/atlas v0.7.0 h1:nBur5go1JSCFCi1VaQ7Ry6du2uHjMFY0w8rI64KQ+b0=
611611
go.mongodb.org/atlas v0.7.0/go.mod h1:CIaBeO8GLHhtYLw7xSSXsw7N90Z4MFY87Oy9qcPyuEs=
612-
go.mongodb.org/atlas v0.7.1-0.20210125210709-d3fc89f33ab2 h1:MDNdtE3XPOOpyoFFOo0a8BbodicG6DQMgNS5FPag9/g=
613-
go.mongodb.org/atlas v0.7.1-0.20210125210709-d3fc89f33ab2/go.mod h1:CIaBeO8GLHhtYLw7xSSXsw7N90Z4MFY87Oy9qcPyuEs=
614612
go.mongodb.org/atlas v0.7.1 h1:hNBtwtKgmhB9vmSX/JyN/cArmhzyy4ihKpmXSMIc4mw=
615613
go.mongodb.org/atlas v0.7.1/go.mod h1:CIaBeO8GLHhtYLw7xSSXsw7N90Z4MFY87Oy9qcPyuEs=
616614
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=

mongodbatlas/data_source_mongodbatlas_privatelink_endpoint_service.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package mongodbatlas
33
import (
44
"context"
55
"fmt"
6-
"net/url"
76

87
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
98
"github.com/spf13/cast"
@@ -75,9 +74,8 @@ func dataSourceMongoDBAtlasPrivateEndpointServiceLinkRead(d *schema.ResourceData
7574
privateLinkID := d.Get("private_link_id").(string)
7675
endpointServiceID := d.Get("endpoint_service_id").(string)
7776
providerName := d.Get("provider_name").(string)
78-
encodedEndpointID := url.PathEscape(endpointServiceID)
7977

80-
serviceEndpoint, _, err := conn.PrivateEndpoints.GetOnePrivateEndpoint(context.Background(), projectID, providerName, privateLinkID, encodedEndpointID)
78+
serviceEndpoint, _, err := conn.PrivateEndpoints.GetOnePrivateEndpoint(context.Background(), projectID, providerName, privateLinkID, endpointServiceID)
8179
if err != nil {
8280
return fmt.Errorf(errorServiceEndpointRead, endpointServiceID, err)
8381
}

mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"errors"
66
"fmt"
7-
"net/url"
87
"strings"
98
"time"
109

@@ -136,9 +135,8 @@ func resourceMongoDBAtlasPrivateEndpointServiceLinkRead(d *schema.ResourceData,
136135
privateLinkID := ids["private_link_id"]
137136
endpointServiceID := ids["endpoint_service_id"]
138137
providerName := ids["provider_name"]
139-
encodedEndpointID := url.PathEscape(endpointServiceID)
140138

141-
privateEndpoint, _, err := conn.PrivateEndpoints.GetOnePrivateEndpoint(context.Background(), projectID, providerName, privateLinkID, encodedEndpointID)
139+
privateEndpoint, _, err := conn.PrivateEndpoints.GetOnePrivateEndpoint(context.Background(), projectID, providerName, privateLinkID, endpointServiceID)
142140
if err != nil {
143141
return fmt.Errorf(errorServiceEndpointRead, endpointServiceID, err)
144142
}
@@ -190,10 +188,9 @@ func resourceMongoDBAtlasPrivateEndpointServiceLinkDelete(d *schema.ResourceData
190188
privateLinkID := ids["private_link_id"]
191189
endpointServiceID := ids["endpoint_service_id"]
192190
providerName := ids["provider_name"]
193-
encodedEndpointID := url.PathEscape(endpointServiceID)
194191

195192
if endpointServiceID != "" {
196-
_, err := conn.PrivateEndpoints.DeleteOnePrivateEndpoint(context.Background(), projectID, providerName, privateLinkID, encodedEndpointID)
193+
_, err := conn.PrivateEndpoints.DeleteOnePrivateEndpoint(context.Background(), projectID, providerName, privateLinkID, endpointServiceID)
197194
if err != nil {
198195
return fmt.Errorf(errorEndpointDelete, endpointServiceID, err)
199196
}
@@ -229,9 +226,8 @@ func resourceMongoDBAtlasPrivateEndpointServiceLinkImportState(d *schema.Resourc
229226
privateLinkID := parts[1]
230227
endpointServiceID := parts[2]
231228
providerName := parts[3]
232-
encodedEndpointID := url.PathEscape(endpointServiceID)
233229

234-
_, _, err := conn.PrivateEndpoints.GetOnePrivateEndpoint(context.Background(), projectID, providerName, privateLinkID, encodedEndpointID)
230+
_, _, err := conn.PrivateEndpoints.GetOnePrivateEndpoint(context.Background(), projectID, providerName, privateLinkID, endpointServiceID)
235231
if err != nil {
236232
return nil, fmt.Errorf(errorServiceEndpointRead, endpointServiceID, err)
237233
}

mongodbatlas/resource_mongodbatlas_privatelink_endpoint_service_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package mongodbatlas
33
import (
44
"context"
55
"fmt"
6-
"net/url"
76
"os"
87
"testing"
98

@@ -118,7 +117,7 @@ func testAccCheckMongoDBAtlasPrivateLinkEndpointServiceExists(resourceName strin
118117

119118
ids := decodeStateID(rs.Primary.ID)
120119

121-
_, _, err := conn.PrivateEndpoints.GetOnePrivateEndpoint(context.Background(), ids["project_id"], ids["provider_name"], ids["private_link_id"], url.QueryEscape(ids["endpoint_service_id"]))
120+
_, _, err := conn.PrivateEndpoints.GetOnePrivateEndpoint(context.Background(), ids["project_id"], ids["provider_name"], ids["private_link_id"], ids["endpoint_service_id"])
122121
if err == nil {
123122
return nil
124123
}
@@ -136,7 +135,7 @@ func testAccCheckMongoDBAtlasPrivateLinkEndpointServiceDestroy(s *terraform.Stat
136135
}
137136

138137
ids := decodeStateID(rs.Primary.ID)
139-
_, _, err := conn.PrivateEndpoints.GetOnePrivateEndpoint(context.Background(), ids["project_id"], ids["provider_name"], ids["endpoint_service_id"], ids["private_link_id"])
138+
_, _, err := conn.PrivateEndpoints.GetOnePrivateEndpoint(context.Background(), ids["project_id"], ids["provider_name"], ids["private_link_id"], ids["endpoint_service_id"])
140139
if err == nil {
141140
return fmt.Errorf("the MongoDB Private Endpoint(%s) still exists", ids["endpoint_service_id"])
142141
}

0 commit comments

Comments
 (0)