Skip to content

Commit

Permalink
Fixed errors
Browse files Browse the repository at this point in the history
  • Loading branch information
christinexlee committed Oct 1, 2024
1 parent 635012a commit 6e76b18
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
9 changes: 5 additions & 4 deletions datadog/fwprovider/resource_datadog_software_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ type EntityResponse struct {
}

type Included struct {
ID string
ID string `json:"id"`
Type string `json:"type"`
Attributes *IncludedAttributes `json:"attributes"`
}

type IncludedAttributes struct {
Schema *Entity `json:"schema,omitempty"`
RawSchema string `json:"raw_schema,omitempty"`
RawSchema string
}

func entityFromYAML(inYAML string) (Entity, error) {
Expand Down Expand Up @@ -276,15 +277,15 @@ func (r *catalogEntityResource) Read(ctx context.Context, request resource.ReadR
}

if len(entityResp.Included) != 1 || entityResp.Included[0].Attributes == nil || entityResp.Included[0].Attributes.RawSchema == "" {
err := fmt.Errorf("no entity is found in the response, path=%v response=%v", path, httpRespByte)
err := fmt.Errorf("no entity is found in the response, path=%v response=%v", path, string(httpRespByte))
response.Diagnostics.Append(utils.FrameworkErrorDiag(err, "error retrieving entity"))
return
}

var e Entity
rawSchema := entityResp.Included[0].Attributes.RawSchema
encodedBytes := decodeBase64String(rawSchema, response)
err = json.Unmarshal(encodedBytes, &e)
err = yaml.Unmarshal(encodedBytes, &e)
if err != nil {
response.Diagnostics.Append(utils.FrameworkErrorDiag(err, "error unmarshalling entity"))
return
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024-09-30T15:40:43.724114-04:00
2024-10-01T09:42:13.446934-04:00
Loading

0 comments on commit 6e76b18

Please sign in to comment.