Skip to content

Commit c5cbbab

Browse files
authored
[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.
1 parent 6317430 commit c5cbbab

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

internal/kibana/packages.go

+13-3
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,29 @@ type FleetPackage struct {
6969
Version string `json:"version"`
7070
Type string `json:"type"`
7171
Status string `json:"status"`
72-
SavedObject struct {
72+
SavedObject *struct {
7373
Attributes struct {
7474
InstalledElasticsearchAssets []packages.Asset `json:"installed_es"`
7575
InstalledKibanaAssets []packages.Asset `json:"installed_kibana"`
7676
PackageAssets []packages.Asset `json:"package_assets"`
7777
} `json:"attributes"`
7878
} `json:"savedObject"`
79+
InstallationInfo *struct {
80+
InstalledElasticsearchAssets []packages.Asset `json:"installed_es"`
81+
InstalledKibanaAssets []packages.Asset `json:"installed_kibana"`
82+
} `json:"installationInfo"`
7983
}
8084

8185
func (p *FleetPackage) Assets() []packages.Asset {
8286
var assets []packages.Asset
83-
assets = append(assets, p.SavedObject.Attributes.InstalledElasticsearchAssets...)
84-
assets = append(assets, p.SavedObject.Attributes.InstalledKibanaAssets...)
87+
if p.SavedObject != nil {
88+
assets = append(assets, p.SavedObject.Attributes.InstalledElasticsearchAssets...)
89+
assets = append(assets, p.SavedObject.Attributes.InstalledKibanaAssets...)
90+
return assets
91+
}
92+
// starting in 9.0.0 "savedObject" fields does not exist in the API response
93+
assets = append(assets, p.InstallationInfo.InstalledElasticsearchAssets...)
94+
assets = append(assets, p.InstallationInfo.InstalledKibanaAssets...)
8595
return assets
8696
}
8797

0 commit comments

Comments
 (0)