Skip to content

Commit 5da3c17

Browse files
authored
Merge pull request #1133 from duplocloud/hotfix/0.11.17
Hotfix Release v0.11.17
2 parents 4c3ddc4 + 4c77b1f commit 5da3c17

File tree

25 files changed

+171
-68
lines changed

25 files changed

+171
-68
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ NAMESPACE=duplocloud
88

99
NAME=duplocloud
1010
BINARY=terraform-provider-${NAME}
11-
VERSION=0.11.16
11+
VERSION=0.11.17
1212
#mac
1313
#OS_ARCH=darwin_amd64
1414
#OS_ARCH=linux_amd64

docs/resources/k8_ingress.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ resource "duplocloud_k8_ingress" "ingress" {
100100
name = "external-echo"
101101
ingress_class_name = "alb"
102102
lbconfig {
103-
is_internal = false
104-
dns_prefix = "external-echo"
105-
certificate_arn = "put your certificate ARN here"
106-
https_port = 443
103+
is_internal = false
104+
dns_prefix = "external-echo"
105+
certificate_arns = ["<cert-arn1>", "<cert-arn2>"]
106+
https_port = 443
107107
}
108108
109109
rule {
@@ -245,7 +245,8 @@ Required:
245245

246246
Optional:
247247

248-
- `certificate_arn` (String) The ARN of an ACM certificate to associate with this load balancer. Only applicable for HTTPS.
248+
- `certificate_arn` (String, Deprecated) The ARN of an ACM certificate to associate with this load balancer. Only applicable for HTTPS. This field has been deprecated use certificate_arns
249+
- `certificate_arns` (List of String) The list of ARN of an ACM certificate to associate with this load balancer. Only applicable for HTTPS.
249250
- `http_port` (Number) HTTP Listener Port.
250251
- `https_port` (Number) HTTPS Listener Port.
251252
- `port_override` (String) Port override for the load balancer. Currently supported for Azure

duplocloud/provider_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ package duplocloud
22

33
import (
44
"context"
5-
"github.com/duplocloud/terraform-provider-duplocloud/duplosdk"
6-
"github.com/duplocloud/terraform-provider-duplocloud/internal/duplosdktest"
75
"log"
86
"strings"
97

8+
"github.com/duplocloud/terraform-provider-duplocloud/duplosdk"
9+
"github.com/duplocloud/terraform-provider-duplocloud/internal/duplosdktest"
10+
1011
"github.com/barkimedes/go-deepcopy"
1112
"github.com/google/uuid"
1213
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
@@ -85,7 +86,7 @@ func testAccProvider_ConfigureContextFunc(d *schema.Provider) schema.ConfigureCo
8586
return
8687
},
8788
},
88-
"/adminproxy/GetInfrastructureConfig/:infraName": {
89+
"/v3/admin/infrastructure/:infraName": {
8990
Factory: func() interface{} { return &duplosdk.DuploInfrastructureConfig{} },
9091
Responder: func(verb string, in interface{}) (id string, out interface{}) {
9192
out = deepcopy.MustAnything(in.(*duplosdk.DuploInfrastructureConfig))

duplocloud/resource_duplo_ecache_instance.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,11 +316,7 @@ func resourceDuploEcacheInstanceCreate(ctx context.Context, d *schema.ResourceDa
316316
}
317317
c := m.(*duplosdk.Client)
318318

319-
fullName, errname := c.GetResourceName("duplo", tenantID, duplo.Name, false)
320-
if errname != nil {
321-
return diag.Errorf("resourceDuploEcacheInstanceCreate: Unable to retrieve duplo service name (name: %s, error: %s)", duplo.Name, errname.Error())
322-
323-
}
319+
fullName := "duplo-" + duplo.Name
324320
if !validateStringLength(fullName, TOTALECACHENAMELENGTH) {
325321
return diag.Errorf("resourceDuploEcacheInstanceCreate: fullname %s exceeds allowable ecache name length %d)", fullName, TOTALECACHENAMELENGTH)
326322

duplocloud/resource_duplo_gcp_k8_node_pool.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,13 +725,15 @@ func resourceGCPNodePoolRead(ctx context.Context, d *schema.ResourceData, m inte
725725
duplo, err := c.GCPK8NodePoolGet(tenantID, fullName)
726726
if err != nil {
727727
if err.Status() == 404 {
728+
log.Printf("GCP node pool %s not found", fullName)
728729
d.SetId("") // object missing or deleted
729730
return nil
730731
}
731732
return diag.Errorf("Unable to retrieve tenant %s GCP Node Pool Domain '%s': %s", tenantID, fullName, err)
732733
}
733734

734735
if duplo == nil {
736+
log.Printf("GCP node pool %s not found", fullName)
735737
d.SetId("") // object missing or deleted
736738
return nil
737739
}
@@ -917,9 +919,13 @@ func resourceGcpNodePoolDelete(ctx context.Context, d *schema.ResourceData, m in
917919
}
918920

919921
err = c.GCPK8NodePoolDelete(tenantID, fullName)
920-
if err != nil {
922+
if err != nil && err.Status() != 404 {
921923
return diag.Errorf("Error deleting node pool '%s': %s", id, err)
922924
}
925+
if err != nil && err.Status() == 404 {
926+
log.Printf("GCP node pool %s not found", fullName)
927+
return nil
928+
}
923929
derr := gcpNodePoolWaitUntilAvailableForDeleted(ctx, c, tenantID, fullName, d.Timeout("delete"))
924930
if derr != nil {
925931
return diag.Errorf("%s", derr)

duplocloud/resource_duplo_infrastructure.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,11 +339,12 @@ func resourceInfrastructureRead(ctx context.Context, d *schema.ResourceData, m i
339339
// Get the object from Duplo, detecting a missing object
340340
c := m.(*duplosdk.Client)
341341
missing, err := infrastructureRead(c, d, name)
342-
if err != nil {
342+
if err != nil && err.Status() != 404 {
343343
return diag.Errorf("Unable to retrieve infrastructure '%s': %s", name, err)
344344
}
345-
if missing {
345+
if (err != nil && err.Status() == 404) || missing {
346346
d.SetId("") // object missing
347+
log.Printf("Infrastructure not found")
347348
return nil
348349
}
349350

@@ -580,7 +581,7 @@ func duploInfrastructureWaitUntilReady(ctx context.Context, c *duplosdk.Client,
580581
return err
581582
}
582583

583-
func infrastructureRead(c *duplosdk.Client, d *schema.ResourceData, name string) (bool, error) {
584+
func infrastructureRead(c *duplosdk.Client, d *schema.ResourceData, name string) (bool, duplosdk.ClientError) {
584585
var infra *duplosdk.DuploInfrastructureConfig
585586
config, err := c.InfrastructureGetConfig(name)
586587
if err != nil {
@@ -735,7 +736,7 @@ func infrastructureRead(c *duplosdk.Client, d *schema.ResourceData, name string)
735736
if config.Cloud == 3 {
736737
natIPs, err := c.GetGCPInfraNATIPs(name)
737738
if err != nil {
738-
return false, fmt.Errorf("error retrieving GCP NAT IPs for infrastructure '%s': %s", name, err)
739+
return false, err
739740
}
740741
if natIPs != nil {
741742
natIPsList := make([]interface{}, len(natIPs))

duplocloud/resource_duplo_k8_ingress.go

Lines changed: 54 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,23 @@ func k8sIngressSchema() map[string]*schema.Schema {
5656
"certificate_arn": {
5757
Description: "The ARN of an ACM certificate to associate with this load balancer. Only applicable for HTTPS.",
5858
Type: schema.TypeString,
59-
Computed: true,
60-
Optional: true,
59+
//Computed: true,
60+
Optional: true,
61+
Deprecated: "This field has been deprecated use certificate_arns",
62+
ConflictsWith: []string{"lbconfig.0.certificate_arns"},
63+
},
64+
"certificate_arns": {
65+
Description: "The list of ARN of an ACM certificate to associate with this load balancer. Only applicable for HTTPS.",
66+
Type: schema.TypeList,
67+
//Computed: true,
68+
Optional: true,
69+
ConflictsWith: []string{"lbconfig.0.certificate_arn"},
70+
71+
Elem: &schema.Schema{
72+
Type: schema.TypeString,
73+
},
6174
},
75+
6276
"http_port": {
6377
Description: "HTTP Listener Port.",
6478
Type: schema.TypeInt,
@@ -318,7 +332,18 @@ func flattenK8sIngress(tenantId string, d *schema.ResourceData, duplo *duplosdk.
318332

319333
// Set LBConfig
320334
if duplo.LbConfig != nil {
321-
d.Set("lbconfig", []interface{}{flattenK8sIngressLBConfig(duplo.LbConfig)})
335+
confHandler := map[string]bool{
336+
"arn": false,
337+
"arns": false,
338+
}
339+
arn := d.Get("lbconfig.0.certificate_arn").(string)
340+
arns := d.Get("lbconfig.0.certificate_arns").([]interface{})
341+
if arn != "" {
342+
confHandler["arn"] = true
343+
} else if len(arns) > 0 {
344+
confHandler["arns"] = true
345+
}
346+
d.Set("lbconfig", []interface{}{flattenK8sIngressLBConfig(duplo.LbConfig, confHandler)})
322347
}
323348

324349
// Set Rules
@@ -334,12 +359,27 @@ func flattenK8sIngress(tenantId string, d *schema.ResourceData, duplo *duplosdk.
334359
}
335360
}
336361

337-
func flattenK8sIngressLBConfig(duplo *duplosdk.DuploK8sLbConfig) map[string]interface{} {
362+
func flattenK8sIngressLBConfig(duplo *duplosdk.DuploK8sLbConfig, confHandler map[string]bool) map[string]interface{} {
338363
m := map[string]interface{}{
339-
"is_internal": !duplo.IsPublic,
340-
"dns_prefix": duplo.DnsPrefix,
341-
"certificate_arn": duplo.CertArn,
364+
"is_internal": !duplo.IsPublic,
365+
"dns_prefix": duplo.DnsPrefix,
366+
}
367+
if confHandler["arn"] {
368+
m["certificate_arn"] = duplo.CertArn
369+
}
370+
371+
if confHandler["arns"] {
372+
certArns := strings.Split(duplo.CertArn, ",")
373+
if len(certArns) > 0 {
374+
arns := make([]interface{}, 0, len(certArns))
375+
for _, certArn := range certArns {
376+
arns = append(arns, certArn)
377+
}
378+
379+
m["certificate_arns"] = arns
380+
}
342381
}
382+
343383
if duplo.Listeners != nil && len(duplo.Listeners.Http) > 0 {
344384
m["http_port"] = duplo.Listeners.Http[0]
345385
}
@@ -436,6 +476,13 @@ func expandK8sIngressLBConfig(m map[string]interface{}) *duplosdk.DuploK8sLbConf
436476
if v, ok := m["port_override"]; ok && v.(string) != "" {
437477
dcb.FrontendPortOverride = v.(string)
438478
}
479+
if v, ok := m["certificate_arns"]; ok && len(v.([]interface{})) > 0 {
480+
xs := []string{}
481+
for _, s := range v.([]interface{}) {
482+
xs = append(xs, s.(string))
483+
}
484+
dcb.CertArn = strings.Join(xs, ",")
485+
}
439486
return dcb
440487
}
441488

duplocloud/resource_duplo_k8_secret.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,10 @@ func resourceK8SecretRead(ctx context.Context, d *schema.ResourceData, m interfa
104104

105105
// Get the object from Duplo, detecting a missing object
106106
c := m.(*duplosdk.Client)
107-
rp, err := c.K8SecretGet(tenantId, name)
108-
if err != nil {
109-
return diag.FromErr(err)
110-
}
111-
if rp == nil || rp.SecretName == "" {
107+
rp, cerr := c.K8SecretGet(tenantId, name)
108+
if cerr != nil {
112109
d.SetId("")
110+
log.Printf("%s", cerr.Error())
113111
return nil
114112
}
115113

duplocloud/resource_duplo_plan_settings.go

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ package duplocloud
22

33
import (
44
"context"
5-
"github.com/duplocloud/terraform-provider-duplocloud/duplosdk"
65
"log"
76
"time"
87

8+
"github.com/duplocloud/terraform-provider-duplocloud/duplosdk"
9+
910
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1011
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
1112
)
@@ -103,23 +104,39 @@ func resourcePlanSettingsRead(ctx context.Context, d *schema.ResourceData, m int
103104

104105
// Get "special" plan settings.
105106
settings, err := c.PlanGetSettings(planID)
106-
if err != nil {
107+
if err != nil && err.Status() != 404 {
107108
return diag.Errorf("failed to retrieve plan settings for '%s': %s", planID, err)
108109
}
109-
110+
if (err != nil && err.Status() == 404) || settings == nil {
111+
d.SetId("")
112+
log.Printf("plan settings not found for plan %s", planID)
113+
return nil
114+
}
110115
// Get plan DNS config. If the config is "global", that means there is no plan DNS config.
111116
dns, err := c.PlanGetDnsConfig(planID)
112-
if err != nil {
117+
if err != nil && err.Status() != 404 {
113118
return diag.Errorf("failed to retrieve plan DNS config for '%s': %s", planID, err)
114119
}
120+
121+
if (err != nil && err.Status() == 404) || settings == nil {
122+
d.SetId("")
123+
log.Printf("plan settings DNS config not found for plan %s", planID)
124+
return nil
125+
}
126+
115127
if dns != nil && dns.IsGlobalDNS {
116128
dns = nil
117129
}
118130

119131
// Get plan metadata.
120132
allMetadata, err := c.PlanMetadataGetList(planID)
121-
if err != nil {
122-
return diag.Errorf("failed to retrieve plan metadata for '%s': %s", planID, err)
133+
if err != nil && err.Status() != 404 {
134+
return diag.Errorf("failed to retrieve plan settings for '%s': %s", planID, err)
135+
}
136+
if (err != nil && err.Status() == 404) || settings == nil {
137+
d.SetId("")
138+
log.Printf("plan settings not found for plan %s", planID)
139+
return nil
123140
}
124141

125142
// Set the simple fields first.
@@ -198,33 +215,49 @@ func resourcePlanSettingsDelete(ctx context.Context, d *schema.ResourceData, m i
198215
}
199216

200217
// Skip if plan does not exist.
201-
if settings == nil {
218+
if (err != nil && err.Status() == 404) || settings == nil {
219+
log.Printf("plan settings not found for plan %s", planID)
202220
return nil
203221
}
204222

205223
// Undo the plan settings we can control here.
206224
if _, ok := d.GetOk("unrestricted_ext_lb"); ok {
207225
settings.UnrestrictedExtLB = false
208226
_, err := c.PlanUpdateSettings(planID, settings)
209-
if err != nil {
210-
return diag.Errorf("failed to remove plan settings for '%s': %s", planID, err)
227+
if err != nil && err.Status() != 404 {
228+
return diag.Errorf("failed to update plan settings for '%s': %s", planID, err)
229+
}
230+
if (err != nil && err.Status() == 404) || settings == nil {
231+
log.Printf("plan settings not found for plan %s", planID)
232+
return nil
211233
}
234+
212235
}
213236

214237
// Undo the plan DNS.
215238
if _, ok := d.GetOk("dns_setting"); ok {
216239
err := c.PlanDeleteDnsConfig(planID)
217-
if err != nil {
240+
if err != nil && err.Status() != 404 {
218241
return diag.Errorf("failed to remove plan DNS config for '%s': %s", planID, err)
219242
}
243+
if (err != nil && err.Status() == 404) || settings == nil {
244+
log.Printf("plan settings dns config not found for plan %s", planID)
245+
return nil
246+
}
247+
220248
}
221249

222250
// Undo the plan metadata
223251
if _, ok := d.GetOk("metadata"); ok {
224252
allMetadata, err := c.PlanMetadataGetList(planID)
225-
if err != nil {
253+
254+
if err != nil && err.Status() != 404 {
226255
return diag.Errorf("failed to retrieve plan metadata for '%s': %s", planID, err)
227256
}
257+
if (err != nil && err.Status() == 404) || settings == nil {
258+
log.Printf("plan settings metadata not found for plan %s", planID)
259+
return nil
260+
}
228261

229262
// Get the previous and desired plan configs
230263
previous, _ := getPlanMetadataChange(allMetadata, d)
@@ -235,6 +268,13 @@ func resourcePlanSettingsDelete(ctx context.Context, d *schema.ResourceData, m i
235268
if err != nil {
236269
return diag.Errorf("failed to remove plan metadata for '%s': %s", planID, err)
237270
}
271+
if err != nil && err.Status() != 404 {
272+
return diag.Errorf("failed to remove plan metadata for '%s': %s", planID, err)
273+
}
274+
if (err != nil && err.Status() == 404) || settings == nil {
275+
log.Printf("plan settings metadata not found for plan %s", planID)
276+
return nil
277+
}
238278
}
239279

240280
log.Printf("[TRACE] resourcePlanSettingsDelete(%s): end", planID)

duplocloud/resource_duplo_tenant.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ func resourceTenantRead(ctx context.Context, d *schema.ResourceData, m interface
132132
duplo, err := c.TenantGetV2(tenantID)
133133
if err != nil {
134134
if err.Status() == 404 {
135+
log.Printf("Tenant %s not found", tenantID)
135136
d.SetId("")
136137
return nil
137138
}
@@ -255,6 +256,7 @@ func resourceTenantDelete(ctx context.Context, d *schema.ResourceData, m interfa
255256
duplo, err := c.TenantGetV2(tenantID)
256257
if err != nil {
257258
if err.Status() == 404 {
259+
log.Printf("Tenant %s not found", tenantID)
258260
return nil
259261
}
260262
return diag.Errorf("Unable to retrieve tenant '%s': %s", tenantID, err)
@@ -265,6 +267,7 @@ func resourceTenantDelete(ctx context.Context, d *schema.ResourceData, m interfa
265267
err = c.TenantDelete(tenantID)
266268
if err != nil {
267269
if err.Status() == 404 {
270+
log.Printf("Tenant %s not found", tenantID)
268271
return nil
269272
}
270273
return diag.Errorf("Error deleting tenant '%s': %s", tenantID, err)

0 commit comments

Comments
 (0)