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
0f89b08e
Commit
0f89b08e
authored
May 10, 2016
by
Matt Butcher
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #683 from technosophos/fix/668-client-error-fmt
fix(helm): fix error formatting
parents
9fecf748
463c7e25
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
26 deletions
+31
-26
delete.go
cmd/helm/delete.go
+2
-2
get.go
cmd/helm/get.go
+3
-3
helm.go
cmd/helm/helm.go
+13
-1
install.go
cmd/helm/install.go
+11
-18
list.go
cmd/helm/list.go
+1
-1
status.go
cmd/helm/status.go
+1
-1
No files found.
cmd/helm/delete.go
View file @
0f89b08e
...
...
@@ -34,7 +34,7 @@ func init() {
func
delRelease
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
if
len
(
args
)
==
0
{
return
errors
.
New
(
"
Command 'delete' requires a release name.
"
)
return
errors
.
New
(
"
command 'delete' requires a release name
"
)
}
// TODO: Handle dry run use case.
...
...
@@ -45,7 +45,7 @@ func delRelease(cmd *cobra.Command, args []string) error {
_
,
err
:=
helm
.
UninstallRelease
(
args
[
0
])
if
err
!=
nil
{
return
err
return
prettyError
(
err
)
}
return
nil
...
...
cmd/helm/get.go
View file @
0f89b08e
...
...
@@ -81,7 +81,7 @@ func getCmd(cmd *cobra.Command, args []string) error {
res
,
err
:=
helm
.
GetReleaseContent
(
args
[
0
])
if
err
!=
nil
{
return
err
return
prettyError
(
err
)
}
fmt
.
Printf
(
"CHART: %s-%s
\n
"
,
res
.
Release
.
Chart
.
Metadata
.
Name
,
res
.
Release
.
Chart
.
Metadata
.
Version
)
...
...
@@ -101,7 +101,7 @@ func getValues(cmd *cobra.Command, args []string) error {
res
,
err
:=
helm
.
GetReleaseContent
(
args
[
0
])
if
err
!=
nil
{
return
err
return
prettyError
(
err
)
}
return
getToFile
(
res
.
Release
.
Config
)
}
...
...
@@ -114,7 +114,7 @@ func getManifest(cmd *cobra.Command, args []string) error {
res
,
err
:=
helm
.
GetReleaseContent
(
args
[
0
])
if
err
!=
nil
{
return
err
return
prettyError
(
err
)
}
return
getToFile
(
res
.
Release
.
Manifest
)
}
...
...
cmd/helm/helm.go
View file @
0f89b08e
package
main
import
(
"errors"
"fmt"
"os"
"strings"
"github.com/spf13/cobra"
"google.golang.org/grpc"
)
var
stdout
=
os
.
Stdout
...
...
@@ -48,7 +50,9 @@ func init() {
}
func
main
()
{
RootCommand
.
Execute
()
if
err
:=
RootCommand
.
Execute
();
err
!=
nil
{
os
.
Exit
(
1
)
}
}
func
checkArgsLength
(
expectedNum
,
actualNum
int
,
requiredArgs
...
string
)
error
{
...
...
@@ -61,3 +65,11 @@ func checkArgsLength(expectedNum, actualNum int, requiredArgs ...string) error {
}
return
nil
}
// prettyError unwraps or rewrites certain errors to make them more user-friendly.
func
prettyError
(
err
error
)
error
{
// This is ridiculous. Why is 'grpc.rpcError' not exported? The least they
// could do is throw an interface on the lib that would let us get back
// the desc. Instead, we have to pass ALL errors through this.
return
errors
.
New
(
grpc
.
ErrorDesc
(
err
))
}
cmd/helm/install.go
View file @
0f89b08e
...
...
@@ -42,11 +42,15 @@ var installCmd = &cobra.Command{
}
func
runInstall
(
cmd
*
cobra
.
Command
,
args
[]
string
)
error
{
setupInstallEnv
(
args
)
if
err
:=
checkArgsLength
(
1
,
len
(
args
),
"chart name"
);
err
!=
nil
{
return
err
}
installArg
=
args
[
0
]
setupInstallEnv
()
res
,
err
:=
helm
.
InstallRelease
(
installArg
,
installDryRun
)
if
err
!=
nil
{
return
err
return
prettyError
(
err
)
}
printRelease
(
res
.
GetRelease
())
...
...
@@ -54,9 +58,6 @@ func runInstall(cmd *cobra.Command, args []string) error {
return
nil
}
// TODO -- Display formatted description of install release status / info.
// Might be friendly to wrap our proto model with pretty-printers.
//
func
printRelease
(
rel
*
release
.
Release
)
{
if
rel
==
nil
{
return
...
...
@@ -71,16 +72,13 @@ func printRelease(rel *release.Release) {
}
}
func
setupInstallEnv
(
args
[]
string
)
{
if
len
(
args
)
>
0
{
installArg
=
args
[
0
]
}
else
{
fatalf
(
"This command needs at least one argument, the name of the chart."
)
}
// note: TILLER_HOST envvar is only
func
setupInstallEnv
()
{
// note: TILLER_HOST envvar is
// acknowledged iff the host flag
// does not override the default.
//
// bug: except that if the host flag happens to set the host to the same
// value as the defaultHost, the env var will be used instead.
if
tillerHost
==
defaultHost
{
host
:=
os
.
Getenv
(
hostEnvVar
)
if
host
!=
""
{
...
...
@@ -91,11 +89,6 @@ func setupInstallEnv(args []string) {
helm
.
Config
.
ServAddr
=
tillerHost
}
func
fatalf
(
format
string
,
args
...
interface
{})
{
fmt
.
Printf
(
"fatal: %s
\n
"
,
fmt
.
Sprintf
(
format
,
args
...
))
os
.
Exit
(
0
)
}
func
init
()
{
installCmd
.
Flags
()
.
StringVar
(
&
tillerHost
,
"host"
,
defaultHost
,
"address of tiller server"
)
installCmd
.
Flags
()
.
BoolVar
(
&
installDryRun
,
"dry-run"
,
false
,
"simulate an install"
)
...
...
cmd/helm/list.go
View file @
0f89b08e
...
...
@@ -47,7 +47,7 @@ func listCmd(cmd *cobra.Command, args []string) error {
res
,
err
:=
helm
.
ListReleases
(
listMax
,
listOffset
)
if
err
!=
nil
{
return
err
return
prettyError
(
err
)
}
rels
:=
res
.
Releases
...
...
cmd/helm/status.go
View file @
0f89b08e
...
...
@@ -30,7 +30,7 @@ func status(cmd *cobra.Command, args []string) error {
res
,
err
:=
helm
.
GetReleaseStatus
(
args
[
0
])
if
err
!=
nil
{
return
err
return
prettyError
(
err
)
}
fmt
.
Printf
(
"Last Deployed: %s
\n
"
,
timeconv
.
String
(
res
.
Info
.
LastDeployed
))
...
...
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