Skip to content

Commit 181c0d5

Browse files
committed
allowing removal of certificate from listener and fix for load balancer resources case where the id of the work request is stored in the statefile
1 parent 4fd21a6 commit 181c0d5

11 files changed

+32
-40
lines changed

oci/core_public_ip_resource.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ func PublicIpResource() *schema.Resource {
5555
"private_ip_id": {
5656
Type: schema.TypeString,
5757
Optional: true,
58-
// Computed: true, Commented out because we want to allow unsetting the value.
5958
},
6059

6160
// Computed

oci/core_security_list_resource.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ func SecurityListResource() *schema.Resource {
5858
"icmp_options": {
5959
Type: schema.TypeList,
6060
Optional: true,
61-
// @CODEGEN 2/2018: This should not be a computed field as generated, as it breaks how Terraform
62-
// considers diffs when the number of icmp_options, tcp_options, and udp_options change.
6361
MaxItems: 1,
6462
MinItems: 1,
6563
Elem: &schema.Resource{
@@ -89,8 +87,6 @@ func SecurityListResource() *schema.Resource {
8987
"tcp_options": {
9088
Type: schema.TypeList,
9189
Optional: true,
92-
// @CODEGEN 2/2018: This should not be a computed field as generated, as it breaks how Terraform
93-
// considers diffs when the number of icmp_options, tcp_options, and udp_options change.
9490
MaxItems: 1,
9591
MinItems: 1,
9692
Elem: &schema.Resource{
@@ -143,8 +139,6 @@ func SecurityListResource() *schema.Resource {
143139
"udp_options": {
144140
Type: schema.TypeList,
145141
Optional: true,
146-
// @CODEGEN 2/2018: This should not be a computed field as generated, as it breaks how Terraform
147-
// considers diffs when the number of icmp_options, tcp_options, and udp_options change.
148142
MaxItems: 1,
149143
MinItems: 1,
150144
Elem: &schema.Resource{
@@ -215,8 +209,6 @@ func SecurityListResource() *schema.Resource {
215209
"icmp_options": {
216210
Type: schema.TypeList,
217211
Optional: true,
218-
// @CODEGEN 2/2018: This should not be a computed field as generated, as it breaks how Terraform
219-
// considers diffs when the number of icmp_options, tcp_options, and udp_options change.
220212
MaxItems: 1,
221213
MinItems: 1,
222214
Elem: &schema.Resource{
@@ -255,8 +247,6 @@ func SecurityListResource() *schema.Resource {
255247
"tcp_options": {
256248
Type: schema.TypeList,
257249
Optional: true,
258-
// @CODEGEN 2/2018: This should not be a computed field as generated, as it breaks how Terraform
259-
// considers diffs when the number of icmp_options, tcp_options, and udp_options change.
260250
MaxItems: 1,
261251
MinItems: 1,
262252
Elem: &schema.Resource{
@@ -305,8 +295,6 @@ func SecurityListResource() *schema.Resource {
305295
"udp_options": {
306296
Type: schema.TypeList,
307297
Optional: true,
308-
// @CODEGEN 2/2018: This should not be a computed field as generated, as it breaks how Terraform
309-
// considers diffs when the number of icmp_options, tcp_options, and udp_options change.
310298
MaxItems: 1,
311299
MinItems: 1,
312300
Elem: &schema.Resource{

oci/crud_helpers.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,10 @@ func LoadBalancerResourceID(res interface{}, workReq *oci_load_balancer.WorkRequ
143143
}
144144

145145
func LoadBalancerResourceGet(client *oci_load_balancer.LoadBalancerClient, d *schema.ResourceData, wr *oci_load_balancer.WorkRequest, retryPolicy *oci_common.RetryPolicy) (id string, stillWorking bool, err error) {
146-
id = d.Id()
147146
// NOTE: if the id is for a work request, refresh its state and loadBalancerID.
148-
if strings.HasPrefix(id, "ocid1.loadbalancerworkrequest.") {
147+
if wr != nil && wr.Id != nil {
149148
getWorkRequestRequest := oci_load_balancer.GetWorkRequestRequest{}
150-
getWorkRequestRequest.WorkRequestId = &id
149+
getWorkRequestRequest.WorkRequestId = wr.Id
151150
getWorkRequestRequest.RequestMetadata.RetryPolicy = retryPolicy
152151
updatedWorkRes, err := client.GetWorkRequest(context.Background(), getWorkRequestRequest)
153152
if err != nil {

oci/load_balancer_backend_resource.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,6 @@ func (s *BackendResourceCrud) Update() error {
352352
}
353353

354354
func (s *BackendResourceCrud) Delete() error {
355-
if strings.Contains(s.D.Id(), "ocid1.loadbalancerworkrequest") {
356-
return nil
357-
}
358355
request := oci_load_balancer.DeleteBackendRequest{}
359356

360357
if backendName, ok := s.D.GetOkExists("name"); ok {

oci/load_balancer_backend_set_resource.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -520,9 +520,6 @@ func (s *BackendSetResourceCrud) Update() error {
520520
}
521521

522522
func (s *BackendSetResourceCrud) Delete() error {
523-
if strings.Contains(s.D.Id(), "ocid1.loadbalancerworkrequest") {
524-
return nil
525-
}
526523
request := oci_load_balancer.DeleteBackendSetRequest{}
527524

528525
if backendSetName, ok := s.D.GetOkExists("name"); ok {

oci/load_balancer_certificate_resource.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package provider
55
import (
66
"context"
77
"errors"
8-
"strings"
98

109
"github.com/hashicorp/terraform/helper/schema"
1110

@@ -231,9 +230,6 @@ func (s *CertificateResourceCrud) Get() error {
231230
}
232231

233232
func (s *CertificateResourceCrud) Delete() error {
234-
if strings.Contains(s.D.Id(), "ocid1.loadbalancerworkrequest") {
235-
return nil
236-
}
237233
request := oci_load_balancer.DeleteCertificateRequest{}
238234

239235
if certificateName, ok := s.D.GetOkExists("certificate_name"); ok {

oci/load_balancer_hostname_resource.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,6 @@ func (s *HostnameResourceCrud) Update() error {
259259
}
260260

261261
func (s *HostnameResourceCrud) Delete() error {
262-
if strings.Contains(s.D.Id(), "ocid1.loadbalancerworkrequest") {
263-
return nil
264-
}
265262
request := oci_load_balancer.DeleteHostnameRequest{}
266263

267264
if loadBalancerId, ok := s.D.GetOkExists("load_balancer_id"); ok {

oci/load_balancer_listener_resource.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ func ListenerResource() *schema.Resource {
9090
"ssl_configuration": {
9191
Type: schema.TypeList,
9292
Optional: true,
93-
Computed: true,
9493
MaxItems: 1,
9594
MinItems: 1,
9695
Elem: &schema.Resource{
@@ -436,9 +435,6 @@ func (s *ListenerResourceCrud) Update() error {
436435
}
437436

438437
func (s *ListenerResourceCrud) Delete() error {
439-
if strings.Contains(s.D.Id(), "ocid1.loadbalancerworkrequest") {
440-
return nil
441-
}
442438
request := oci_load_balancer.DeleteListenerRequest{}
443439

444440
if listenerName, ok := s.D.GetOkExists("name"); ok {

oci/load_balancer_listener_resource_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,36 @@ func (s *ResourceLoadBalancerListenerTestSuite) TestAccResourceLoadBalancerListe
167167
},
168168
),
169169
},
170+
// test remove ssl configuration
171+
{
172+
Config: s.Config + `
173+
resource "oci_load_balancer_listener" "t" {
174+
load_balancer_id = "${oci_load_balancer.t.id}"
175+
name = "-tf-listener-updated"
176+
default_backend_set_name = "${oci_load_balancer_backendset.t.name}"
177+
port = 443
178+
protocol = "HTTP"
179+
}`,
180+
Check: resource.ComposeAggregateTestCheckFunc(
181+
resource.TestCheckResourceAttrSet(s.ResourceName, "load_balancer_id"),
182+
resource.TestCheckResourceAttr(s.ResourceName, "name", "-tf-listener-updated"),
183+
resource.TestCheckResourceAttr(s.ResourceName, "default_backend_set_name", "-tf-backend-set"),
184+
resource.TestCheckResourceAttr(s.ResourceName, "protocol", "HTTP"),
185+
resource.TestCheckResourceAttr(s.ResourceName, "port", "443"),
186+
resource.TestCheckNoResourceAttr(s.ResourceName, "ssl_configuration.0.certificate_name"),
187+
resource.TestCheckNoResourceAttr(s.ResourceName, "ssl_configuration.0.verify_depth"),
188+
resource.TestCheckNoResourceAttr(s.ResourceName, "ssl_configuration.0.verify_peer_certificate"),
189+
resource.TestCheckResourceAttr(s.ResourceName, "state", string(loadbalancer.WorkRequestLifecycleStateSucceeded)),
190+
func(ts *terraform.State) (err error) {
191+
resId2, err = fromInstanceState(ts, s.ResourceName, "id")
192+
if resId2 != resId {
193+
return fmt.Errorf("resource recreated when it should not have been")
194+
}
195+
resId = resId2
196+
return err
197+
},
198+
),
199+
},
170200
// verify resource import
171201
{
172202
Config: s.Config + `

oci/load_balancer_load_balancer_resource.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ package provider
44

55
import (
66
"context"
7-
"strings"
87

98
"github.com/hashicorp/terraform/helper/schema"
109

@@ -339,9 +338,6 @@ func (s *LoadBalancerResourceCrud) Update() error {
339338
}
340339

341340
func (s *LoadBalancerResourceCrud) Delete() error {
342-
if strings.Contains(s.D.Id(), "ocid1.loadbalancerworkrequest") {
343-
return nil
344-
}
345341
request := oci_load_balancer.DeleteLoadBalancerRequest{}
346342

347343
tmp := s.D.Id()

0 commit comments

Comments
 (0)