From c5cbbab1e4f1632a44c4c8ab07c0b58b72829a20 Mon Sep 17 00:00:00 2001 From: Mario Rodriguez Molins Date: Tue, 19 Nov 2024 12:50:55 +0100 Subject: [PATCH] [Asset tests] Add `installationInfo` field to API response of get package (#2233) The "savedObject" field has been removed from the API response starting in 9.0.0 Elastic stack. The information about the assets installed by a package now should be retrieved from the "installationInfo" field included in the API response. That field contains the same data that "savedObject" had. --- internal/kibana/packages.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/internal/kibana/packages.go b/internal/kibana/packages.go index 77e4d49b0..40b40434e 100644 --- a/internal/kibana/packages.go +++ b/internal/kibana/packages.go @@ -69,19 +69,29 @@ type FleetPackage struct { Version string `json:"version"` Type string `json:"type"` Status string `json:"status"` - SavedObject struct { + SavedObject *struct { Attributes struct { InstalledElasticsearchAssets []packages.Asset `json:"installed_es"` InstalledKibanaAssets []packages.Asset `json:"installed_kibana"` PackageAssets []packages.Asset `json:"package_assets"` } `json:"attributes"` } `json:"savedObject"` + InstallationInfo *struct { + InstalledElasticsearchAssets []packages.Asset `json:"installed_es"` + InstalledKibanaAssets []packages.Asset `json:"installed_kibana"` + } `json:"installationInfo"` } func (p *FleetPackage) Assets() []packages.Asset { var assets []packages.Asset - assets = append(assets, p.SavedObject.Attributes.InstalledElasticsearchAssets...) - assets = append(assets, p.SavedObject.Attributes.InstalledKibanaAssets...) + if p.SavedObject != nil { + assets = append(assets, p.SavedObject.Attributes.InstalledElasticsearchAssets...) + assets = append(assets, p.SavedObject.Attributes.InstalledKibanaAssets...) + return assets + } + // starting in 9.0.0 "savedObject" fields does not exist in the API response + assets = append(assets, p.InstallationInfo.InstalledElasticsearchAssets...) + assets = append(assets, p.InstallationInfo.InstalledKibanaAssets...) return assets }