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
5e3044a6
Commit
5e3044a6
authored
Jun 30, 2016
by
Adam Reese
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ref(cmd): refactor get command
parent
e339cc7e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
53 deletions
+87
-53
get.go
cmd/helm/get.go
+86
-53
helm.go
cmd/helm/helm.go
+1
-0
No files found.
cmd/helm/get.go
View file @
5e3044a6
...
...
@@ -19,6 +19,7 @@ package main
import
(
"errors"
"fmt"
"io"
"time"
"github.com/spf13/cobra"
...
...
@@ -53,48 +54,88 @@ were generated from this release's chart(s). If a chart is dependent on other
charts, those resources will also be included in the manifest.
`
var
allValues
=
false
var
errReleaseRequired
=
errors
.
New
(
"release name is required"
)
var
getCommand
=
&
cobra
.
Command
{
Use
:
"get [flags] RELEASE_NAME"
,
Short
:
"download a named release"
,
Long
:
getHelp
,
RunE
:
getCmd
,
PersistentPreRunE
:
setupConnection
,
type
getCmd
struct
{
release
string
out
io
.
Writer
client
helm
.
Interface
}
var
getValuesCommand
=
&
cobra
.
Command
{
Use
:
"values [flags] RELEASE_NAME"
,
Short
:
"download the values file for a named release"
,
Long
:
getValuesHelp
,
RunE
:
getValues
,
func
newGetCmd
(
client
helm
.
Interface
,
out
io
.
Writer
)
*
cobra
.
Command
{
get
:=
&
getCmd
{
out
:
out
,
client
:
client
,
}
cmd
:=
&
cobra
.
Command
{
Use
:
"get [flags] RELEASE_NAME"
,
Short
:
"download a named release"
,
Long
:
getHelp
,
RunE
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
if
len
(
args
)
==
0
{
return
errReleaseRequired
}
get
.
release
=
args
[
0
]
return
get
.
run
()
},
PersistentPreRunE
:
setupConnection
,
}
cmd
.
AddCommand
(
newGetValuesCmd
(
client
,
out
))
cmd
.
AddCommand
(
newGetManifestCmd
(
client
,
out
))
return
cmd
}
var
getManifestCommand
=
&
cobra
.
Command
{
Use
:
"manifest [flags] RELEASE_NAME"
,
Short
:
"download the manifest for a named release"
,
Long
:
getManifestHelp
,
RunE
:
getManifest
,
type
getValuesCmd
struct
{
allValues
bool
getCmd
}
func
init
()
{
// 'get values' flags.
getValuesCommand
.
PersistentFlags
()
.
BoolVarP
(
&
allValues
,
"all"
,
"a"
,
false
,
"dump all (computed) values"
)
func
newGetValuesCmd
(
client
helm
.
Interface
,
out
io
.
Writer
)
*
cobra
.
Command
{
get
:=
&
getValuesCmd
{}
get
.
out
=
out
get
.
client
=
client
cmd
:=
&
cobra
.
Command
{
Use
:
"values [flags] RELEASE_NAME"
,
Short
:
"download the values file for a named release"
,
Long
:
getValuesHelp
,
RunE
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
if
len
(
args
)
==
0
{
return
errReleaseRequired
}
get
.
release
=
args
[
0
]
return
get
.
run
()
},
}
cmd
.
Flags
()
.
BoolVarP
(
&
get
.
allValues
,
"all"
,
"a"
,
false
,
"dump all (computed) values"
)
return
cmd
}
getCommand
.
AddCommand
(
getValuesCommand
)
getCommand
.
AddCommand
(
getManifestCommand
)
RootCommand
.
AddCommand
(
getCommand
)
type
getManifestCmd
struct
{
getCmd
}
// getCmd is the command that implements 'helm get'
func
getCmd
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
if
len
(
args
)
==
0
{
return
errReleaseRequired
func
newGetManifestCmd
(
client
helm
.
Interface
,
out
io
.
Writer
)
*
cobra
.
Command
{
get
:=
&
getManifestCmd
{}
get
.
out
=
out
get
.
client
=
client
cmd
:=
&
cobra
.
Command
{
Use
:
"manifest [flags] RELEASE_NAME"
,
Short
:
"download the manifest for a named release"
,
Long
:
getManifestHelp
,
RunE
:
func
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
if
len
(
args
)
==
0
{
return
errReleaseRequired
}
get
.
release
=
args
[
0
]
return
get
.
run
()
},
}
return
cmd
}
res
,
err
:=
helm
.
GetReleaseContent
(
args
[
0
])
// getCmd is the command that implements 'helm get'
func
(
g
*
getCmd
)
run
()
error
{
res
,
err
:=
helm
.
GetReleaseContent
(
g
.
release
)
if
err
!=
nil
{
return
prettyError
(
err
)
}
...
...
@@ -108,30 +149,26 @@ func getCmd(cmd *cobra.Command, args []string) error {
return
err
}
fmt
.
Printf
(
"CHART: %s-%s
\n
"
,
res
.
Release
.
Chart
.
Metadata
.
Name
,
res
.
Release
.
Chart
.
Metadata
.
Version
)
fmt
.
Printf
(
"RELEASED: %s
\n
"
,
timeconv
.
Format
(
res
.
Release
.
Info
.
LastDeployed
,
time
.
ANSIC
))
fmt
.
Println
(
"USER-SUPPLIED VALUES:"
)
fmt
.
Println
(
res
.
Release
.
Config
.
Raw
)
fmt
.
Println
(
"COMPUTED VALUES:"
)
fmt
.
Println
(
cfgStr
)
fmt
.
Println
(
"MANIFEST:"
)
fmt
.
Println
(
res
.
Release
.
Manifest
)
fmt
.
Fprintf
(
g
.
out
,
"CHART: %s-%s
\n
"
,
res
.
Release
.
Chart
.
Metadata
.
Name
,
res
.
Release
.
Chart
.
Metadata
.
Version
)
fmt
.
Fprintf
(
g
.
out
,
"RELEASED: %s
\n
"
,
timeconv
.
Format
(
res
.
Release
.
Info
.
LastDeployed
,
time
.
ANSIC
))
fmt
.
Fprintln
(
g
.
out
,
"USER-SUPPLIED VALUES:"
)
fmt
.
Fprintln
(
g
.
out
,
res
.
Release
.
Config
.
Raw
)
fmt
.
Fprintln
(
g
.
out
,
"COMPUTED VALUES:"
)
fmt
.
Fprintln
(
g
.
out
,
cfgStr
)
fmt
.
Fprintln
(
g
.
out
,
"MANIFEST:"
)
fmt
.
Fprintln
(
g
.
out
,
res
.
Release
.
Manifest
)
return
nil
}
// getValues implements 'helm get values'
func
getValues
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
if
len
(
args
)
==
0
{
return
errReleaseRequired
}
res
,
err
:=
helm
.
GetReleaseContent
(
args
[
0
])
func
(
g
*
getValuesCmd
)
run
()
error
{
res
,
err
:=
helm
.
GetReleaseContent
(
g
.
release
)
if
err
!=
nil
{
return
prettyError
(
err
)
}
// If the user wants all values, compute the values and return.
if
allValues
{
if
g
.
allValues
{
cfg
,
err
:=
chartutil
.
CoalesceValues
(
res
.
Release
.
Chart
,
res
.
Release
.
Config
,
nil
)
if
err
!=
nil
{
return
err
...
...
@@ -140,24 +177,20 @@ func getValues(cmd *cobra.Command, args []string) error {
if
err
!=
nil
{
return
err
}
fmt
.
Println
(
cfgStr
)
fmt
.
Fprintln
(
g
.
out
,
cfgStr
)
return
nil
}
fmt
.
Println
(
res
.
Release
.
Config
.
Raw
)
fmt
.
Fprintln
(
g
.
out
,
res
.
Release
.
Config
.
Raw
)
return
nil
}
// getManifest implements 'helm get manifest'
func
getManifest
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
if
len
(
args
)
==
0
{
return
errReleaseRequired
}
res
,
err
:=
helm
.
GetReleaseContent
(
args
[
0
])
func
(
g
*
getManifestCmd
)
run
()
error
{
res
,
err
:=
helm
.
GetReleaseContent
(
g
.
release
)
if
err
!=
nil
{
return
prettyError
(
err
)
}
fmt
.
Println
(
res
.
Release
.
Manifest
)
fmt
.
Fprintln
(
g
.
out
,
res
.
Release
.
Manifest
)
return
nil
}
cmd/helm/helm.go
View file @
5e3044a6
...
...
@@ -86,6 +86,7 @@ func newRootCmd(out io.Writer) *cobra.Command {
p
.
BoolVarP
(
&
flagDebug
,
"debug"
,
""
,
false
,
"enable verbose output"
)
cmd
.
AddCommand
(
newListCmd
(
nil
,
out
))
cmd
.
AddCommand
(
newGetCmd
(
nil
,
out
))
return
cmd
}
...
...
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