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
7530a84b
Commit
7530a84b
authored
May 02, 2016
by
Matt Butcher
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #620 from technosophos/feat/helm-get-values
feat(helm): add 'get values', 'get manifest'
parents
48e80e7b
bdedb38d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
0 deletions
+78
-0
get.go
cmd/helm/get.go
+78
-0
No files found.
cmd/helm/get.go
View file @
7530a84b
...
@@ -3,6 +3,7 @@ package main
...
@@ -3,6 +3,7 @@ package main
import
(
import
(
"errors"
"errors"
"fmt"
"fmt"
"os"
"github.com/kubernetes/helm/pkg/helm"
"github.com/kubernetes/helm/pkg/helm"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
...
@@ -21,6 +22,25 @@ By default, this prints a human readable collection of information about the
...
@@ -21,6 +22,25 @@ By default, this prints a human readable collection of information about the
chart, the supplied values, and the generated manifest file.
chart, the supplied values, and the generated manifest file.
`
`
var
getValuesHelp
=
`
This command downloads a values file for a given release.
To save the output to a file, use the -f flag.
`
var
getManifestHelp
=
`
This command fetches the generated manifest for a given release.
A manifest is a YAML-encoded representation of the Kubernetes resources that
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.
`
// getOut is the filename to direct output.
//
// If it is blank, output is sent to os.Stdout.
var
getOut
=
""
var
errReleaseRequired
=
errors
.
New
(
"release name is required"
)
var
errReleaseRequired
=
errors
.
New
(
"release name is required"
)
var
getCommand
=
&
cobra
.
Command
{
var
getCommand
=
&
cobra
.
Command
{
...
@@ -30,10 +50,28 @@ var getCommand = &cobra.Command{
...
@@ -30,10 +50,28 @@ var getCommand = &cobra.Command{
RunE
:
getCmd
,
RunE
:
getCmd
,
}
}
var
getValuesCommand
=
&
cobra
.
Command
{
Use
:
"values [flags] RELEASE_NAME"
,
Short
:
"Download the values file for a named release"
,
Long
:
getValuesHelp
,
RunE
:
getValues
,
}
var
getManifestCommand
=
&
cobra
.
Command
{
Use
:
"manifest [flags] RELEASE_NAME"
,
Short
:
"Download the manifest for a named release"
,
Long
:
getManifestHelp
,
RunE
:
getManifest
,
}
func
init
()
{
func
init
()
{
getCommand
.
PersistentFlags
()
.
StringVarP
(
&
getOut
,
"file"
,
"f"
,
""
,
"output file"
)
getCommand
.
AddCommand
(
getValuesCommand
)
getCommand
.
AddCommand
(
getManifestCommand
)
RootCommand
.
AddCommand
(
getCommand
)
RootCommand
.
AddCommand
(
getCommand
)
}
}
// getCmd is the command that implements 'helm get'
func
getCmd
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
func
getCmd
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
if
len
(
args
)
==
0
{
if
len
(
args
)
==
0
{
return
errReleaseRequired
return
errReleaseRequired
...
@@ -51,3 +89,43 @@ func getCmd(cmd *cobra.Command, args []string) error {
...
@@ -51,3 +89,43 @@ func getCmd(cmd *cobra.Command, args []string) error {
fmt
.
Println
(
res
.
Release
.
Manifest
)
fmt
.
Println
(
res
.
Release
.
Manifest
)
return
nil
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
])
if
err
!=
nil
{
return
err
}
return
getToFile
(
res
.
Release
.
Config
)
}
// 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
])
if
err
!=
nil
{
return
err
}
return
getToFile
(
res
.
Release
.
Manifest
)
}
func
getToFile
(
v
interface
{})
error
{
out
:=
os
.
Stdout
if
len
(
getOut
)
>
0
{
t
,
err
:=
os
.
Create
(
getOut
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to create %s: %s"
,
getOut
,
err
)
}
defer
t
.
Close
()
out
=
t
}
fmt
.
Fprintln
(
out
,
v
)
return
nil
}
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