Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
1105 Внедрение механизмов обеспечения безопасности цепочки поставки программных проектов
Legacy
scanned-projects
helm
Commits
7150fc3d
Commit
7150fc3d
authored
7 years ago
by
Shane Starcher
Browse files
Options
Download
Patches
Plain Diff
bug(helm) - install/upgrade/search semver constraint support
parent
01f8dcdc
main
Release
add-codeql
dependabot/go_modules/github.com/docker/distribution-2.8.2incompatible
dependabot/go_modules/github.com/lib/pq-1.10.9
dependabot/go_modules/github.com/rubenv/sql-migrate-1.4.0
dependabot/go_modules/golang.org/x/crypto-0.9.0
dependabot/go_modules/golang.org/x/term-0.8.0
dependabot/go_modules/k8s.io/klog/v2-2.100.1
dev-v2
feat-v3/event-emitter-lua
release-2.10
release-2.11
release-2.12
release-2.13
release-2.14
release-2.15
release-2.16
release-2.17
release-2.4
release-2.5
release-2.6
release-2.7
release-2.8
release-2.9
release-3.0
release-3.1
release-3.10
release-3.11
release-3.12
release-3.2
release-3.3
release-3.4
release-3.5
release-3.6
release-3.6.1
release-3.6.2
release-3.7
release-3.8
release-3.9
release-v3.0.0-beta.4
v3.12.0
v3.12.0-rc.1
v3.12.0-dev.1
v3.11.3
v3.11.2
v3.11.1
v3.11.0
v3.11.0-rc.2
v3.11.0-rc.1
v3.10.3
v3.10.2
v3.10.1
v3.10.0
v3.10.0-rc.1
v3.9.4
v3.9.3
v3.9.2
v3.9.1
v3.9.0
v3.9.0-rc.1
v3.8.2
v3.8.1
v3.8.0
v3.8.0-rc.2
v3.8.0-rc.1
v3.7.2
v3.7.1
v3.7.0
v3.7.0-rc.3
v3.7.0-rc.2
v3.7.0-rc.1
v3.6.3
v3.6.2
v3.6.1
v3.6.0
v3.6.0-rc.1
v3.5.4
v3.5.3
v3.5.2
v3.5.1
v3.5.0
v3.5.0-rc.2
v3.5.0-rc.1
v3.4.2
v3.4.1
v3.4.0
v3.4.0-rc.1
v3.3.4
v3.3.3
v3.3.2
v3.3.1
v3.3.0
v3.3.0-rc.2
v3.3.0-rc.1
v3.2.4
v3.2.3
v3.2.2
v3.2.1
v3.2.0
v3.2.0-rc.1
v3.1.3
v3.1.2
v3.1.1
v3.1.0
v3.1.0-rc.3
v3.1.0-rc.2
v3.1.0-rc.1
v3.0.3
v3.0.2
v3.0.1
v3.0.0
v3.0.0-rc.4
v3.0.0-rc.3
v3.0.0-rc.2
v3.0.0-rc.1
v3.0.0-beta.5
v3.0.0-beta.4
v3.0.0-beta.3
v3.0.0-beta.2
v3.0.0-beta.1
v3.0.0-alpha.2
v3.0.0-alpha.1
v2.17.0
v2.17.0-rc.1
v2.16.12
v2.16.11
v2.16.10
v2.16.9
v2.16.8
v2.16.7
v2.16.6
v2.16.5
v2.16.4
v2.16.3
v2.16.2
v2.16.1
v2.16.0
v2.16.0-rc.2
v2.16.0-rc.1
v2.15.2
v2.15.1
v2.15.0
v2.15.0-rc.2
v2.15.0-rc.1
v2.14.3
v2.14.2
v2.14.1
v2.14.0
v2.14.0-rc.2
v2.14.0-rc.1
v2.13.1
v2.13.1-rc.1
v2.13.0
v2.13.0-rc.2
v2.13.0-rc.1
v2.12.3
v2.12.2
v2.12.1
v2.12.0
v2.12.0-rc.2
v2.12.0-rc.1
v2.11.0
v2.11.0-rc.4
v2.11.0-rc.3
v2.11.0-rc.2
v2.11.0-rc.1
v2.10.0
v2.10.0-rc.3
v2.10.0-rc.2
v2.10.0-rc.1
v2.9.1
v2.9.0
v2.9.0-rc5
v2.9.0-rc4
v2.9.0-rc3
v2.9.0-rc2
v2.9.0-rc1
v2.8.2
v2.8.2-rc1
v2.8.1
v2.8.0
v2.8.0-rc.1
v2.7.2
v2.7.1
v2.7.0
v2.7.0-rc1
v2.6.2
v2.6.1
v2.6.0
v2.5.1
v2.5.0
v2.4.2
v2.4.1
v2.4.0
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
cmd/helm/search.go
+34
-11
cmd/helm/search.go
docs/helm/helm_search.md
+4
-3
docs/helm/helm_search.md
docs/man/man1/helm_search.1
+5
-1
docs/man/man1/helm_search.1
pkg/repo/index.go
+16
-3
pkg/repo/index.go
scripts/completions.bash
+3
-0
scripts/completions.bash
with
62 additions
and
18 deletions
+62
-18
cmd/helm/search.go
+
34
−
11
View file @
7150fc3d
...
...
@@ -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
)
if
err
!=
nil
{
return
nil
}
}
q
:=
strings
.
Join
(
args
,
" "
)
res
,
err
:=
index
.
Search
(
q
,
searchMaxScore
,
s
.
regexp
)
search
.
SortScore
(
res
)
data
,
err
:=
s
.
applyConstraint
(
res
)
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
}
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
{
...
...
This diff is collapsed.
Click to expand it.
docs/helm/helm_search.md
+
4
−
3
View file @
7150fc3d
...
...
@@ -19,8 +19,9 @@ helm search [keyword]
### Options
```
-r, --regexp use regular expressions for searching
-l, --versions show the long listing, with each version of each chart on its own line
-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
```
### Options inherited from parent commands
...
...
@@ -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
This diff is collapsed.
Click to expand it.
docs/man/man1/helm_search.1
+
5
−
1
View file @
7150fc3d
...
...
@@ -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
This diff is collapsed.
Click to expand it.
pkg/repo/index.go
+
16
−
3
View file @
7150fc3d
...
...
@@ -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
}
}
...
...
This diff is collapsed.
Click to expand it.
scripts/completions.bash
+
3
−
0
View file @
7150fc3d
...
...
@@ -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"
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets