v0.3.1 Latest Latest

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

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



Package search

Provides client-side repository searching

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

Our implementation but extracts it into a package so it can be reused and composed over

Search 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 based on the name, version or annotations.



This section is empty.


This section is empty.


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.


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
	Annotations  map[string]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