clair: Index | Files | Directories

package featurefmt

import ""

Package featurefmt exposes functions to dynamically register methods for determining the features present in an image layer.

Package featurefmt contains utility functions for featurefmt tests


Package Files

driver.go testutil.go

func ListFeatures Uses

func ListFeatures(files tarutil.FilesMap, toUse []database.Detector) ([]database.LayerFeature, error)

ListFeatures produces the list of Features in an image layer using every registered Lister.

func ListListers Uses

func ListListers() []database.Detector

ListListers returns the names of all the registered feature listers.

func LoadFileForTest Uses

func LoadFileForTest(name string) []byte

LoadFileForTest can be used in order to obtain the []byte contents of a file that is meant to be used for test data.

func RegisterLister Uses

func RegisterLister(name string, version string, l Lister)

RegisterLister makes a Lister available by the provided name.

If called twice with the same name, the name is blank, or if the provided Lister is nil, this function panics.

func RequiredFilenames Uses

func RequiredFilenames(toUse []database.Detector) (files []string)

RequiredFilenames returns all file patterns that will be passed to the given extensions. These patterns are expressed as regexps. Any extension metadata that has non feature-detector type will be skipped.

func RunTest Uses

func RunTest(t *testing.T, test TestCase, lister Lister, expectedVersionFormat string)

RunTest runs a featurefmt test by loading the package info database files and the expected packages.

type Lister Uses

type Lister interface {
    // ListFeatures produces a list of Features present in an image layer.
    ListFeatures(tarutil.FilesMap) ([]database.LayerFeature, error)

    // RequiredFilenames returns a list of patterns for filenames that will
    // be in the FilesMap provided to the ListFeatures method.
    // The patterns are expressed as regexps, and will be matched against
    // full paths that do not include the leading "/".
    RequiredFilenames() []string

Lister represents an ability to list the features present in an image layer.

type TestCase Uses

type TestCase struct {
    Name           string
    FilePaths      map[string]string
    ExpectedResult []database.LayerFeature

TestCase is used by the RunTest function to execute.


apkPackage apk implements a featurefmt.Lister for APK packages.
dpkgPackage dpkg implements a featurefmt.Lister for dpkg packages.
rpmPackage rpm implements a featurefmt.Lister for rpm packages.

Package featurefmt imports 10 packages (graph) and is imported by 15 packages. Updated 2019-03-22. Refresh now. Tools for package owners.