Skip to content

Commit

Permalink
patch - bug fixing (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
OrNovo authored Feb 4, 2024
1 parent 78f2d93 commit 2396732
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -440,3 +440,8 @@ New Features:
* Adding support for `folder`, `annotations` fields.
* Adding support for `data_prime` for `bar_chart`, `data_table` and `pie_chart` widgets.
* adding validation for `env` field.

## Release 1.11.5
Bug fixing:
#### resource/coralogix_slo
* fixing log messages and flattening update-response into schema.
15 changes: 8 additions & 7 deletions coralogix/resource_coralogix_slo.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func (r *SLOResource) Create(ctx context.Context, req resource.CreateRequest, re
log.Printf("[ERROR] Received error: %s", err.Error())
resp.Diagnostics.AddError(
"Error creating SLO",
formatRpcErrors(err, createSloUrl, protojson.Format(createResp)),
formatRpcErrors(err, createSloUrl, protojson.Format(createSloReq)),
)
return
}
Expand Down Expand Up @@ -439,7 +439,8 @@ func (r *SLOResource) Read(ctx context.Context, req resource.ReadRequest, resp *

//Get refreshed SLO value from Coralogix
id := state.ID.ValueString()
readSloResp, err := r.client.GetSLO(ctx, &slos.GetServiceSloRequest{Id: wrapperspb.String(id)})
readSloReq := &slos.GetServiceSloRequest{Id: wrapperspb.String(id)}
readSloResp, err := r.client.GetSLO(ctx, readSloReq)
if err != nil {
log.Printf("[ERROR] Received error: %#v", err)
if status.Code(err) == codes.NotFound {
Expand All @@ -450,7 +451,7 @@ func (r *SLOResource) Read(ctx context.Context, req resource.ReadRequest, resp *
} else {
resp.Diagnostics.AddError(
"Error reading SLO",
formatRpcErrors(err, getSloUrl, protojson.Format(readSloResp)),
formatRpcErrors(err, getSloUrl, protojson.Format(readSloReq)),
)
}
return
Expand Down Expand Up @@ -510,22 +511,22 @@ func (r *SLOResource) Update(ctx context.Context, req resource.UpdateRequest, re
} else {
resp.Diagnostics.AddError(
"Error reading SLO",
formatRpcErrors(err, getSloUrl, protojson.Format(getSloResp)),
formatRpcErrors(err, getSloUrl, protojson.Format(getSloReq)),
)
}
return
}

slo = getSloResp.GetSlo()
log.Printf("[INFO] Received SLO: %s", protojson.Format(slo))

plan, diags = flattenSLO(ctx, slo)
state, diags := flattenSLO(ctx, slo)
if diags.HasError() {
resp.Diagnostics = diags
return
}

// Set state to fully populated data
diags = resp.State.Set(ctx, plan)
diags = resp.State.Set(ctx, state)
resp.Diagnostics.Append(diags...)
}

Expand Down

0 comments on commit 2396732

Please sign in to comment.