rpmmd: rename fetchpackagelist to fetchmetadata
the name was misleading because the function could do more than just download package list. In PushComposeRequest it is also used to fetch checksums for the repositories, therefore I decided to rename it to reflect this usage.
This commit is contained in:
parent
18ad83d43d
commit
f1b5ee8859
5 changed files with 17 additions and 37 deletions
|
|
@ -57,11 +57,12 @@ func TestFetchChecksum(quiet bool, dir string) {
|
|||
if !quiet {
|
||||
log.Println("Running TestFetchChecksum on:", dir)
|
||||
}
|
||||
c, err := repoCfg.FetchChecksum()
|
||||
rpmMetadata := rpmmd.NewRPMMD()
|
||||
_, c, err := rpmMetadata.FetchMetadata([]rpmmd.RepoConfig{repoCfg}, "platform:f31")
|
||||
if err != nil {
|
||||
log.Panic("Failed to fetch checksum:", err)
|
||||
}
|
||||
if c == "" {
|
||||
if c["repo"] == "" {
|
||||
log.Panic("The checksum is empty")
|
||||
}
|
||||
if !quiet {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ func NewRPMMDMock(fixture Fixture) rpmmd.RPMMD {
|
|||
return &rpmmdMock{Fixture: fixture}
|
||||
}
|
||||
|
||||
func (r *rpmmdMock) FetchPackageList(repos []rpmmd.RepoConfig, modulePlatformID string) (rpmmd.PackageList, map[string]string, error) {
|
||||
func (r *rpmmdMock) FetchMetadata(repos []rpmmd.RepoConfig, modulePlatformID string) (rpmmd.PackageList, map[string]string, error) {
|
||||
return r.Fixture.fetchPackageList.ret, r.Fixture.fetchPackageList.checksums, r.Fixture.fetchPackageList.err
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,13 @@ type PackageInfo struct {
|
|||
}
|
||||
|
||||
type RPMMD interface {
|
||||
FetchPackageList(repos []RepoConfig, modulePlatformID string) (PackageList, map[string]string, error)
|
||||
// FetchMetadata returns all metadata about the repositories we use in the code. Specifically it is a
|
||||
// list of packages and dictionary of checksums of the repositories.
|
||||
FetchMetadata(repos []RepoConfig, modulePlatformID string) (PackageList, map[string]string, error)
|
||||
|
||||
// Depsolve takes a list of required content (specs), explicitly unwanted content (excludeSpecs), list
|
||||
// or repositories, and platform ID for modularity. It returns a list of all packages (with solved
|
||||
// dependencies) that will be installed into the system.
|
||||
Depsolve(specs, excludeSpecs []string, repos []RepoConfig, modulePlatformID string, clean bool) ([]PackageSpec, map[string]string, error)
|
||||
}
|
||||
|
||||
|
|
@ -207,7 +213,7 @@ func NewRPMMD() RPMMD {
|
|||
return &rpmmdImpl{}
|
||||
}
|
||||
|
||||
func (*rpmmdImpl) FetchPackageList(repos []RepoConfig, modulePlatformID string) (PackageList, map[string]string, error) {
|
||||
func (*rpmmdImpl) FetchMetadata(repos []RepoConfig, modulePlatformID string) (PackageList, map[string]string, error) {
|
||||
var arguments = struct {
|
||||
Repos []RepoConfig `json:"repos"`
|
||||
ModulePlatformID string `json:"module_platform_id"`
|
||||
|
|
@ -295,27 +301,3 @@ func (pkg *PackageInfo) FillDependencies(rpmmd RPMMD, repos []RepoConfig, module
|
|||
pkg.Dependencies, _, err = rpmmd.Depsolve([]string{pkg.Name}, nil, repos, modulePlatformID, false)
|
||||
return
|
||||
}
|
||||
|
||||
// FetchChecksum returns a repository checksum for given repo config
|
||||
func (rc *RepoConfig) FetchChecksum() (string, error) {
|
||||
command := "dump"
|
||||
arguments := struct {
|
||||
Repos []RepoConfig `json:"repos"`
|
||||
}{
|
||||
Repos: []RepoConfig{*rc},
|
||||
}
|
||||
output := struct {
|
||||
Checksums map[string]string `json:"checksums"`
|
||||
Packages []Package `json:"packages"`
|
||||
}{}
|
||||
err := runDNF(command, arguments, &output)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
checksum, exists := output.Checksums[rc.Id]
|
||||
if !exists {
|
||||
// This should never happen unless there is a bug in dnf-json
|
||||
return "", &RepositoryError{"fatal error, dnf-json did not return required checksum"}
|
||||
}
|
||||
return checksum, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -600,13 +600,10 @@ func (s *Store) PushComposeRequest(request common.ComposeRequest) error {
|
|||
}
|
||||
|
||||
// map( repo-id => checksum )
|
||||
checksums := make(map[string]string)
|
||||
for _, repo := range request.Repositories {
|
||||
checksum, err := repo.FetchChecksum()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
checksums[repo.Id] = checksum
|
||||
rpmMetadata := rpmmd.NewRPMMD()
|
||||
_, checksums, err := rpmMetadata.FetchMetadata(request.Repositories, distroStruct.ModulePlatformID())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for imageBuildID, imageRequest := range request.RequestedImages {
|
||||
|
|
|
|||
|
|
@ -1839,7 +1839,7 @@ func (api *API) fetchPackageList() (rpmmd.PackageList, error) {
|
|||
repos = append(repos, source.RepoConfig())
|
||||
}
|
||||
|
||||
packages, _, err := api.rpmmd.FetchPackageList(repos, api.distro.ModulePlatformID())
|
||||
packages, _, err := api.rpmmd.FetchMetadata(repos, api.distro.ModulePlatformID())
|
||||
return packages, err
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue