search

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package search provides client-side repository searching.

This supports building an in-memory search index based on the contents of multiple repositories, and then using string matching or regular expressions to find matches.

Package search implements the search for charts in repos but extracts it into a package

so it can be reused and composed over Currently the helm search is implemented under the cmd dir which means that most of its options cant be used in a composite struct to build on top of them

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SortScore

func SortScore(r []*Result)

SortScore does an in-place sort of the results.

Lowest scores are highest on the list. Matching scores are subsorted alphabetically.

Types

type Index

type Index struct {
	// contains filtered or unexported fields
}

Index is a searchable index of chart information.

func NewIndex

func NewIndex() *Index

NewIndex creates a new Index.

func (*Index) AddRepo

func (i *Index) AddRepo(rname string, ind *repo.IndexFile, all bool)

AddRepo adds a repository index to the search index.

func (*Index) All

func (i *Index) All() []*Result

All returns all charts in the index as if they were search results.

Each will be given a score of 0.

func (*Index) Search

func (i *Index) Search(term string, threshold int, regexp bool) ([]*Result, error)

Search searches an index for the given term.

Threshold indicates the maximum score a term may have before being marked irrelevant. (Low score means higher relevance. Golf, not bowling.)

If regexp is true, the term is treated as a regular expression. Otherwise, term is treated as a literal string.

func (*Index) SearchLiteral

func (i *Index) SearchLiteral(term string, threshold int) []*Result

SearchLiteral does a literal string search (no regexp).

func (*Index) SearchRegexp

func (i *Index) SearchRegexp(re string, threshold int) ([]*Result, error)

SearchRegexp searches using a regular expression.

type RepoOptions

type RepoOptions struct {
	Versions     bool
	Regexp       bool
	Devel        bool
	Version      string
	MaxColWidth  uint
	RepoFile     string
	RepoCacheDir string
	OutputFormat output.Format
}

RepoOptions is the struct used to search, and stores the different options to filter and configure the output

func (*RepoOptions) Run

func (o *RepoOptions) Run(logger log.Logger, args []string) error

Run searchs and prints the found charts based of the filters

type Result

type Result struct {
	Name  string
	Score int
	Chart *helmRepo.ChartVersion
}

Result is a search result.

Score indicates how close it is to match. The higher the score, the longer the distance.

Jump to

Keyboard shortcuts

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