-
Notifications
You must be signed in to change notification settings - Fork 136
feat(block): add support for identity for snapshot and volume #3656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,6 +7,7 @@ import ( | |||||||||
| "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||||||||
| block "github.com/scaleway/scaleway-sdk-go/api/block/v1alpha1" | ||||||||||
| "github.com/scaleway/terraform-provider-scaleway/v2/internal/datasource" | ||||||||||
| "github.com/scaleway/terraform-provider-scaleway/v2/internal/httperrors" | ||||||||||
| "github.com/scaleway/terraform-provider-scaleway/v2/internal/types" | ||||||||||
| "github.com/scaleway/terraform-provider-scaleway/v2/internal/verify" | ||||||||||
| ) | ||||||||||
|
|
@@ -72,14 +73,20 @@ func DataSourceBlockSnapshotRead(ctx context.Context, d *schema.ResourceData, m | |||||||||
| return diag.FromErr(err) | ||||||||||
| } | ||||||||||
|
|
||||||||||
| diags := ResourceBlockSnapshotRead(ctx, d, m) | ||||||||||
| if diags != nil { | ||||||||||
| return append(diags, diag.Errorf("failed to read snapshot state")...) | ||||||||||
| } | ||||||||||
| // Wait for the snapshot and use it to set the state | ||||||||||
| snapshot, err := waitForBlockSnapshot(ctx, api, zone, snapshotID.(string), d.Timeout(schema.TimeoutRead)) | ||||||||||
| if err != nil { | ||||||||||
| if httperrors.Is404(err) { | ||||||||||
| d.SetId("") | ||||||||||
|
|
||||||||||
| return nil | ||||||||||
|
Comment on lines
+80
to
+82
|
||||||||||
| d.SetId("") | |
| return nil | |
| return diag.Errorf("snapshot %s not found", zoneID) |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -7,6 +7,7 @@ import ( | |||||||||
| "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||||||||||
| block "github.com/scaleway/scaleway-sdk-go/api/block/v1alpha1" | ||||||||||
| "github.com/scaleway/terraform-provider-scaleway/v2/internal/datasource" | ||||||||||
| "github.com/scaleway/terraform-provider-scaleway/v2/internal/httperrors" | ||||||||||
| "github.com/scaleway/terraform-provider-scaleway/v2/internal/types" | ||||||||||
| "github.com/scaleway/terraform-provider-scaleway/v2/internal/verify" | ||||||||||
| ) | ||||||||||
|
|
@@ -71,14 +72,20 @@ func DataSourceBlockVolumeRead(ctx context.Context, d *schema.ResourceData, m an | |||||||||
| return diag.FromErr(err) | ||||||||||
| } | ||||||||||
|
|
||||||||||
| diags := ResourceBlockVolumeRead(ctx, d, m) | ||||||||||
| if diags != nil { | ||||||||||
| return append(diags, diag.Errorf("failed to read volume state")...) | ||||||||||
| } | ||||||||||
| // Wait for the volume and use it to set the state | ||||||||||
| volume, err := waitForBlockVolume(ctx, api, zone, volumeID.(string), d.Timeout(schema.TimeoutRead)) | ||||||||||
| if err != nil { | ||||||||||
|
Comment on lines
+75
to
+77
|
||||||||||
| if httperrors.Is404(err) { | ||||||||||
| d.SetId("") | ||||||||||
|
|
||||||||||
| return nil | ||||||||||
|
Comment on lines
+79
to
+81
|
||||||||||
| d.SetId("") | |
| return nil | |
| return diag.Errorf("block volume %s not found", zoneID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
waitForBlockSnapshotis called withsnapshotID.(string), butsnapshot_idis stored in state as a zoned ID (e.g.fr-par-1/<uuid>). On subsequent reads (or when the user provides a localized ID), this will pass the localized form to the Block API, which expects the raw UUID, and it also ignores the zone embedded in the ID. Parse the zoned ID (e.g. viazonal.ParseID/locality.ExpandID) and use the extractedid(and zone if present) when callingwaitForBlockSnapshot.