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
6707fe04
Unverified
Commit
6707fe04
authored
Dec 13, 2017
by
Matthew Fisher
Committed by
GitHub
Dec 13, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3190 from mattfarina/feat/status-json
feat(status): Optional output as JSON and YAML
parents
1042f611
9d4b9ca2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
1 deletion
+45
-1
status.go
cmd/helm/status.go
+23
-0
status_test.go
cmd/helm/status_test.go
+20
-0
helm_status.md
docs/helm/helm_status.md
+2
-1
No files found.
cmd/helm/status.go
View file @
6707fe04
...
...
@@ -17,11 +17,13 @@ limitations under the License.
package
main
import
(
"encoding/json"
"fmt"
"io"
"regexp"
"text/tabwriter"
"github.com/ghodss/yaml"
"github.com/gosuri/uitable"
"github.com/gosuri/uitable/util/strutil"
"github.com/spf13/cobra"
...
...
@@ -48,6 +50,7 @@ type statusCmd struct {
out
io
.
Writer
client
helm
.
Interface
version
int32
outfmt
string
}
func
newStatusCmd
(
client
helm
.
Interface
,
out
io
.
Writer
)
*
cobra
.
Command
{
...
...
@@ -74,6 +77,7 @@ func newStatusCmd(client helm.Interface, out io.Writer) *cobra.Command {
}
cmd
.
PersistentFlags
()
.
Int32Var
(
&
status
.
version
,
"revision"
,
0
,
"if set, display the status of the named release with revision"
)
cmd
.
PersistentFlags
()
.
StringVarP
(
&
status
.
outfmt
,
"output"
,
"o"
,
""
,
"output the status in the specified format (json or yaml)"
)
return
cmd
}
...
...
@@ -84,8 +88,27 @@ func (s *statusCmd) run() error {
return
prettyError
(
err
)
}
switch
s
.
outfmt
{
case
""
:
PrintStatus
(
s
.
out
,
res
)
return
nil
case
"json"
:
data
,
err
:=
json
.
Marshal
(
res
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Failed to Marshal JSON output: %s"
,
err
)
}
s
.
out
.
Write
(
data
)
return
nil
case
"yaml"
:
data
,
err
:=
yaml
.
Marshal
(
res
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Failed to Marshal YAML output: %s"
,
err
)
}
s
.
out
.
Write
(
data
)
return
nil
}
return
fmt
.
Errorf
(
"Unknown output format %q"
,
s
.
outfmt
)
}
// PrintStatus prints out the status of a release. Shared because also used by
...
...
cmd/helm/status_test.go
View file @
6707fe04
...
...
@@ -65,6 +65,16 @@ func TestStatusCmd(t *testing.T) {
Notes
:
"release notes"
,
}),
},
{
name
:
"get status of a deployed release with notes in json"
,
args
:
[]
string
{
"flummoxed-chickadee"
},
flags
:
[]
string
{
"-o"
,
"json"
},
expected
:
`{"name":"flummoxed-chickadee","info":{"status":{"code":1,"notes":"release notes"},"first_deployed":{"seconds":242085845},"last_deployed":{"seconds":242085845}}}`
,
rel
:
releaseMockWithStatus
(
&
release
.
Status
{
Code
:
release
.
Status_DEPLOYED
,
Notes
:
"release notes"
,
}),
},
{
name
:
"get status of a deployed release with resources"
,
args
:
[]
string
{
"flummoxed-chickadee"
},
...
...
@@ -74,6 +84,16 @@ func TestStatusCmd(t *testing.T) {
Resources
:
"resource A
\n
resource B
\n
"
,
}),
},
{
name
:
"get status of a deployed release with resources in YAML"
,
args
:
[]
string
{
"flummoxed-chickadee"
},
flags
:
[]
string
{
"-o"
,
"yaml"
},
expected
:
"info:
\n
first_deployed:
\n
seconds:242085845
\n
last_deployed:
\n
seconds:242085845
\n
status:
\n
code:1
\n
resources:|
\n
resourceA
\n
resourceB
\n
name:flummoxed-chickadee
\n
"
,
rel
:
releaseMockWithStatus
(
&
release
.
Status
{
Code
:
release
.
Status_DEPLOYED
,
Resources
:
"resource A
\n
resource B
\n
"
,
}),
},
{
name
:
"get status of a deployed release with test suite"
,
args
:
[]
string
{
"flummoxed-chickadee"
},
...
...
docs/helm/helm_status.md
View file @
6707fe04
...
...
@@ -23,6 +23,7 @@ helm status [flags] RELEASE_NAME
### Options
```
-o, --output string output the status in the specified format (json or yaml)
--revision int32 if set, display the status of the named release with revision
--tls enable TLS for request
--tls-ca-cert string path to TLS CA certificate file (default "$HELM_HOME/ca.pem")
...
...
@@ -45,4 +46,4 @@ helm status [flags] RELEASE_NAME
### SEE ALSO
*
[
helm
](
helm.md
)
- The Helm package manager for Kubernetes.
###### Auto generated by spf13/cobra on
7-Nov
-2017
###### Auto generated by spf13/cobra on
12-Dec
-2017
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