From 8b8552656bd9b785a847674c520c7c80107304f6 Mon Sep 17 00:00:00 2001 From: Derek Horton Date: Fri, 19 Jan 2024 11:58:14 -0600 Subject: [PATCH] Inventory is returning a fact as a float. We were expecting it to be a string. --- go.mod | 4 ++-- go.sum | 4 ++++ internal/api/connectors/inventory/inventory.go | 17 ++++++++++++++--- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 59d1fb55..2b8db35c 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,7 @@ require ( ) require ( - github.com/atombender/go-jsonschema v0.15.1-0.20240118015147-40f48ce0470e // indirect + github.com/atombender/go-jsonschema v0.15.1-0.20240119115630-8bc07a9849d1 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/fatih/color v1.16.0 // indirect @@ -84,7 +84,7 @@ require ( go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.5.0 // indirect golang.org/x/crypto v0.18.0 // indirect - golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 // indirect + golang.org/x/exp v0.0.0-20240119083558-1b970713d09a // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.20.0 // indirect golang.org/x/sys v0.16.0 // indirect diff --git a/go.sum b/go.sum index a02a0c74..c3c62ddd 100644 --- a/go.sum +++ b/go.sum @@ -117,6 +117,8 @@ github.com/atombender/go-jsonschema v0.14.2-0.20240112180320-6fcc83b8eebe h1:RsH github.com/atombender/go-jsonschema v0.14.2-0.20240112180320-6fcc83b8eebe/go.mod h1:JqTHPe4S0pVB4LH/CGKJzX+di8cnLwSYkDDXFoOewLw= github.com/atombender/go-jsonschema v0.15.1-0.20240118015147-40f48ce0470e h1:HYGyiXgVzqcD5o4Tk7VGmwou+/FqmlLwBT62Qt8uCDU= github.com/atombender/go-jsonschema v0.15.1-0.20240118015147-40f48ce0470e/go.mod h1:2HVikrSiZk0Y2+E6qeLQBQypLwpu0K68Y8a2C9Snc+w= +github.com/atombender/go-jsonschema v0.15.1-0.20240119115630-8bc07a9849d1 h1:rlcsPLlEWYiDxt1r1bHBfDQraV5IMvi4sgNOM9nyoUc= +github.com/atombender/go-jsonschema v0.15.1-0.20240119115630-8bc07a9849d1/go.mod h1:/+2LNadsDUmKibSR+qfKXzCiuMZEDpDYQpjK9wFvfvc= github.com/aws/aws-sdk-go v1.15.11/go.mod h1:mFuSZ37Z9YOHbQEwBWztmVzqXrEkub65tZoCYDt7FT0= github.com/aws/aws-sdk-go v1.17.7/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.34.2/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= @@ -1163,6 +1165,8 @@ golang.org/x/exp v0.0.0-20240110193028-0dcbfd608b1e h1:723BNChdd0c2Wk6WOE320qGBi golang.org/x/exp v0.0.0-20240110193028-0dcbfd608b1e/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3 h1:hNQpMuAJe5CtcUqCXaWga3FHu+kQvCqcsoVaQgSV60o= golang.org/x/exp v0.0.0-20240112132812-db7319d0e0e3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= +golang.org/x/exp v0.0.0-20240119083558-1b970713d09a h1:Q8/wZp0KX97QFTc2ywcOE0YRjZPVIx+MXInMzdvQqcA= +golang.org/x/exp v0.0.0-20240119083558-1b970713d09a/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= diff --git a/internal/api/connectors/inventory/inventory.go b/internal/api/connectors/inventory/inventory.go index 1200dee7..026b899a 100644 --- a/internal/api/connectors/inventory/inventory.go +++ b/internal/api/connectors/inventory/inventory.go @@ -37,17 +37,17 @@ func getSatelliteFacts(facts *[]FactSet) satelliteFacts { satelliteOrgID, orgIDExists := fact.Facts["organization_id"] if idExists { - strigifiedInstanceID := satelliteInstanceID.(string) + strigifiedInstanceID := convertInterfaceToString(satelliteInstanceID) satelliteFacts.SatelliteInstanceID = &strigifiedInstanceID } if versionExists { - stringifiedVersion := satelliteVersion.(string) + stringifiedVersion := convertInterfaceToString(satelliteVersion) satelliteFacts.SatelliteVersion = &stringifiedVersion } if orgIDExists { - stringifiedOrgID := satelliteOrgID.(string) + stringifiedOrgID := convertInterfaceToString(satelliteOrgID) satelliteFacts.SatelliteOrgID = &stringifiedOrgID } } @@ -56,6 +56,17 @@ func getSatelliteFacts(facts *[]FactSet) satelliteFacts { return satelliteFacts } +func convertInterfaceToString(v interface{}) string { + switch result := v.(type) { + case float64: + return fmt.Sprintf("%f", result) + case string: + return v.(string) + default: + return "" + } +} + func createHostGetHostByIdParams(orderBy string, orderHow string) *ApiHostGetHostByIdParams { orderByParam := OrderByParam(orderBy) orderHowParam := OrderHowParam(OrderHowParam_ASC)