weldr: remove usage of ImageType.PackageSets()
Use the new manifest generation procedure in the Weldr API. Updated test distro to include the same packages from the PackageSets() method in the Manifest.Content.PackageSets.
This commit is contained in:
parent
b495d9d476
commit
5ca4b4eb3f
2 changed files with 46 additions and 33 deletions
|
|
@ -243,6 +243,7 @@ func (t *TestImageType) Exports() []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TestImageType) Manifest(b *blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSpecSets map[string][]rpmmd.PackageSpec, containers []container.Spec, seed int64) (*manifest.Manifest, []string, error) {
|
func (t *TestImageType) Manifest(b *blueprint.Blueprint, options distro.ImageOptions, repos []rpmmd.RepoConfig, packageSpecSets map[string][]rpmmd.PackageSpec, containers []container.Spec, seed int64) (*manifest.Manifest, []string, error) {
|
||||||
|
var bpPkgs []string
|
||||||
if b != nil {
|
if b != nil {
|
||||||
mountpoints := b.Customizations.GetFilesystems()
|
mountpoints := b.Customizations.GetFilesystems()
|
||||||
|
|
||||||
|
|
@ -256,9 +257,36 @@ func (t *TestImageType) Manifest(b *blueprint.Blueprint, options distro.ImageOpt
|
||||||
if len(invalidMountpoints) > 0 {
|
if len(invalidMountpoints) > 0 {
|
||||||
return nil, nil, fmt.Errorf("The following custom mountpoints are not supported %+q", invalidMountpoints)
|
return nil, nil, fmt.Errorf("The following custom mountpoints are not supported %+q", invalidMountpoints)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bpPkgs = b.GetPackages()
|
||||||
}
|
}
|
||||||
|
|
||||||
ret := manifest.Manifest{}
|
ret := manifest.Manifest{
|
||||||
|
Content: manifest.Content{
|
||||||
|
PackageSets: map[string][]rpmmd.PackageSet{
|
||||||
|
buildPkgsKey: {{
|
||||||
|
Include: []string{
|
||||||
|
"dep-package1",
|
||||||
|
"dep-package2",
|
||||||
|
"dep-package3",
|
||||||
|
},
|
||||||
|
Repositories: repos,
|
||||||
|
}},
|
||||||
|
blueprintPkgsKey: {{
|
||||||
|
Include: bpPkgs,
|
||||||
|
Repositories: repos,
|
||||||
|
}},
|
||||||
|
osPkgsKey: {{
|
||||||
|
Include: []string{
|
||||||
|
"dep-package1",
|
||||||
|
"dep-package2",
|
||||||
|
"dep-package3",
|
||||||
|
},
|
||||||
|
Repositories: repos,
|
||||||
|
}},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
return &ret, nil, nil
|
return &ret, nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2241,29 +2241,14 @@ func (api *API) blueprintsTagHandler(writer http.ResponseWriter, request *http.R
|
||||||
statusResponseOK(writer)
|
statusResponseOK(writer)
|
||||||
}
|
}
|
||||||
|
|
||||||
// depsolveBlueprintForImageType handles depsolving the blueprint package list and
|
// depsolve handles depsolving package sets required for serializing a manifest for a given distribution.
|
||||||
// the packages required for the image type.
|
func (api *API) depsolve(packageSets map[string][]rpmmd.PackageSet, distro distro.Distro) (map[string][]rpmmd.PackageSpec, error) {
|
||||||
// NOTE: The imageType *must* be from the same distribution as the blueprint.
|
|
||||||
func (api *API) depsolveBlueprintForImageType(bp blueprint.Blueprint, options distro.ImageOptions, imageType distro.ImageType) (map[string][]rpmmd.PackageSpec, error) {
|
|
||||||
// Depsolve using the host distro if none has been specified
|
|
||||||
if bp.Distro == "" {
|
|
||||||
bp.Distro = api.hostDistroName
|
|
||||||
}
|
|
||||||
|
|
||||||
if bp.Distro != imageType.Arch().Distro().Name() {
|
platformID := distro.ModulePlatformID()
|
||||||
return nil, fmt.Errorf("Blueprint distro %s does not match imageType distro %s", bp.Distro, imageType.Arch().Distro().Name())
|
releasever := distro.Releasever()
|
||||||
}
|
distroName := distro.Name()
|
||||||
|
|
||||||
imageTypeRepos, err := api.allRepositoriesByImageType(imageType)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
platformID := imageType.Arch().Distro().ModulePlatformID()
|
|
||||||
releasever := imageType.Arch().Distro().Releasever()
|
|
||||||
distroName := imageType.Arch().Distro().Name()
|
|
||||||
solver := api.solver.NewWithConfig(platformID, releasever, api.archName, distroName)
|
solver := api.solver.NewWithConfig(platformID, releasever, api.archName, distroName)
|
||||||
|
|
||||||
packageSets := imageType.PackageSets(bp, options, imageTypeRepos)
|
|
||||||
depsolvedSets := make(map[string][]rpmmd.PackageSpec, len(packageSets))
|
depsolvedSets := make(map[string][]rpmmd.PackageSpec, len(packageSets))
|
||||||
|
|
||||||
for name, pkgSet := range packageSets {
|
for name, pkgSet := range packageSets {
|
||||||
|
|
@ -2502,18 +2487,7 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
|
||||||
APIType: facts.WELDR_APITYPE,
|
APIType: facts.WELDR_APITYPE,
|
||||||
}
|
}
|
||||||
|
|
||||||
packageSets, err := api.depsolveBlueprintForImageType(*bp, options, imageType)
|
|
||||||
if err != nil {
|
|
||||||
errors := responseError{
|
|
||||||
ID: "DepsolveError",
|
|
||||||
Msg: err.Error(),
|
|
||||||
}
|
|
||||||
statusResponseError(writer, http.StatusInternalServerError, errors)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
imageRepos, err := api.allRepositoriesByImageType(imageType)
|
imageRepos, err := api.allRepositoriesByImageType(imageType)
|
||||||
// this should not happen if the api.depsolveBlueprintForImageType() call above worked
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errors := responseError{
|
errors := responseError{
|
||||||
ID: "InternalError",
|
ID: "InternalError",
|
||||||
|
|
@ -2536,7 +2510,7 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
|
||||||
manifest, warnings, err := imageType.Manifest(bp,
|
manifest, warnings, err := imageType.Manifest(bp,
|
||||||
options,
|
options,
|
||||||
imageRepos,
|
imageRepos,
|
||||||
packageSets,
|
nil,
|
||||||
containerSpecs,
|
containerSpecs,
|
||||||
seed)
|
seed)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -2547,6 +2521,17 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
|
||||||
statusResponseError(writer, http.StatusBadRequest, errors)
|
statusResponseError(writer, http.StatusBadRequest, errors)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
packageSets, err := api.depsolve(manifest.Content.PackageSets, imageType.Arch().Distro())
|
||||||
|
if err != nil {
|
||||||
|
errors := responseError{
|
||||||
|
ID: "DepsolveError",
|
||||||
|
Msg: err.Error(),
|
||||||
|
}
|
||||||
|
statusResponseError(writer, http.StatusInternalServerError, errors)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
mf, err := manifest.Serialize(packageSets)
|
mf, err := manifest.Serialize(packageSets)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errors := responseError{
|
errors := responseError{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue