Skip to content

Commit

Permalink
many: rename dnfjson.DepsolveResult to Result
Browse files Browse the repository at this point in the history
This commit renames `dnfjson.DepsolveResult` to `dnfjson.Result`.
It is slightly less descriptive but shorter and the only kind
of result we have in the pacakge is from a depsolve so the meaning
should be clear enough.
  • Loading branch information
mvo5 committed Jan 16, 2025
1 parent ff89da5 commit 991d5d8
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions cmd/build/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ func resolvePipelineCommits(commitSources map[string][]ostree.SourceSpec) (map[s
return commits, nil
}

func depsolve(cacheDir string, packageSets map[string][]rpmmd.PackageSet, d distro.Distro, arch string) (map[string]dnfjson.DepsolveResult, error) {
func depsolve(cacheDir string, packageSets map[string][]rpmmd.PackageSet, d distro.Distro, arch string) (map[string]dnfjson.Result, error) {
solver := dnfjson.NewSolver(d.ModulePlatformID(), d.Releasever(), arch, d.Name(), cacheDir)
depsolvedSets := make(map[string]dnfjson.DepsolveResult)
depsolvedSets := make(map[string]dnfjson.Result)
for name, pkgSet := range packageSets {
res, err := solver.Depsolve(pkgSet, sbom.StandardTypeNone)
if err != nil {
Expand Down
14 changes: 7 additions & 7 deletions cmd/gen-manifests/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func makeManifestJob(
return
}

var depsolvedSets map[string]dnfjson.DepsolveResult
var depsolvedSets map[string]dnfjson.Result
if content["packages"] {
depsolvedSets, err = depsolve(cacheDir, manifest.GetPackageSetChains(), distribution, archName)
if err != nil {
Expand Down Expand Up @@ -344,9 +344,9 @@ func mockResolveCommits(commitSources map[string][]ostree.SourceSpec) map[string
return commits
}

func depsolve(cacheDir string, packageSets map[string][]rpmmd.PackageSet, d distro.Distro, arch string) (map[string]dnfjson.DepsolveResult, error) {
func depsolve(cacheDir string, packageSets map[string][]rpmmd.PackageSet, d distro.Distro, arch string) (map[string]dnfjson.Result, error) {
solver := dnfjson.NewSolver(d.ModulePlatformID(), d.Releasever(), arch, d.Name(), cacheDir)
depsolvedSets := make(map[string]dnfjson.DepsolveResult)
depsolvedSets := make(map[string]dnfjson.Result)
for name, pkgSet := range packageSets {
res, err := solver.Depsolve(pkgSet, sbom.StandardTypeNone)
if err != nil {
Expand All @@ -357,8 +357,8 @@ func depsolve(cacheDir string, packageSets map[string][]rpmmd.PackageSet, d dist
return depsolvedSets, nil
}

func mockDepsolve(packageSets map[string][]rpmmd.PackageSet, repos []rpmmd.RepoConfig, archName string) map[string]dnfjson.DepsolveResult {
depsolvedSets := make(map[string]dnfjson.DepsolveResult)
func mockDepsolve(packageSets map[string][]rpmmd.PackageSet, repos []rpmmd.RepoConfig, archName string) map[string]dnfjson.Result {
depsolvedSets := make(map[string]dnfjson.Result)

for name, pkgSetChain := range packageSets {
specSet := make([]rpmmd.PackageSpec, 0)
Expand Down Expand Up @@ -419,7 +419,7 @@ func mockDepsolve(packageSets map[string][]rpmmd.PackageSet, repos []rpmmd.RepoC
})
}

depsolvedSets[name] = dnfjson.DepsolveResult{
depsolvedSets[name] = dnfjson.Result{
Packages: specSet,
Repos: repos,
}
Expand All @@ -428,7 +428,7 @@ func mockDepsolve(packageSets map[string][]rpmmd.PackageSet, repos []rpmmd.RepoC
return depsolvedSets
}

func save(ms manifest.OSBuildManifest, depsolved map[string]dnfjson.DepsolveResult, containers map[string][]container.Spec, commits map[string][]ostree.CommitSpec, cr buildRequest, path, filename string, metadata bool) error {
func save(ms manifest.OSBuildManifest, depsolved map[string]dnfjson.Result, containers map[string][]container.Spec, commits map[string][]ostree.CommitSpec, cr buildRequest, path, filename string, metadata bool) error {
var data interface{}
if metadata {
rpmmds := make(map[string][]rpmmd.PackageSpec)
Expand Down
2 changes: 1 addition & 1 deletion cmd/osbuild-playground/playground.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func RunPlayground(img image.ImageKind, d distro.Distro, arch distro.Arch, repos
panic("InstantiateManifest() failed: " + err.Error())
}

depsolvedSets := make(map[string]dnfjson.DepsolveResult)
depsolvedSets := make(map[string]dnfjson.Result)
for name, chain := range manifest.GetPackageSetChains() {
res, err := solver.Depsolve(chain, sbom.StandardTypeNone)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/distro/distro_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func TestImageTypePipelineNames(t *testing.T) {
{Name: "filesystem", Checksum: "sha256:6b4bf18ba28ccbdd49f2716c9f33c9211155ff703fa6c195c78a07bd160da0eb"},
}

depsolvedSets := make(map[string]dnfjson.DepsolveResult, len(allPipelines))
depsolvedSets := make(map[string]dnfjson.Result, len(allPipelines))
for _, plName := range allPipelines {
dr := depsolvedSets[plName]
dr.Packages = minimalPackageSet
Expand Down
8 changes: 4 additions & 4 deletions pkg/dnfjson/dnfjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ type Solver struct {
subscriptions *rhsm.Subscriptions
}

// DepsolveResult contains the results of a depsolve operation.
type DepsolveResult struct {
// Result contains the results of a dnfjson depsolve operation.
type Result struct {
Packages []rpmmd.PackageSpec
Repos []rpmmd.RepoConfig
SBOM *sbom.Document
Expand Down Expand Up @@ -202,7 +202,7 @@ func (s *Solver) SetProxy(proxy string) error {
// their associated repositories. Each package set is depsolved as a separate
// transactions in a chain. It returns a list of all packages (with solved
// dependencies) that will be installed into the system.
func (s *Solver) Depsolve(pkgSets []rpmmd.PackageSet, sbomType sbom.StandardType) (*DepsolveResult, error) {
func (s *Solver) Depsolve(pkgSets []rpmmd.PackageSet, sbomType sbom.StandardType) (*Result, error) {
req, rhsmMap, err := s.makeDepsolveRequest(pkgSets, sbomType)
if err != nil {
return nil, fmt.Errorf("makeDepsolveRequest failed: %w", err)
Expand Down Expand Up @@ -241,7 +241,7 @@ func (s *Solver) Depsolve(pkgSets []rpmmd.PackageSet, sbomType sbom.StandardType
}
}

return &DepsolveResult{
return &Result{
Packages: packages,
Repos: repos,
SBOM: sbomDoc,
Expand Down
6 changes: 3 additions & 3 deletions pkg/image/installer_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"github.com/osbuild/images/pkg/runner"
)

func mockPackageSets() map[string]dnfjson.DepsolveResult {
return map[string]dnfjson.DepsolveResult{
func mockPackageSets() map[string]dnfjson.Result {
return map[string]dnfjson.Result{
"build": {
Packages: []rpmmd.PackageSpec{
{
Expand Down Expand Up @@ -362,7 +362,7 @@ func TestLiveInstallerSquashfsRootfs(t *testing.T) {
assert.NotContains(t, mfs, `"name:rootfs-image"`)
}

func instantiateAndSerialize(t *testing.T, img image.ImageKind, depsolved map[string]dnfjson.DepsolveResult, containers map[string][]container.Spec, commits map[string][]ostree.CommitSpec) string {
func instantiateAndSerialize(t *testing.T, img image.ImageKind, depsolved map[string]dnfjson.Result, containers map[string][]container.Spec, commits map[string][]ostree.CommitSpec) string {
source := rand.NewSource(int64(0))
// math/rand is good enough in this case
/* #nosec G404 */
Expand Down
2 changes: 1 addition & 1 deletion pkg/manifest/anaconda_installer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestAnacondaInstallerModules(t *testing.T) {
installerPipeline.UseLegacyAnacondaConfig = legacy
installerPipeline.AdditionalAnacondaModules = tc.enable
installerPipeline.DisabledAnacondaModules = tc.disable
installerPipeline.serializeStart(Inputs{Depsolved: dnfjson.DepsolveResult{Packages: pkgs}})
installerPipeline.serializeStart(Inputs{Depsolved: dnfjson.Result{Packages: pkgs}})
pipeline := installerPipeline.serialize()

require := require.New(t)
Expand Down
2 changes: 1 addition & 1 deletion pkg/manifest/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (m Manifest) GetOSTreeSourceSpecs() map[string][]ostree.SourceSpec {
return ostreeSpecs
}

func (m Manifest) Serialize(depsolvedSets map[string]dnfjson.DepsolveResult, containerSpecs map[string][]container.Spec, ostreeCommits map[string][]ostree.CommitSpec, rpmDownloader osbuild.RpmDownloader) (OSBuildManifest, error) {
func (m Manifest) Serialize(depsolvedSets map[string]dnfjson.Result, containerSpecs map[string][]container.Spec, ostreeCommits map[string][]ostree.CommitSpec, rpmDownloader osbuild.RpmDownloader) (OSBuildManifest, error) {
for _, pipeline := range m.pipelines {
pipeline.serializeStart(Inputs{
Depsolved: depsolvedSets[pipeline.Name()],
Expand Down
2 changes: 1 addition & 1 deletion pkg/manifest/os_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func NewTestOS() *OS {
{Name: "pkg1", Checksum: "sha1:c02524e2bd19490f2a7167958f792262754c5f46"},
}
os.serializeStart(Inputs{
Depsolved: dnfjson.DepsolveResult{
Depsolved: dnfjson.Result{
Packages: packages,
Repos: repos,
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/osbuild/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const (
// Note that for Packages/RpmRepos the depsolve resolved results
// must be passed
type SourceInputs struct {
Depsolved dnfjson.DepsolveResult
Depsolved dnfjson.Result
Containers []container.Spec
Commits []ostree.CommitSpec
InlineData []string
Expand Down
8 changes: 4 additions & 4 deletions pkg/osbuild/source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ var fakeRepos = []rpmmd.RepoConfig{

func TestGenSourcesRpmDefaultRpmDownloaderIsCurl(t *testing.T) {
inputs := SourceInputs{
Depsolved: dnfjson.DepsolveResult{
Depsolved: dnfjson.Result{
Packages: []rpmmd.PackageSpec{opensslPkg},
Repos: fakeRepos,
},
Expand All @@ -253,7 +253,7 @@ func TestGenSourcesRpmDefaultRpmDownloaderIsCurl(t *testing.T) {

func TestGenSourcesRpmWithLibcurl(t *testing.T) {
inputs := SourceInputs{
Depsolved: dnfjson.DepsolveResult{
Depsolved: dnfjson.Result{
Packages: []rpmmd.PackageSpec{opensslPkg},
Repos: fakeRepos,
},
Expand All @@ -276,7 +276,7 @@ func TestGenSourcesRpmWithLibcurl(t *testing.T) {

func TestGenSourcesRpmWithLibrepo(t *testing.T) {
inputs := SourceInputs{
Depsolved: dnfjson.DepsolveResult{
Depsolved: dnfjson.Result{
Packages: []rpmmd.PackageSpec{opensslPkg},
Repos: fakeRepos,
},
Expand Down Expand Up @@ -308,7 +308,7 @@ func TestGenSourcesRpmWithLibrepo(t *testing.T) {

func TestGenSourcesRpmBad(t *testing.T) {
inputs := SourceInputs{
Depsolved: dnfjson.DepsolveResult{
Depsolved: dnfjson.Result{
Packages: []rpmmd.PackageSpec{opensslPkg},
Repos: fakeRepos,
},
Expand Down

0 comments on commit 991d5d8

Please sign in to comment.