Skip to content

Commit

Permalink
[Asset tests] Add installationInfo field to API response of get pac…
Browse files Browse the repository at this point in the history
…kage (#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.
  • Loading branch information
mrodm authored Nov 19, 2024
1 parent 6317430 commit c5cbbab
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions internal/kibana/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit c5cbbab

Please sign in to comment.