Skip to content

Commit e416c5f

Browse files
committed
instance failed cassette + linter + cassette validation ok
1 parent f92a378 commit e416c5f

File tree

10 files changed

+4123
-4844
lines changed

10 files changed

+4123
-4844
lines changed

internal/services/baremetal/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,7 @@ func ResourceServerRead(ctx context.Context, d *schema.ResourceData, m interface
548548
}
549549

550550
privateIPs, err := ipam.GetResourcePrivateIPs(ctx, m, pnRegion, opts)
551+
551552
switch {
552553
case err == nil:
553554
allPrivateIPs = append(allPrivateIPs, privateIPs...)

internal/services/instance/private_nic.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ func ResourceInstancePrivateNICRead(ctx context.Context, d *schema.ResourceData,
189189

190190
// Get private NIC's private IPs if possible
191191
diags := diag.Diagnostics{}
192+
192193
region, err := zone.Region()
193194
if err != nil {
194195
return append(diags, diag.Diagnostic{
@@ -216,6 +217,7 @@ func ResourceInstancePrivateNICRead(ctx context.Context, d *schema.ResourceData,
216217
}
217218

218219
privateIPs, err := ipam.GetResourcePrivateIPs(ctx, m, region, opts)
220+
219221
switch {
220222
case err == nil:
221223
_ = d.Set("private_ips", privateIPs)

internal/services/instance/server.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,7 @@ func ResourceInstanceServerRead(ctx context.Context, d *schema.ResourceData, m i
785785
// Display warning if server will soon reach End of Service
786786
////
787787
diags := diag.Diagnostics{}
788+
788789
if server.EndOfService {
789790
compatibleTypes, err := api.GetServerCompatibleTypes(&instanceSDK.GetServerCompatibleTypesRequest{
790791
Zone: zone,
@@ -855,6 +856,7 @@ You can check the full list of compatible server types:
855856
}
856857

857858
privateIPs, err := ipam.GetResourcePrivateIPs(ctx, m, region, opts)
859+
858860
switch {
859861
case err == nil:
860862
allPrivateIPs = append(allPrivateIPs, privateIPs...)

internal/services/instance/testdata/private-nic-basic.cassette.yaml

Lines changed: 472 additions & 572 deletions
Large diffs are not rendered by default.

internal/services/k8s/pool.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,30 +449,36 @@ func ResourceK8SPoolRead(ctx context.Context, d *schema.ResourceData, m interfac
449449
continue
450450
}
451451

452+
authorized := true
452453
opts := &ipam.GetResourcePrivateIPsOptions{
453454
ResourceName: &nodeName,
454455
ProjectID: &projectID,
455456
}
456457

457458
privateIPs, err := ipam.GetResourcePrivateIPs(ctx, m, region, opts)
459+
458460
switch {
459461
case err == nil:
460462
nodes[i]["private_ips"] = privateIPs
461463
case httperrors.Is403(err):
464+
authorized = false
465+
462466
diags = append(diags, diag.Diagnostic{
463467
Severity: diag.Warning,
464468
Summary: "Unauthorized to read nodes' private IPs, please check your IAM permissions",
465469
Detail: err.Error(),
466470
})
467-
468-
break
469471
default:
470472
diags = append(diags, diag.Diagnostic{
471473
Severity: diag.Warning,
472474
Summary: fmt.Sprintf("Unable to get private IPs for node %q", nodeName),
473475
Detail: err.Error(),
474476
})
475477
}
478+
479+
if !authorized {
480+
break
481+
}
476482
}
477483
}
478484

internal/services/k8s/testdata/pool-public-ip-disabled.cassette.yaml

Lines changed: 2701 additions & 3095 deletions
Large diffs are not rendered by default.

internal/services/rdb/instance.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,19 +685,19 @@ func ResourceRdbInstanceRead(ctx context.Context, d *schema.ResourceData, m inte
685685
}
686686

687687
endpointPrivateIPs, err := ipam.GetResourcePrivateIPs(ctx, m, region, opts)
688+
688689
switch {
689690
case err == nil:
690691
privateIPs = append(privateIPs, endpointPrivateIPs...)
691692
case httperrors.Is403(err):
692693
authorized = false
694+
693695
diags = append(diags, diag.Diagnostic{
694696
Severity: diag.Warning,
695697
Summary: "Unauthorized to read RDB Instance's private IP, please check your IAM permissions",
696698
Detail: err.Error(),
697699
AttributePath: cty.GetAttrPath("private_ip"),
698700
})
699-
700-
break
701701
default:
702702
diags = append(diags, diag.Diagnostic{
703703
Severity: diag.Warning,
@@ -706,6 +706,10 @@ func ResourceRdbInstanceRead(ctx context.Context, d *schema.ResourceData, m inte
706706
AttributePath: cty.GetAttrPath("private_ip"),
707707
})
708708
}
709+
710+
if !authorized {
711+
break
712+
}
709713
}
710714
}
711715

internal/services/redis/cluster.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ func ResourceClusterRead(ctx context.Context, d *schema.ResourceData, m interfac
386386
} else {
387387
resourceType := ipamAPI.ResourceTypeRedisCluster
388388
privateNetworkIDs := []string(nil)
389+
389390
for _, endpoint := range cluster.Endpoints {
390391
if endpoint.PrivateNetwork != nil {
391392
privateNetworkIDs = append(privateNetworkIDs, endpoint.PrivateNetwork.ID)
@@ -401,19 +402,19 @@ func ResourceClusterRead(ctx context.Context, d *schema.ResourceData, m interfac
401402
}
402403

403404
privateIPs, err := ipam.GetResourcePrivateIPs(ctx, m, region, opts)
405+
404406
switch {
405407
case err == nil:
406408
allPrivateIPs = append(allPrivateIPs, privateIPs...)
407409
case httperrors.Is403(err):
408410
authorized = false
411+
409412
diags = append(diags, diag.Diagnostic{
410413
Severity: diag.Warning,
411414
Summary: "Unauthorized to read cluster's private IPs, please check your IAM permissions",
412415
Detail: err.Error(),
413416
AttributePath: cty.GetAttrPath("private_ips"),
414417
})
415-
416-
break
417418
default:
418419
diags = append(diags, diag.Diagnostic{
419420
Severity: diag.Warning,
@@ -422,6 +423,10 @@ func ResourceClusterRead(ctx context.Context, d *schema.ResourceData, m interfac
422423
AttributePath: cty.GetAttrPath("private_ips"),
423424
})
424425
}
426+
427+
if !authorized {
428+
break
429+
}
425430
}
426431
}
427432
}

0 commit comments

Comments
 (0)