Skip to content

Commit 72eb6a6

Browse files
committed
fixed nil pointer and not-required arguments
1 parent 21594e2 commit 72eb6a6

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

stackit/internal/services/sfs/share/datasource.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,14 @@ func (r *shareDataSource) Schema(_ context.Context, _ datasource.SchemaRequest,
158158
},
159159
"export_policy": schema.StringAttribute{
160160
Description: `Name of the Share Export Policy to use in the Share.
161-
Note that if this is not set, the Share can only be mounted in read only by
162-
clients with IPs matching the IP ACL of the Resource Pool hosting this Share.
161+
Note that if this is not set, the Share can only be mounted in read only by
162+
clients with IPs matching the IP ACL of the Resource Pool hosting this Share.
163163
You can also assign a Share Export Policy after creating the Share`,
164164
Computed: true,
165165
},
166166
"space_hard_limit_gigabytes": schema.Int64Attribute{
167167
Computed: true,
168-
Description: `Space hard limit for the Share.
168+
Description: `Space hard limit for the Share.
169169
If zero, the Share will have access to the full space of the Resource Pool it lives in.
170170
(unit: gigabytes)`,
171171
},
@@ -207,8 +207,10 @@ func mapDataSourceFields(_ context.Context, region string, share *sfs.GetShareRe
207207
utils.Coalesce(model.ShareId, types.StringPointerValue(share.Id)).ValueString(),
208208
)
209209
model.Name = types.StringPointerValue(share.Name)
210-
if policy := share.ExportPolicy.Get(); policy != nil {
211-
model.ExportPolicyName = types.StringPointerValue(policy.Name)
210+
if share.ExportPolicy != nil {
211+
if policy := share.ExportPolicy.Get(); policy != nil {
212+
model.ExportPolicyName = types.StringPointerValue(policy.Name)
213+
}
212214
}
213215

214216
model.SpaceHardLimitGigabytes = types.Int64PointerValue(share.SpaceHardLimitGigabytes)

stackit/internal/services/sfs/share/resource.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,14 @@ func (r *shareResource) Schema(_ context.Context, _ resource.SchemaRequest, resp
179179
},
180180
"export_policy": schema.StringAttribute{
181181
Description: `Name of the Share Export Policy to use in the Share.
182-
Note that if this is set to an empty string, the Share can only be mounted in read only by
183-
clients with IPs matching the IP ACL of the Resource Pool hosting this Share.
182+
Note that if this is set to an empty string, the Share can only be mounted in read only by
183+
clients with IPs matching the IP ACL of the Resource Pool hosting this Share.
184184
You can also assign a Share Export Policy after creating the Share`,
185-
Required: true,
185+
Optional: true,
186186
},
187187
"space_hard_limit_gigabytes": schema.Int64Attribute{
188188
Required: true,
189-
Description: `Space hard limit for the Share.
189+
Description: `Space hard limit for the Share.
190190
If zero, the Share will have access to the full space of the Resource Pool it lives in.
191191
(unit: gigabytes)`,
192192
},
@@ -496,8 +496,10 @@ func mapFields(_ context.Context, share *sfs.GetShareResponseShare, region strin
496496
)
497497
model.Name = types.StringPointerValue(share.Name)
498498

499-
if policy := share.ExportPolicy.Get(); policy != nil {
500-
model.ExportPolicyName = types.StringPointerValue(policy.Name)
499+
if share.ExportPolicy != nil {
500+
if policy := share.ExportPolicy.Get(); policy != nil {
501+
model.ExportPolicyName = types.StringPointerValue(policy.Name)
502+
}
501503
}
502504

503505
model.SpaceHardLimitGigabytes = types.Int64PointerValue(share.SpaceHardLimitGigabytes)

0 commit comments

Comments
 (0)