Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
helm3
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
helm3
Commits
fe110405
Commit
fe110405
authored
Apr 18, 2017
by
Matt Butcher
Committed by
GitHub
Apr 18, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2279 from sstarcher/search_constraint
Search constraint and Install/Upgrade default constraint
parents
d4e129d5
7150fc3d
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
15 deletions
+59
-15
search.go
cmd/helm/search.go
+33
-10
helm_search.md
docs/helm/helm_search.md
+2
-1
helm_search.1
docs/man/man1/helm_search.1
+5
-1
index.go
pkg/repo/index.go
+16
-3
completions.bash
scripts/completions.bash
+3
-0
No files found.
cmd/helm/search.go
View file @
fe110405
...
...
@@ -21,6 +21,7 @@ import (
"io"
"strings"
"github.com/Masterminds/semver"
"github.com/gosuri/uitable"
"github.com/spf13/cobra"
...
...
@@ -45,6 +46,7 @@ type searchCmd struct {
versions
bool
regexp
bool
version
string
}
func
newSearchCmd
(
out
io
.
Writer
)
*
cobra
.
Command
{
...
...
@@ -62,6 +64,7 @@ func newSearchCmd(out io.Writer) *cobra.Command {
f
:=
cmd
.
Flags
()
f
.
BoolVarP
(
&
sc
.
regexp
,
"regexp"
,
"r"
,
false
,
"use regular expressions for searching"
)
f
.
BoolVarP
(
&
sc
.
versions
,
"versions"
,
"l"
,
false
,
"show the long listing, with each version of each chart on its own line"
)
f
.
StringVarP
(
&
sc
.
version
,
"version"
,
"v"
,
""
,
"search using semantic versioning constraints"
)
return
cmd
}
...
...
@@ -72,27 +75,47 @@ func (s *searchCmd) run(args []string) error {
return
err
}
var
res
[]
*
search
.
Result
if
len
(
args
)
==
0
{
s
.
showAllCharts
(
index
)
return
nil
}
res
=
index
.
All
()
}
else
{
q
:=
strings
.
Join
(
args
,
" "
)
res
,
err
:
=
index
.
Search
(
q
,
searchMaxScore
,
s
.
regexp
)
res
,
err
=
index
.
Search
(
q
,
searchMaxScore
,
s
.
regexp
)
if
err
!=
nil
{
return
nil
}
}
search
.
SortScore
(
res
)
data
,
err
:=
s
.
applyConstraint
(
res
)
if
err
!=
nil
{
return
err
}
fmt
.
Fprintln
(
s
.
out
,
s
.
formatSearchResults
(
res
))
fmt
.
Fprintln
(
s
.
out
,
s
.
formatSearchResults
(
data
))
return
nil
}
func
(
s
*
searchCmd
)
showAllCharts
(
i
*
search
.
Index
)
{
res
:=
i
.
All
()
search
.
SortScore
(
res
)
fmt
.
Fprintln
(
s
.
out
,
s
.
formatSearchResults
(
res
))
func
(
s
*
searchCmd
)
applyConstraint
(
res
[]
*
search
.
Result
)
([]
*
search
.
Result
,
error
)
{
if
len
(
s
.
version
)
==
0
{
return
res
,
nil
}
constraint
,
err
:=
semver
.
NewConstraint
(
s
.
version
)
if
err
!=
nil
{
return
res
,
fmt
.
Errorf
(
"an invalid version/constraint format: %s"
,
err
)
}
data
:=
res
[
:
0
]
for
_
,
r
:=
range
res
{
v
,
err
:=
semver
.
NewVersion
(
r
.
Chart
.
Version
)
if
err
!=
nil
||
constraint
.
Check
(
v
)
{
data
=
append
(
data
,
r
)
}
}
return
data
,
nil
}
func
(
s
*
searchCmd
)
formatSearchResults
(
res
[]
*
search
.
Result
)
string
{
...
...
docs/helm/helm_search.md
View file @
fe110405
...
...
@@ -20,6 +20,7 @@ helm search [keyword]
```
-r, --regexp use regular expressions for searching
-v, --version string search using semantic versioning constraints
-l, --versions show the long listing, with each version of each chart on its own line
```
...
...
@@ -36,4 +37,4 @@ helm search [keyword]
### SEE ALSO
*
[
helm
](
helm.md
)
- The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on 1
6
-Apr-2017
###### Auto generated by spf13/cobra on 1
8
-Apr-2017
docs/man/man1/helm_search.1
View file @
fe110405
...
...
@@ -27,6 +27,10 @@ Repositories are managed with 'helm repo' commands.
\fB\-r\fP, \fB\-\-regexp\fP[=false]
use regular expressions for searching
.PP
\fB\-v\fP, \fB\-\-version\fP=""
search using semantic versioning constraints
.PP
\fB\-l\fP, \fB\-\-versions\fP[=false]
show the long listing, with each version of each chart on its own line
...
...
@@ -61,4 +65,4 @@ Repositories are managed with 'helm repo' commands.
.SH HISTORY
.PP
1
6
\-Apr\-2017 Auto generated by spf13/cobra
1
8
\-Apr\-2017 Auto generated by spf13/cobra
pkg/repo/index.go
View file @
fe110405
...
...
@@ -155,12 +155,25 @@ func (i IndexFile) Get(name, version string) (*ChartVersion, error) {
if
len
(
vs
)
==
0
{
return
nil
,
ErrNoChartVersion
}
var
constraint
*
semver
.
Constraints
if
len
(
version
)
==
0
{
return
vs
[
0
],
nil
constraint
,
_
=
semver
.
NewConstraint
(
"*"
)
}
else
{
var
err
error
constraint
,
err
=
semver
.
NewConstraint
(
version
)
if
err
!=
nil
{
return
nil
,
err
}
}
for
_
,
ver
:=
range
vs
{
// TODO: Do we need to normalize the version field with the SemVer lib?
if
ver
.
Version
==
version
{
test
,
err
:=
semver
.
NewVersion
(
ver
.
Version
)
if
err
!=
nil
{
continue
}
if
constraint
.
Check
(
test
)
{
return
ver
,
nil
}
}
...
...
scripts/completions.bash
View file @
fe110405
...
...
@@ -1265,6 +1265,9 @@ _helm_search()
flags+
=(
"--regexp"
)
flags+
=(
"-r"
)
local_nonpersistent_flags+
=(
"--regexp"
)
flags+
=(
"--version="
)
two_word_flags+
=(
"-v"
)
local_nonpersistent_flags+
=(
"--version="
)
flags+
=(
"--versions"
)
flags+
=(
"-l"
)
local_nonpersistent_flags+
=(
"--versions"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment