options

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// WildcardCharacter represents the character that can be supplied
	// to searches to find 'all' results (before filtering).
	// It is explicitly intended to be used in relation to querying a name.
	WildcardCharacter = "*"

	// FilterKeyName is the key to use for filtering 'name'.
	FilterKeyName = "name"

	// FilterKeyRuntime is the key to use for filtering 'runtime'.
	FilterKeyRuntime = "runtime"

	// FilterKeyTools is the key to use for filtering 'tools'.
	FilterKeyTools = "tools"

	// FilterKeyTags is the key to use for filtering 'tags'.
	FilterKeyTags = "tags"

	// FilterKeyCategories is the key to use for filtering 'categories'.
	FilterKeyCategories = "categories"

	// FilterKeyVersion is the key to use for filtering 'version'.
	FilterKeyVersion = "version"

	// FilterKeyLicense is the key to use for filtering 'license'.
	FilterKeyLicense = "license"

	// FilterKeySource is the key to use for filtering 'source'.
	FilterKeySource = "source"

	// FilterKeyIsOfficial is the key to use for filtering 'isOfficial'.
	FilterKeyIsOfficial = "isOfficial"
)

Variables

This section is empty.

Functions

func CategoriesProvider

func CategoriesProvider(pkg packages.Server) []string

func DefaultCacheDir

func DefaultCacheDir() (string, error)

DefaultCacheDir returns the default cache directory for registry manifests.

func DefaultCacheTTL

func DefaultCacheTTL() *config.Duration

DefaultCacheTTL returns the default cache time-to-live.

func DefaultMatchers

func DefaultMatchers() map[string]Predicate

func DisplayNameProvider

func DisplayNameProvider(pkg packages.Server) string

func IDProvider

func IDProvider(pkg packages.Server) string

func IsOfficialProvider

func IsOfficialProvider(pkg packages.Server) bool

func LicenseProvider

func LicenseProvider(pkg packages.Server) string

func Match

func Match(pkg packages.Server, filters map[string]string, opts ...Option) (bool, error)

Match filters a packages.Server using optional predicate matchers defined by the supplied filter keys. Each filter key corresponds to a predicate that (if supplied) evaluates a specific field in the packages.Server.

func NameProvider

func NameProvider(pkg packages.Server) string

func PrepareFilters

func PrepareFilters(
	filters map[string]string,
	name string,
	mutateFunc func(map[string]string) error,
) (map[string]string, error)

PrepareFilters returns a new map based on the provided filters, ensuring that the FilterKeyName is injected. If a registry-specific mutation function is provided, it is applied after the name injection. If the mutation function returns an error, PrepareFilters returns that error.

func ResolveFilters

func ResolveFilters(opts ResolveOptions) map[string]string

func RuntimesProvider

func RuntimesProvider(pkg packages.Server) []string

func SourceProvider

func SourceProvider(pkg packages.Server) string

func TagsProvider

func TagsProvider(pkg packages.Server) []string

func ToolsProvider

func ToolsProvider(pkg packages.Server) []string

func VersionsProvider

func VersionsProvider(pkg packages.Server) []string

Types

type BoolValueProvider

type BoolValueProvider = filter.BoolValueProvider[packages.Server]

BoolValueProvider is used to provide a specific boolean value from a packages.Server.

type BuildOption

type BuildOption func(*BuildOptions) error

BuildOption defines a functional option for configuring registry builds.

func WithCacheDir

func WithCacheDir(dir string) BuildOption

WithCacheDir configures the cache directory.

func WithCacheTTL

func WithCacheTTL(ttl time.Duration) BuildOption

WithCacheTTL configures the cache time-to-live.

func WithCaching

func WithCaching(enabled bool) BuildOption

WithCaching configures whether caching is enabled.

func WithRefreshCache

func WithRefreshCache(refreshCache bool) BuildOption

WithRefreshCache configures whether to force cache refresh.

type BuildOptions

type BuildOptions struct {
	// UseCache determines if registry manifest caching should be used.
	UseCache bool

	// RefreshCache forces refresh of cached registry manifests.
	RefreshCache bool

	// CacheDir specifies the cache directory (empty uses default).
	CacheDir string

	// CacheTTL specifies the cache time-to-live (zero uses default).
	CacheTTL time.Duration
}

BuildOptions contains configuration for building a registry. NewBuildOptions should be used to create instances of BuildOptions.

func NewBuildOptions

func NewBuildOptions(opts ...BuildOption) (BuildOptions, error)

NewBuildOptions creates BuildOptions with optional configurations applied. Starts with default values, then applies options in order with later options overriding earlier ones.

type Option

type Option = filter.Option[packages.Server]

Option for providing a packages.Server.

func WithCategoriesMatcher

func WithCategoriesMatcher(provider StringValuesProvider) Option

WithCategoriesMatcher returns a filter.Option with a matcher configured for the "categories" filter key. The matcher is applied during Match only if the categories filter key is present in the filters map. This matcher returns true if all the filter values are found in the package's categories as substrings. Matching is case-insensitive and uses normalized values.

func WithDefaultMatchers

func WithDefaultMatchers() Option

func WithIsOfficialMatcher

func WithIsOfficialMatcher(provider BoolValueProvider) Option

WithIsOfficialMatcher returns a filter.Option with a matcher configured for the 'is Official' filter key. The matcher is applied during Match only if the 'is_official' filter key is present in the filters map. This matcher performs boolean comparison on a parsed input string value, with the provided field.

func WithLicenseMatcher

func WithLicenseMatcher(provider StringValueProvider) Option

WithLicenseMatcher returns a filter.Option with a matcher configured for the "license" filter key. The matcher is applied during Match only if the license filter key is present in the filters map. This matcher performs case-insensitive substring matching on the license field.

func WithLogFunc

func WithLogFunc(fn func(key, val string)) Option

WithLogFunc sets a log function which will be used to log info if unsupported keys are encountered.

func WithNameMatcher

func WithNameMatcher() Option

WithNameMatcher returns a filter.Option with a matcher configured for the "name" filter key. The matcher is applied during Match only if the name filter key is present in the filters map. This matcher performs case-insensitive substring matching across Name, DisplayName, and ID fields. If the filter value is "*", all packages match unconditionally.

func WithRuntimeMatcher

func WithRuntimeMatcher(provider StringValuesProvider) Option

WithRuntimeMatcher returns a filter.Option with a matcher configured for the "runtime" filter key. The matcher is applied during Match only if the runtime filter key is present in the filters map. Matching is case-insensitive and uses normalized values.

func WithSourceMatcher

func WithSourceMatcher(provider StringValueProvider) Option

WithSourceMatcher returns a filter.Option with a matcher configured for the "source" filter key. The matcher is applied during Match only if the source filter key is present in the filters map. This matcher performs case-insensitive equality matching on the source field.

func WithTagsMatcher

func WithTagsMatcher(provider StringValuesProvider) Option

WithTagsMatcher returns a filter.Option with a matcher configured for the "tags" filter key. The matcher is applied during Match only if the tags filter key is present in the filters map. This matcher returns true if all the filter values are found in the package's tag as substrings. Matching is case-insensitive and uses normalized values.

func WithToolsMatcher

func WithToolsMatcher(provider StringValuesProvider) Option

WithToolsMatcher returns a filter.Option with a matcher configured for the "tools" filter key. The matcher is applied during Match only if the tools filter key is present in the filters map. This matcher returns true only if all filter values are found in the package's tools. Matching is case-insensitive and uses normalized values.

func WithUnsupportedKeys

func WithUnsupportedKeys(keys ...string) Option

WithUnsupportedKeys marks specific keys as unsupported when used for filtering.

func WithVersionMatcher

func WithVersionMatcher(provider StringValueProvider) Option

WithVersionMatcher returns a filter.Option with a matcher configured for the "version" filter key. The matcher is applied during Match only if the version filter key is present in the filters map. This matcher performs case-insensitive equality matching on the version field.

type Predicate

type Predicate = filter.Predicate[packages.Server]

Predicate for matching a packages.Server.

type ResolveOption

type ResolveOption func(*ResolveOptions) error

func WithResolveRuntime

func WithResolveRuntime(runtime runtime.Runtime) ResolveOption

func WithResolveSource

func WithResolveSource(source string) ResolveOption

func WithResolveVersion

func WithResolveVersion(version string) ResolveOption

type ResolveOptions

type ResolveOptions struct {
	Runtime runtime.Runtime
	Source  string
	Version string
}

func NewResolveOptions

func NewResolveOptions(opt ...ResolveOption) (ResolveOptions, error)

type SearchOption

type SearchOption func(*SearchOptions) error

func WithSearchSource

func WithSearchSource(source string) SearchOption

type SearchOptions

type SearchOptions struct {
	Source string
}

func NewSearchOptions

func NewSearchOptions(opt ...SearchOption) (SearchOptions, error)

type StringValueProvider

type StringValueProvider = filter.StringValueProvider[packages.Server]

StringValueProvider is used to provide a specific string value from a packages.Server.

type StringValuesProvider

type StringValuesProvider = filter.StringValuesProvider[packages.Server]

StringValuesProvider is used to provide a specific string slice value from a packages.Server.

Jump to

Keyboard shortcuts

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