Skip to content

Commit

Permalink
KIM integration - safer casting during managedFields removal (#1131)
Browse files Browse the repository at this point in the history
safer casting
  • Loading branch information
jaroslaw-pieszka authored Sep 12, 2024
1 parent b493c75 commit 0bd6ea0
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions internal/runtime/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,15 @@ func (h *Handler) getRuntimes(w http.ResponseWriter, req *http.Request) {
dto.RuntimeConfig = nil
default:
// remove managedFields from the object to reduce the size of the response
delete(runtimeResourceObject.Object["metadata"].(map[string]interface{}), "managedFields")
dto.RuntimeConfig = &runtimeResourceObject.Object
_, ok := runtimeResourceObject.Object["metadata"].(map[string]interface{})
if !ok {
h.logger.Warn(fmt.Sprintf("unable to get Runtime resource metadata %s/%s: %s", dto.InstanceID, dto.RuntimeID, err.Error()))
dto.RuntimeConfig = nil

} else {
delete(runtimeResourceObject.Object["metadata"].(map[string]interface{}), "managedFields")
dto.RuntimeConfig = &runtimeResourceObject.Object
}
}
}

Expand Down

0 comments on commit 0bd6ea0

Please sign in to comment.