func (o *RepoOptions) applyConstraint(res []*Result) ([]*Result, error) {
	if o.Version == "" {
		return res, nil
	}
	constraint, err := semver.NewConstraint(o.Version)
	if err != nil {
		return res, errors.Wrap(err, "an invalid version/constraint format")
	}
	data := res[:0]
	foundNames := map[string]bool{}
	for _, r := range res {
		if !o.Versions && foundNames[r.Name] {
			continue
		}
		v, err := semver.NewVersion(r.Chart.Version)
		if err != nil {
			continue
		}
		if constraint.Check(v) {
			data = append(data, r)
			foundNames[r.Name] = true
		}
	}
	return data, nil
}
applyConstraint get a result list and filters it based on the version constraint set
package search
import (
	"fmt"
	"github.com/Masterminds/log-go"
	logio "github.com/Masterminds/log-go/io"
	"github.com/Masterminds/semver/v3"
	"github.com/gosuri/uitable"
	"github.com/pkg/errors"
	"github.com/rancher-sandbox/hypper/pkg/hypperpath"
	"github.com/rancher-sandbox/hypper/pkg/repo"
	"helm.sh/helm/v3/pkg/cli/output"
	"io"
	"os"
	"path/filepath"
	"regexp"
	"strings"
)
const searchMaxScore = 25
func isNotExist(err error) bool {
	return os.IsNotExist(errors.Cause(err))
}
type RepoOptions struct {
	Versions     bool
	Regexp       bool
	Devel        bool
	Version      string
	MaxColWidth  uint
	RepoFile     string
	RepoCacheDir string
	Annotations  map[string]string
	OutputFormat output.Format
}
func (o *RepoOptions) Run(logger log.Logger, args []string) error {
	wInfo := logio.NewWriter(logger, log.InfoLevel)
	o.setupSearchedVersion()
	index, err := o.buildIndex()
	if err != nil {
		return err
	}
	var res []*Result
	if len(args) == 0 {
		res = index.All()
	} else {
		q := strings.Join(args, " ")
		res, err = index.Search(q, searchMaxScore, o.Regexp)
		if err != nil {
			return err
		}
	}
	SortScore(res)
	data, err := o.applyAnnotationsConstraint(res)
	if err != nil {
		return err
	}
	data, err = o.applyConstraint(data)
	if err != nil {
		return err
	}
	return o.OutputFormat.Write(wInfo, &repoSearchWriter{data, o.MaxColWidth})
}
func (o *RepoOptions) setupSearchedVersion() {
	log.Debug("Original chart version: %q", o.Version)
	if o.Version != "" {
		return
	}
	if o.Devel {  
		log.Debug("setting version to >0.0.0-0")
		o.Version = ">0.0.0-0"
	} else {  
		log.Debug("setting version to >0.0.0")
		o.Version = ">0.0.0"
	}
}