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
36252410
Commit
36252410
authored
Mar 14, 2018
by
Florian Zysset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(helm): inspect readme
parent
d5161584
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
133 additions
and
35 deletions
+133
-35
inspect.go
cmd/helm/inspect.go
+79
-28
inspect_test.go
cmd/helm/inspect_test.go
+8
-5
helm.md
docs/helm/helm.md
+1
-1
helm_inspect.md
docs/helm/helm_inspect.md
+2
-1
helm_inspect_readme.md
docs/helm/helm_inspect_readme.md
+43
-0
No files found.
cmd/helm/inspect.go
View file @
36252410
...
@@ -19,11 +19,14 @@ package main
...
@@ -19,11 +19,14 @@ package main
import
(
import
(
"fmt"
"fmt"
"io"
"io"
"strings"
"github.com/ghodss/yaml"
"github.com/ghodss/yaml"
"github.com/golang/protobuf/ptypes/any"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
"k8s.io/helm/pkg/chartutil"
"k8s.io/helm/pkg/chartutil"
"k8s.io/kubernetes/pkg/util/slice"
)
)
const
inspectDesc
=
`
const
inspectDesc
=
`
...
@@ -43,6 +46,11 @@ This command inspects a chart (directory, file, or URL) and displays the content
...
@@ -43,6 +46,11 @@ This command inspects a chart (directory, file, or URL) and displays the content
of the Charts.yaml file
of the Charts.yaml file
`
`
const
readmeChartDesc
=
`
This command inspects a chart (directory, file, or URL) and displays the contents
of the README file
`
type
inspectCmd
struct
{
type
inspectCmd
struct
{
chartpath
string
chartpath
string
output
string
output
string
...
@@ -60,13 +68,16 @@ type inspectCmd struct {
...
@@ -60,13 +68,16 @@ type inspectCmd struct {
const
(
const
(
chartOnly
=
"chart"
chartOnly
=
"chart"
valuesOnly
=
"values"
valuesOnly
=
"values"
both
=
"both"
readmeOnly
=
"readme"
all
=
"all"
)
)
var
readmeFileNames
=
[]
string
{
"readme.md"
,
"readme.txt"
,
"readme"
}
func
newInspectCmd
(
out
io
.
Writer
)
*
cobra
.
Command
{
func
newInspectCmd
(
out
io
.
Writer
)
*
cobra
.
Command
{
insp
:=
&
inspectCmd
{
insp
:=
&
inspectCmd
{
out
:
out
,
out
:
out
,
output
:
both
,
output
:
all
,
}
}
inspectCommand
:=
&
cobra
.
Command
{
inspectCommand
:=
&
cobra
.
Command
{
...
@@ -125,51 +136,72 @@ func newInspectCmd(out io.Writer) *cobra.Command {
...
@@ -125,51 +136,72 @@ func newInspectCmd(out io.Writer) *cobra.Command {
},
},
}
}
readmeSubCmd
:=
&
cobra
.
Command
{
Use
:
"readme [CHART]"
,
Short
:
"shows inspect readme"
,
Long
:
readmeChartDesc
,
RunE
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
insp
.
output
=
readmeOnly
if
err
:=
checkArgsLength
(
len
(
args
),
"chart name"
);
err
!=
nil
{
return
err
}
cp
,
err
:=
locateChartPath
(
insp
.
repoURL
,
args
[
0
],
insp
.
version
,
insp
.
verify
,
insp
.
keyring
,
insp
.
certFile
,
insp
.
keyFile
,
insp
.
caFile
)
if
err
!=
nil
{
return
err
}
insp
.
chartpath
=
cp
return
insp
.
run
()
},
}
cmds
:=
[]
*
cobra
.
Command
{
inspectCommand
,
readmeSubCmd
,
valuesSubCmd
,
chartSubCmd
}
vflag
:=
"verify"
vflag
:=
"verify"
vdesc
:=
"verify the provenance data for this chart"
vdesc
:=
"verify the provenance data for this chart"
inspectCommand
.
Flags
()
.
BoolVar
(
&
insp
.
verify
,
vflag
,
false
,
vdesc
)
for
_
,
subCmd
:=
range
cmds
{
valuesS
ubCmd
.
Flags
()
.
BoolVar
(
&
insp
.
verify
,
vflag
,
false
,
vdesc
)
s
ubCmd
.
Flags
()
.
BoolVar
(
&
insp
.
verify
,
vflag
,
false
,
vdesc
)
chartSubCmd
.
Flags
()
.
BoolVar
(
&
insp
.
verify
,
vflag
,
false
,
vdesc
)
}
kflag
:=
"keyring"
kflag
:=
"keyring"
kdesc
:=
"path to the keyring containing public verification keys"
kdesc
:=
"path to the keyring containing public verification keys"
kdefault
:=
defaultKeyring
()
kdefault
:=
defaultKeyring
()
inspectCommand
.
Flags
()
.
StringVar
(
&
insp
.
keyring
,
kflag
,
kdefault
,
kdesc
)
for
_
,
subCmd
:=
range
cmds
{
valuesS
ubCmd
.
Flags
()
.
StringVar
(
&
insp
.
keyring
,
kflag
,
kdefault
,
kdesc
)
s
ubCmd
.
Flags
()
.
StringVar
(
&
insp
.
keyring
,
kflag
,
kdefault
,
kdesc
)
chartSubCmd
.
Flags
()
.
StringVar
(
&
insp
.
keyring
,
kflag
,
kdefault
,
kdesc
)
}
verflag
:=
"version"
verflag
:=
"version"
verdesc
:=
"version of the chart. By default, the newest chart is shown"
verdesc
:=
"version of the chart. By default, the newest chart is shown"
inspectCommand
.
Flags
()
.
StringVar
(
&
insp
.
version
,
verflag
,
""
,
verdesc
)
for
_
,
subCmd
:=
range
cmds
{
valuesS
ubCmd
.
Flags
()
.
StringVar
(
&
insp
.
version
,
verflag
,
""
,
verdesc
)
s
ubCmd
.
Flags
()
.
StringVar
(
&
insp
.
version
,
verflag
,
""
,
verdesc
)
chartSubCmd
.
Flags
()
.
StringVar
(
&
insp
.
version
,
verflag
,
""
,
verdesc
)
}
repoURL
:=
"repo"
repoURL
:=
"repo"
repoURLdesc
:=
"chart repository url where to locate the requested chart"
repoURLdesc
:=
"chart repository url where to locate the requested chart"
inspectCommand
.
Flags
()
.
StringVar
(
&
insp
.
repoURL
,
repoURL
,
""
,
repoURLdesc
)
for
_
,
subCmd
:=
range
cmds
{
valuesS
ubCmd
.
Flags
()
.
StringVar
(
&
insp
.
repoURL
,
repoURL
,
""
,
repoURLdesc
)
s
ubCmd
.
Flags
()
.
StringVar
(
&
insp
.
repoURL
,
repoURL
,
""
,
repoURLdesc
)
chartSubCmd
.
Flags
()
.
StringVar
(
&
insp
.
repoURL
,
repoURL
,
""
,
repoURLdesc
)
}
certFile
:=
"cert-file"
certFile
:=
"cert-file"
certFiledesc
:=
"verify certificates of HTTPS-enabled servers using this CA bundle"
certFiledesc
:=
"verify certificates of HTTPS-enabled servers using this CA bundle"
inspectCommand
.
Flags
()
.
StringVar
(
&
insp
.
certFile
,
certFile
,
""
,
certFiledesc
)
for
_
,
subCmd
:=
range
cmds
{
valuesS
ubCmd
.
Flags
()
.
StringVar
(
&
insp
.
certFile
,
certFile
,
""
,
certFiledesc
)
s
ubCmd
.
Flags
()
.
StringVar
(
&
insp
.
certFile
,
certFile
,
""
,
certFiledesc
)
chartSubCmd
.
Flags
()
.
StringVar
(
&
insp
.
certFile
,
certFile
,
""
,
certFiledesc
)
}
keyFile
:=
"key-file"
keyFile
:=
"key-file"
keyFiledesc
:=
"identify HTTPS client using this SSL key file"
keyFiledesc
:=
"identify HTTPS client using this SSL key file"
inspectCommand
.
Flags
()
.
StringVar
(
&
insp
.
keyFile
,
keyFile
,
""
,
keyFiledesc
)
for
_
,
subCmd
:=
range
cmds
{
valuesS
ubCmd
.
Flags
()
.
StringVar
(
&
insp
.
keyFile
,
keyFile
,
""
,
keyFiledesc
)
s
ubCmd
.
Flags
()
.
StringVar
(
&
insp
.
keyFile
,
keyFile
,
""
,
keyFiledesc
)
chartSubCmd
.
Flags
()
.
StringVar
(
&
insp
.
keyFile
,
keyFile
,
""
,
keyFiledesc
)
}
caFile
:=
"ca-file"
caFile
:=
"ca-file"
caFiledesc
:=
"chart repository url where to locate the requested chart"
caFiledesc
:=
"chart repository url where to locate the requested chart"
inspectCommand
.
Flags
()
.
StringVar
(
&
insp
.
caFile
,
caFile
,
""
,
caFiledesc
)
for
_
,
subCmd
:=
range
cmds
{
valuesS
ubCmd
.
Flags
()
.
StringVar
(
&
insp
.
caFile
,
caFile
,
""
,
caFiledesc
)
s
ubCmd
.
Flags
()
.
StringVar
(
&
insp
.
caFile
,
caFile
,
""
,
caFiledesc
)
chartSubCmd
.
Flags
()
.
StringVar
(
&
insp
.
caFile
,
caFile
,
""
,
caFiledesc
)
}
inspectCommand
.
AddCommand
(
valuesSubCmd
)
for
_
,
subCmd
:=
range
cmds
[
1
:
]
{
inspectCommand
.
AddCommand
(
chartSubCmd
)
inspectCommand
.
AddCommand
(
subCmd
)
}
return
inspectCommand
return
inspectCommand
}
}
...
@@ -184,16 +216,35 @@ func (i *inspectCmd) run() error {
...
@@ -184,16 +216,35 @@ func (i *inspectCmd) run() error {
return
err
return
err
}
}
if
i
.
output
==
chartOnly
||
i
.
output
==
both
{
if
i
.
output
==
chartOnly
||
i
.
output
==
all
{
fmt
.
Fprintln
(
i
.
out
,
string
(
cf
))
fmt
.
Fprintln
(
i
.
out
,
string
(
cf
))
}
}
if
(
i
.
output
==
valuesOnly
||
i
.
output
==
both
)
&&
chrt
.
Values
!=
nil
{
if
(
i
.
output
==
valuesOnly
||
i
.
output
==
all
)
&&
chrt
.
Values
!=
nil
{
if
i
.
output
==
both
{
if
i
.
output
==
all
{
fmt
.
Fprintln
(
i
.
out
,
"---"
)
fmt
.
Fprintln
(
i
.
out
,
"---"
)
}
}
fmt
.
Fprintln
(
i
.
out
,
chrt
.
Values
.
Raw
)
fmt
.
Fprintln
(
i
.
out
,
chrt
.
Values
.
Raw
)
}
}
if
i
.
output
==
readmeOnly
||
i
.
output
==
all
{
if
i
.
output
==
all
{
fmt
.
Fprintln
(
i
.
out
,
"---"
)
}
readme
:=
findReadme
(
chrt
.
Files
)
if
readme
==
nil
{
return
nil
}
fmt
.
Fprintln
(
i
.
out
,
string
(
readme
.
Value
))
}
return
nil
}
func
findReadme
(
files
[]
*
any
.
Any
)
(
file
*
any
.
Any
)
{
for
_
,
file
:=
range
files
{
if
slice
.
ContainsString
(
readmeFileNames
,
strings
.
ToLower
(
file
.
TypeUrl
),
nil
)
{
return
file
}
}
return
nil
return
nil
}
}
cmd/helm/inspect_test.go
View file @
36252410
...
@@ -28,7 +28,7 @@ func TestInspect(t *testing.T) {
...
@@ -28,7 +28,7 @@ func TestInspect(t *testing.T) {
insp
:=
&
inspectCmd
{
insp
:=
&
inspectCmd
{
chartpath
:
"testdata/testcharts/alpine"
,
chartpath
:
"testdata/testcharts/alpine"
,
output
:
"both"
,
output
:
all
,
out
:
b
,
out
:
b
,
}
}
insp
.
run
()
insp
.
run
()
...
@@ -42,15 +42,19 @@ func TestInspect(t *testing.T) {
...
@@ -42,15 +42,19 @@ func TestInspect(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
readmeData
,
err
:=
ioutil
.
ReadFile
(
"testdata/testcharts/alpine/README.md"
)
parts
:=
strings
.
SplitN
(
b
.
String
(),
"---"
,
2
)
if
err
!=
nil
{
if
len
(
parts
)
!=
2
{
t
.
Fatal
(
err
)
}
parts
:=
strings
.
SplitN
(
b
.
String
(),
"---"
,
3
)
if
len
(
parts
)
!=
3
{
t
.
Fatalf
(
"Expected 2 parts, got %d"
,
len
(
parts
))
t
.
Fatalf
(
"Expected 2 parts, got %d"
,
len
(
parts
))
}
}
expect
:=
[]
string
{
expect
:=
[]
string
{
strings
.
Replace
(
strings
.
TrimSpace
(
string
(
cdata
)),
"
\r
"
,
""
,
-
1
),
strings
.
Replace
(
strings
.
TrimSpace
(
string
(
cdata
)),
"
\r
"
,
""
,
-
1
),
strings
.
Replace
(
strings
.
TrimSpace
(
string
(
data
)),
"
\r
"
,
""
,
-
1
),
strings
.
Replace
(
strings
.
TrimSpace
(
string
(
data
)),
"
\r
"
,
""
,
-
1
),
strings
.
Replace
(
strings
.
TrimSpace
(
string
(
readmeData
)),
"
\r
"
,
""
,
-
1
),
}
}
// Problem: ghodss/yaml doesn't marshal into struct order. To solve, we
// Problem: ghodss/yaml doesn't marshal into struct order. To solve, we
...
@@ -73,5 +77,4 @@ func TestInspect(t *testing.T) {
...
@@ -73,5 +77,4 @@ func TestInspect(t *testing.T) {
if
b
.
Len
()
!=
0
{
if
b
.
Len
()
!=
0
{
t
.
Errorf
(
"expected empty values buffer, got %q"
,
b
.
String
())
t
.
Errorf
(
"expected empty values buffer, got %q"
,
b
.
String
())
}
}
}
}
docs/helm/helm.md
View file @
36252410
...
@@ -68,4 +68,4 @@ Environment:
...
@@ -68,4 +68,4 @@ Environment:
*
[
helm verify
](
helm_verify.md
)
- verify that a chart at the given path has been signed and is valid
*
[
helm verify
](
helm_verify.md
)
- verify that a chart at the given path has been signed and is valid
*
[
helm version
](
helm_version.md
)
- print the client/server version information
*
[
helm version
](
helm_version.md
)
- print the client/server version information
###### Auto generated by spf13/cobra on
8
-Mar-2018
###### Auto generated by spf13/cobra on
14
-Mar-2018
docs/helm/helm_inspect.md
View file @
36252410
...
@@ -42,6 +42,7 @@ helm inspect [CHART]
...
@@ -42,6 +42,7 @@ helm inspect [CHART]
### SEE ALSO
### SEE ALSO
*
[
helm
](
helm.md
)
- The Helm package manager for Kubernetes.
*
[
helm
](
helm.md
)
- The Helm package manager for Kubernetes.
*
[
helm inspect chart
](
helm_inspect_chart.md
)
- shows inspect chart
*
[
helm inspect chart
](
helm_inspect_chart.md
)
- shows inspect chart
*
[
helm inspect readme
](
helm_inspect_readme.md
)
- shows inspect readme
*
[
helm inspect values
](
helm_inspect_values.md
)
- shows inspect values
*
[
helm inspect values
](
helm_inspect_values.md
)
- shows inspect values
###### Auto generated by spf13/cobra on
8
-Mar-2018
###### Auto generated by spf13/cobra on
14
-Mar-2018
docs/helm/helm_inspect_readme.md
0 → 100644
View file @
36252410
## helm inspect readme
shows inspect readme
### Synopsis
This command inspects a chart (directory, file, or URL) and displays the contents
of the README file
```
helm inspect readme [CHART]
```
### Options
```
--ca-file string chart repository url where to locate the requested chart
--cert-file string verify certificates of HTTPS-enabled servers using this CA bundle
--key-file string identify HTTPS client using this SSL key file
--keyring string path to the keyring containing public verification keys (default "~/.gnupg/pubring.gpg")
--repo string chart repository url where to locate the requested chart
--verify verify the provenance data for this chart
--version string version of the chart. By default, the newest chart is shown
```
### Options inherited from parent commands
```
--debug enable verbose output
--home string location of your Helm config. Overrides $HELM_HOME (default "~/.helm")
--host string address of Tiller. Overrides $HELM_HOST
--kube-context string name of the kubeconfig context to use
--tiller-connection-timeout int the duration (in seconds) Helm will wait to establish a connection to tiller (default 300)
--tiller-namespace string namespace of Tiller (default "kube-system")
```
### SEE ALSO
*
[
helm inspect
](
helm_inspect.md
)
- inspect a chart
###### Auto generated by spf13/cobra on 14-Mar-2018
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