Skip to content

Commit

Permalink
add workaround for yaml bug unmarshalling int to interface
Browse files Browse the repository at this point in the history
Signed-off-by: Zach Hammer <[email protected]>
  • Loading branch information
zhammer authored and avinashkatamreddy-sg committed Apr 26, 2024
1 parent 8850a97 commit 42c71b1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions controller/cache/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ func populateServiceInfo(un *unstructured.Unstructured, res *ResourceInfo) {
}

func populateReplicaSetInfo(un *unstructured.Unstructured, res *ResourceInfo) {
replicas, ok, err := unstructured.NestedInt64(un.Object, "spec", "replicas")
// due to https://github.com/kubernetes-sigs/yaml/issues/45, replicas is parsed as a float
replicas, ok, err := unstructured.NestedFloat64(un.Object, "spec", "replicas")
if err == nil && ok {
res.Info = append(res.Info, v1alpha1.InfoItem{Name: "Replicas", Value: fmt.Sprintf("Replicas:%d", replicas)})
res.Info = append(res.Info, v1alpha1.InfoItem{Name: "Replicas", Value: fmt.Sprintf("Replicas:%d", int(replicas))})
}
}

Expand Down

0 comments on commit 42c71b1

Please sign in to comment.