Skip to content

Commit 8ffc85f

Browse files
Fixes
1 parent d5ed6d2 commit 8ffc85f

File tree

8 files changed

+36
-37
lines changed

8 files changed

+36
-37
lines changed

docs/data-sources/consumer_image_share_group_image_shares.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ description: |-
66

77
# Data Source: linode\_consumer\_image\_share\_group\_image\_shares
88

9-
Provides information about a list of Images that match a set of filters that have been
10-
.shared in the Image Share Group that the provided Token has been accepted into
9+
Provides information about a list of Images that match a set of filters that have been
10+
.shared in the Image Share Group that the provided Token has been accepted into
1111
For more information, see the [Linode APIv4 docs](TODO).
1212

1313
## Example Usage
@@ -69,14 +69,14 @@ Each Image Share will be stored in the `images_shares` attribute and will export
6969
* `is_public` - True if the Image is public.
7070

7171
* `image_sharing` - Details about image sharing, including who the image is shared with and by.
72-
* `shared_with` - Details about who the image is shared with.
73-
* `sharegroup_count` - The number of sharegroups the private image is present in.
74-
* `sharegroup_list_url` - The GET api url to view the sharegroups in which the image is shared.
75-
* `shared_by` - Details about who the image is shared by.
76-
* `sharegroup_id` - The sharegroup_id from the im_ImageShare row.
77-
* `sharegroup_uuid` - The sharegroup_uuid from the im_ImageShare row.
78-
* `sharegroup_label` - The label from the associated im_ImageShareGroup row.
79-
* `source_image_id` - The image id of the base image (will only be shown to producers, will be null for consumers).
72+
* `shared_with` - Details about who the image is shared with.
73+
* `sharegroup_count` - The number of sharegroups the private image is present in.
74+
* `sharegroup_list_url` - The GET api url to view the sharegroups in which the image is shared.
75+
* `shared_by` - Details about who the image is shared by.
76+
* `sharegroup_id` - The sharegroup_id from the im_ImageShare row.
77+
* `sharegroup_uuid` - The sharegroup_uuid from the im_ImageShare row.
78+
* `sharegroup_label` - The label from the associated im_ImageShareGroup row.
79+
* `source_image_id` - The image id of the base image (will only be shown to producers, will be null for consumers).
8080

8181
* `size` - The minimum size this Image needs to deploy. Size is in MB. example: 2500
8282

docs/data-sources/producer_image_share_group.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ description: |-
99
`linode_producer_image_share_group` provides details about an Image Share Group.
1010
For more information, see the [Linode APIv4 docs](TODO).
1111

12-
1312
## Example Usage
1413

1514
The following example shows how the datasource might be used to obtain additional information about an Image Share Group.

docs/data-sources/producer_image_share_group_image_shares.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ Each Image Share will be stored in the `images_shares` attribute and will export
7070
* `is_public` - True if the Image is public.
7171

7272
* `image_sharing` - Details about image sharing, including who the image is shared with and by.
73-
* `shared_with` - Details about who the image is shared with.
74-
* `sharegroup_count` - The number of sharegroups the private image is present in.
75-
* `sharegroup_list_url` - The GET api url to view the sharegroups in which the image is shared.
76-
* `shared_by` - Details about who the image is shared by.
77-
* `sharegroup_id` - The sharegroup_id from the im_ImageShare row.
78-
* `sharegroup_uuid` - The sharegroup_uuid from the im_ImageShare row.
79-
* `sharegroup_label` - The label from the associated im_ImageShareGroup row.
80-
* `source_image_id` - The image id of the base image (will only be shown to producers, will be null for consumers).
73+
* `shared_with` - Details about who the image is shared with.
74+
* `sharegroup_count` - The number of sharegroups the private image is present in.
75+
* `sharegroup_list_url` - The GET api url to view the sharegroups in which the image is shared.
76+
* `shared_by` - Details about who the image is shared by.
77+
* `sharegroup_id` - The sharegroup_id from the im_ImageShare row.
78+
* `sharegroup_uuid` - The sharegroup_uuid from the im_ImageShare row.
79+
* `sharegroup_label` - The label from the associated im_ImageShareGroup row.
80+
* `source_image_id` - The image id of the base image (will only be shown to producers, will be null for consumers).
8181

8282
* `size` - The minimum size this Image needs to deploy. Size is in MB. example: 2500
8383

linode/framework_provider.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ func (p *FrameworkProvider) Resources(ctx context.Context) []func() resource.Res
264264
networkingipassignment.NewResource,
265265
obj.NewResource,
266266
databasemysqlv2.NewResource,
267+
producerimagesharegroup.NewResource,
268+
producerimagesharegroupmember.NewResource,
269+
consumerimagesharegrouptoken.NewResource,
267270
}
268271
}
269272

linode/producerimagesharegroup/framework_models.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package producerimagesharegroup
22

33
import (
44
"github.com/hashicorp/terraform-plugin-framework-timetypes/timetypes"
5-
"github.com/hashicorp/terraform-plugin-framework/attr"
65
"github.com/hashicorp/terraform-plugin-framework/diag"
76
"github.com/hashicorp/terraform-plugin-framework/types"
87
"github.com/linode/linodego"
@@ -52,12 +51,9 @@ func (data *ResourceModel) FlattenImageShareGroup(
5251
data.Expiry, timetypes.NewRFC3339TimePointerValue(imageShareGroup.Expiry), preserveKnown,
5352
)
5453

55-
// Images must persist in state across CRUD operations but is not returned by the API. It will be maintained
56-
// manually as a part of Create, Update, and Read, so we only need to set it here if it is null or unknown
57-
// so that it is properly typed.
58-
if data.Images.IsNull() || data.Images.IsUnknown() {
59-
data.Images = types.ListValueMust(imageShareGroupImage.Type(), []attr.Value{})
60-
}
54+
// Images will persist in state across CRUD operations even though it is not returned by the API. It is maintained
55+
// manually as a part of Create, Update, and Read. We do not need to set it here because it defaults to a
56+
// properly typed empty list when omitted from the config.
6157
}
6258

6359
type DataSourceModel struct {

linode/producerimagesharegroup/framework_resource.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -197,16 +197,6 @@ func (r *Resource) Update(
197197
return
198198
}
199199

200-
// Refresh remote state to ensure accuracy
201-
sg, err := client.GetImageShareGroup(ctx, imageShareGroupID)
202-
if err != nil {
203-
resp.Diagnostics.AddError(
204-
"Failed to read Image Share Group.",
205-
err.Error(),
206-
)
207-
return
208-
}
209-
210200
imagesResp, err := client.ImageShareGroupListImageShareEntries(ctx, imageShareGroupID, nil)
211201
if err != nil {
212202
resp.Diagnostics.AddError(
@@ -339,7 +329,7 @@ func (r *Resource) Update(
339329
}
340330

341331
// Refresh and persist final state
342-
sg, err = client.GetImageShareGroup(ctx, imageShareGroupID)
332+
sg, err := client.GetImageShareGroup(ctx, imageShareGroupID)
343333
if err != nil {
344334
resp.Diagnostics.AddError("Failed to re-fetch share group", err.Error())
345335
return

linode/producerimagesharegroup/framework_schema_resource.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ package producerimagesharegroup
22

33
import (
44
"github.com/hashicorp/terraform-plugin-framework-timetypes/timetypes"
5+
"github.com/hashicorp/terraform-plugin-framework/attr"
56
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
67
"github.com/hashicorp/terraform-plugin-framework/resource/schema/int64planmodifier"
8+
"github.com/hashicorp/terraform-plugin-framework/resource/schema/listdefault"
79
"github.com/hashicorp/terraform-plugin-framework/resource/schema/listplanmodifier"
810
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
911
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
12+
"github.com/hashicorp/terraform-plugin-framework/types"
1013
)
1114

1215
var imageShareGroupImage = schema.NestedAttributeObject{
@@ -85,6 +88,9 @@ var frameworkResourceSchema = schema.Schema{
8588
PlanModifiers: []planmodifier.List{
8689
listplanmodifier.UseStateForUnknown(),
8790
},
91+
// Default to an empty list to ensure proper typing in state when not specified in config. This makes
92+
// it so that the user specifying an empty list and not specifying the attribute at all is equivalent.
93+
Default: listdefault.StaticValue(types.ListValueMust(imageShareGroupImage.Type(), []attr.Value{})),
8894
},
8995
},
9096
}

linode/producerimagesharegroup/tmpl/updates.gotf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ resource "linode_producer_image_share_group" "foobar" {
3535
label = "{{ .ImageShareGroupLabel }}"
3636
description = "{{ .ImageShareGroupDescription }}"
3737

38+
depends_on = [
39+
linode_image.foobar,
40+
linode_image.barfoo,
41+
]
42+
3843
{{- if .Images }}
3944
images = [
4045
{{- range .Images }}

0 commit comments

Comments
 (0)