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
7150fc3d
Commit
7150fc3d
authored
Apr 18, 2017
by
Shane Starcher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug(helm) - install/upgrade/search semver constraint support
parent
01f8dcdc
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
18 deletions
+62
-18
search.go
cmd/helm/search.go
+34
-11
helm_search.md
docs/helm/helm_search.md
+4
-3
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 @
7150fc3d
...
@@ -21,6 +21,7 @@ import (
...
@@ -21,6 +21,7 @@ import (
"io"
"io"
"strings"
"strings"
"github.com/Masterminds/semver"
"github.com/gosuri/uitable"
"github.com/gosuri/uitable"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
...
@@ -45,6 +46,7 @@ type searchCmd struct {
...
@@ -45,6 +46,7 @@ type searchCmd struct {
versions
bool
versions
bool
regexp
bool
regexp
bool
version
string
}
}
func
newSearchCmd
(
out
io
.
Writer
)
*
cobra
.
Command
{
func
newSearchCmd
(
out
io
.
Writer
)
*
cobra
.
Command
{
...
@@ -62,6 +64,7 @@ func newSearchCmd(out io.Writer) *cobra.Command {
...
@@ -62,6 +64,7 @@ func newSearchCmd(out io.Writer) *cobra.Command {
f
:=
cmd
.
Flags
()
f
:=
cmd
.
Flags
()
f
.
BoolVarP
(
&
sc
.
regexp
,
"regexp"
,
"r"
,
false
,
"use regular expressions for searching"
)
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
.
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
return
cmd
}
}
...
@@ -72,27 +75,47 @@ func (s *searchCmd) run(args []string) error {
...
@@ -72,27 +75,47 @@ func (s *searchCmd) run(args []string) error {
return
err
return
err
}
}
var
res
[]
*
search
.
Result
if
len
(
args
)
==
0
{
if
len
(
args
)
==
0
{
s
.
showAllCharts
(
index
)
res
=
index
.
All
()
return
nil
}
else
{
q
:=
strings
.
Join
(
args
,
" "
)
res
,
err
=
index
.
Search
(
q
,
searchMaxScore
,
s
.
regexp
)
if
err
!=
nil
{
return
nil
}
}
}
q
:=
strings
.
Join
(
args
,
" "
)
search
.
SortScore
(
res
)
res
,
err
:=
index
.
Search
(
q
,
searchMaxScore
,
s
.
regexp
)
data
,
err
:=
s
.
applyConstraint
(
res
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
return
err
}
}
search
.
SortScore
(
res
)
fmt
.
Fprintln
(
s
.
out
,
s
.
formatSearchResults
(
res
))
fmt
.
Fprintln
(
s
.
out
,
s
.
formatSearchResults
(
data
))
return
nil
return
nil
}
}
func
(
s
*
searchCmd
)
showAllCharts
(
i
*
search
.
Index
)
{
func
(
s
*
searchCmd
)
applyConstraint
(
res
[]
*
search
.
Result
)
([]
*
search
.
Result
,
error
)
{
res
:=
i
.
All
()
if
len
(
s
.
version
)
==
0
{
search
.
SortScore
(
res
)
return
res
,
nil
fmt
.
Fprintln
(
s
.
out
,
s
.
formatSearchResults
(
res
))
}
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
{
func
(
s
*
searchCmd
)
formatSearchResults
(
res
[]
*
search
.
Result
)
string
{
...
...
docs/helm/helm_search.md
View file @
7150fc3d
...
@@ -19,8 +19,9 @@ helm search [keyword]
...
@@ -19,8 +19,9 @@ helm search [keyword]
### Options
### Options
```
```
-r, --regexp use regular expressions for searching
-r, --regexp use regular expressions for searching
-l, --versions show the long listing, with each version of each chart on its own line
-v, --version string search using semantic versioning constraints
-l, --versions show the long listing, with each version of each chart on its own line
```
```
### Options inherited from parent commands
### Options inherited from parent commands
...
@@ -36,4 +37,4 @@ helm search [keyword]
...
@@ -36,4 +37,4 @@ helm search [keyword]
### SEE ALSO
### SEE ALSO
*
[
helm
](
helm.md
)
- The Helm package manager for Kubernetes.
*
[
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 @
7150fc3d
...
@@ -27,6 +27,10 @@ Repositories are managed with 'helm repo' commands.
...
@@ -27,6 +27,10 @@ Repositories are managed with 'helm repo' commands.
\fB\-r\fP, \fB\-\-regexp\fP[=false]
\fB\-r\fP, \fB\-\-regexp\fP[=false]
use regular expressions for searching
use regular expressions for searching
.PP
\fB\-v\fP, \fB\-\-version\fP=""
search using semantic versioning constraints
.PP
.PP
\fB\-l\fP, \fB\-\-versions\fP[=false]
\fB\-l\fP, \fB\-\-versions\fP[=false]
show the long listing, with each version of each chart on its own line
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.
...
@@ -61,4 +65,4 @@ Repositories are managed with 'helm repo' commands.
.SH HISTORY
.SH HISTORY
.PP
.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 @
7150fc3d
...
@@ -155,12 +155,25 @@ func (i IndexFile) Get(name, version string) (*ChartVersion, error) {
...
@@ -155,12 +155,25 @@ func (i IndexFile) Get(name, version string) (*ChartVersion, error) {
if
len
(
vs
)
==
0
{
if
len
(
vs
)
==
0
{
return
nil
,
ErrNoChartVersion
return
nil
,
ErrNoChartVersion
}
}
var
constraint
*
semver
.
Constraints
if
len
(
version
)
==
0
{
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
{
for
_
,
ver
:=
range
vs
{
// TODO: Do we need to normalize the version field with the SemVer lib?
test
,
err
:=
semver
.
NewVersion
(
ver
.
Version
)
if
ver
.
Version
==
version
{
if
err
!=
nil
{
continue
}
if
constraint
.
Check
(
test
)
{
return
ver
,
nil
return
ver
,
nil
}
}
}
}
...
...
scripts/completions.bash
View file @
7150fc3d
...
@@ -1265,6 +1265,9 @@ _helm_search()
...
@@ -1265,6 +1265,9 @@ _helm_search()
flags+
=(
"--regexp"
)
flags+
=(
"--regexp"
)
flags+
=(
"-r"
)
flags+
=(
"-r"
)
local_nonpersistent_flags+
=(
"--regexp"
)
local_nonpersistent_flags+
=(
"--regexp"
)
flags+
=(
"--version="
)
two_word_flags+
=(
"-v"
)
local_nonpersistent_flags+
=(
"--version="
)
flags+
=(
"--versions"
)
flags+
=(
"--versions"
)
flags+
=(
"-l"
)
flags+
=(
"-l"
)
local_nonpersistent_flags+
=(
"--versions"
)
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