rpmtest

package
v1.5.26 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SortPackages = cmpopts.SortSlices(func(a, b *claircore.Package) bool {
		return a.Name < b.Name
	})
	IgnorePackageDB = cmpopts.IgnoreFields(claircore.Package{}, ".PackageDB")
)

Does what it says on the tin.

View Source
var EpochCompare = cmp.FilterPath(
	func(p cmp.Path) bool { return p.Last().String() == ".Version" },
	cmp.Comparer(func(a, b string) bool {
		evr, vr := a, b
		if len(b) > len(a) {
			evr = b
			vr = a
		}
		return strings.Contains(evr, vr)
	}),
)

RPM Manifest doesn't have package epoch information. This checks if the VR string is contained in the EVR string.

View Source
var HintCompare = cmp.FilterPath(
	func(p cmp.Path) bool { return p.Last().String() == ".RepositoryHint" },
	cmpopts.AcyclicTransformer("NormalizeHint", func(h string) string {
		n := [][2]string{}
		for _, s := range strings.Split(h, "|") {
			if s == "" {
				continue
			}
			k, v, ok := strings.Cut(s, ":")
			if !ok {
				panic("odd format: " + s)
			}
			if k == "hash" {
				continue
			}
			i := len(n)
			n = append(n, [2]string{})
			n[i][0] = k
			n[i][1] = v
		}
		sort.Slice(n, func(i, j int) bool { return n[i][0] < n[i][1] })
		var b strings.Builder
		for i, s := range n {
			if i != 0 {
				b.WriteByte('|')
			}
			b.WriteString(s[0])
			b.WriteByte(':')
			b.WriteString(s[1])
		}
		return b.String()
	}),
)

RPM Manifest doesn't have checksum information. It does have keyid information, so cook up a comparison function that understands the rpm package's packed format.

View Source
var ModuleCompare = cmp.FilterPath(
	func(p cmp.Path) bool { return p.Last().String() == ".Module" },
	cmp.FilterValues(
		func(a, b string) bool { return a != "" && b == "" || a == "" && b != "" },
		cmp.Ignore(),
	),
)

ModuleCompare allows one of the reported modules to be the empty string. This is needed because of STONEBLD-1472.

Functions

func PackagesFromRPMManifest

func PackagesFromRPMManifest(t *testing.T, r io.Reader) []*claircore.Package

Types

type Manifest

type Manifest struct {
	RPM []ManifestRPM `json:"rpms"`
}

type ManifestRPM

type ManifestRPM struct {
	Name    string `json:"name"`
	Version string `json:"version"`
	Release string `json:"release"`
	Arch    string `json:"architecture"`
	Source  string `json:"srpm_nevra"`
	GPG     string `json:"gpg"`
	Module  string `json:"module"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL