1.2.2
This commit is contained in:
@@ -67,6 +67,11 @@ func (r *resourceBService) Create(ctx context.Context, req resource.CreateReques
|
||||
ctx, cancel := context.WithTimeout(ctx, createTimeout)
|
||||
defer cancel()
|
||||
|
||||
if len(plan.Snapshots.Elements()) > 0 {
|
||||
resp.Diagnostics.AddError("BServiceResourceCreate: snapshot field must be empty when resource is creating", "")
|
||||
return
|
||||
}
|
||||
|
||||
// Make create request and get response
|
||||
id, diags := utilities.BServiceResourceCreate(ctx, &plan, r.client)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
@@ -74,15 +79,9 @@ func (r *resourceBService) Create(ctx context.Context, req resource.CreateReques
|
||||
return
|
||||
}
|
||||
plan.ID = types.StringValue(strconv.Itoa(int(*id)))
|
||||
tflog.Info(ctx, "BServiceResourceCreatee: BService created", map[string]any{"service_id": id})
|
||||
tflog.Info(ctx, "BServiceResourceCreate: BService created", map[string]any{"service_id": id})
|
||||
|
||||
tflog.Info(ctx, "BServiceResourceCreatee: resource creation is completed", map[string]any{"service_id": id})
|
||||
|
||||
currentSnapshots, diags := types.ListValue(plan.Snapshots.Type(ctx), plan.Snapshots.Elements())
|
||||
resp.Diagnostics.Append(diags...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
return
|
||||
}
|
||||
tflog.Info(ctx, "BServiceResourceCreate: resource creation is completed", map[string]any{"service_id": id})
|
||||
|
||||
// Map response body to schema and populate Computed attribute values
|
||||
resp.Diagnostics.Append(flattens.BServiceResource(ctx, &plan, r.client)...)
|
||||
@@ -90,15 +89,6 @@ func (r *resourceBService) Create(ctx context.Context, req resource.CreateReques
|
||||
return
|
||||
}
|
||||
|
||||
if !plan.Snapshots.Equal(currentSnapshots) && !currentSnapshots.IsNull() {
|
||||
resp.Diagnostics.Append(utilities.SnapshotsBService(ctx, currentSnapshots, plan.Snapshots, uint64(plan.ServiceId.ValueInt64()), r.client)...)
|
||||
|
||||
if resp.Diagnostics.HasError() {
|
||||
tflog.Warn(ctx, "Create resourceBService: Error snapshosts bservice")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Set state to fully populated data
|
||||
resp.Diagnostics.Append(resp.State.Set(ctx, plan)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
@@ -217,8 +207,7 @@ func (r *resourceBService) Update(ctx context.Context, req resource.UpdateReques
|
||||
|
||||
// SnapshotsBService bservice
|
||||
if !plan.Snapshots.Equal(state.Snapshots) && !plan.Snapshots.IsNull() {
|
||||
resp.Diagnostics.Append(utilities.SnapshotsBService(ctx, state.Snapshots, plan.Snapshots, uint64(plan.ServiceId.ValueInt64()), r.client)...)
|
||||
|
||||
resp.Diagnostics.Append(utilities.SnapshotsBService(ctx, state.Snapshots, plan.Snapshots, uint64(state.ServiceId.ValueInt64()), r.client)...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
tflog.Error(ctx, "Update resourceBService: Error snapshosts bservice")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user