diff --git a/internal/providers/pluginfw/resources/sharing/resource_share.go b/internal/providers/pluginfw/resources/sharing/resource_share.go index 69796abfd..4884c9247 100644 --- a/internal/providers/pluginfw/resources/sharing/resource_share.go +++ b/internal/providers/pluginfw/resources/sharing/resource_share.go @@ -221,6 +221,9 @@ func (r *ShareResource) Create(ctx context.Context, req resource.CreateRequest, } resp.Diagnostics.Append(resp.State.Set(ctx, newState)...) + if resp.Diagnostics.HasError() { + return + } } func (r *ShareResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { @@ -251,9 +254,6 @@ func (r *ShareResource) Read(ctx context.Context, req resource.ReadRequest, resp } shareInfo, err := w.Shares.Get(ctx, getShareRequest) - matchOrder(shareInfo.Objects, stateGoSDK.Objects, func(obj sharing.SharedDataObject) string { return obj.Name }) - suppressCDFEnabledDiff(shareInfo) - if err != nil { if apierr.IsMissing(err) { resp.State.RemoveResource(ctx) @@ -263,6 +263,9 @@ func (r *ShareResource) Read(ctx context.Context, req resource.ReadRequest, resp return } + matchOrder(shareInfo.Objects, stateGoSDK.Objects, func(obj sharing.SharedDataObject) string { return obj.Name }) + suppressCDFEnabledDiff(shareInfo) + var newState ShareInfoExtended resp.Diagnostics.Append(converters.GoSdkToTfSdkStruct(ctx, shareInfo, &newState)...) if resp.Diagnostics.HasError() { @@ -308,6 +311,7 @@ func (r *ShareResource) Update(ctx context.Context, req resource.UpdateRequest, currentShareInfo, err := client.Shares.Get(ctx, getShareRequest) if err != nil { + resp.Diagnostics.AddError("failed to get current share info", err.Error()) return } @@ -328,7 +332,7 @@ func (r *ShareResource) Update(ctx context.Context, req resource.UpdateRequest, return } } else { - resp.Diagnostics.AddError("failed to share owner", err.Error()) + resp.Diagnostics.AddError("failed to update share owner", err.Error()) return } } @@ -359,6 +363,7 @@ func (r *ShareResource) Update(ctx context.Context, req resource.UpdateRequest, } resp.Diagnostics.AddError("failed to update share", err.Error()) + return } } @@ -385,5 +390,6 @@ func (r *ShareResource) Delete(ctx context.Context, req resource.DeleteRequest, err := w.Shares.DeleteByName(ctx, deleteShareRequest.Name.ValueString()) if err != nil && !apierr.IsMissing(err) { resp.Diagnostics.AddError("failed to delete share", err.Error()) + return } }