mirror of https://github.com/helm/helm
parent
fe0dcd2d39
commit
dd2ff4f916
@ -0,0 +1,53 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/deis/tiller/pkg/helm"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var getHelp = `
|
||||||
|
This command shows the details of a named release.
|
||||||
|
|
||||||
|
It can be used to get extended information about the release, including:
|
||||||
|
|
||||||
|
- The values used to generate the release
|
||||||
|
- The chart used to generate the release
|
||||||
|
- The generated manifest file
|
||||||
|
|
||||||
|
By default, this prints a human readable collection of information about the
|
||||||
|
chart, the supplied values, and the generated manifest file.
|
||||||
|
`
|
||||||
|
|
||||||
|
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,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
RootCommand.AddCommand(getCommand)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getCmd(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) == 0 {
|
||||||
|
return errReleaseRequired
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := helm.GetReleaseContent(args[0])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("Chart/Version: %s %s\n", res.Release.Chart.Metadata.Name, res.Release.Chart.Metadata.Version)
|
||||||
|
fmt.Println("Config:")
|
||||||
|
fmt.Println(res.Release.Config)
|
||||||
|
fmt.Println("\nManifest:")
|
||||||
|
fmt.Println(res.Release.Manifest)
|
||||||
|
return nil
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/deis/tiller/pkg/helm"
|
||||||
|
"github.com/deis/tiller/pkg/timeconv"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var statusHelp = `
|
||||||
|
This command shows the status of a named release.
|
||||||
|
`
|
||||||
|
|
||||||
|
var statusCommand = &cobra.Command{
|
||||||
|
Use: "status [flags] RELEASE_NAME",
|
||||||
|
Short: "Displays the status of the named release",
|
||||||
|
Long: statusHelp,
|
||||||
|
RunE: status,
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
RootCommand.AddCommand(statusCommand)
|
||||||
|
}
|
||||||
|
|
||||||
|
func status(cmd *cobra.Command, args []string) error {
|
||||||
|
if len(args) == 0 {
|
||||||
|
return errReleaseRequired
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := helm.GetReleaseStatus(args[0])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("Last Deployed: %s\n", timeconv.Format(res.Info.LastDeployed, time.ANSIC))
|
||||||
|
fmt.Printf("Status: %s\n", res.Info.Status.Code)
|
||||||
|
if res.Info.Status.Details != nil {
|
||||||
|
fmt.Printf("Details: %s\n", res.Info.Status.Details)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
/*Package timeconv contains utilities for converting time.
|
||||||
|
|
||||||
|
The gRPC/Protobuf libraries contain time implementations that require conversion
|
||||||
|
to and from Go times. This library provides utilities and convenience functions
|
||||||
|
for performing conversions.
|
||||||
|
*/
|
||||||
|
package timeconv
|
@ -0,0 +1,32 @@
|
|||||||
|
package timeconv
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/golang/protobuf/ptypes/timestamp"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Now creates a timestamp.Timestamp representing the current time.
|
||||||
|
func Now() *timestamp.Timestamp {
|
||||||
|
return Timestamp(time.Now())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Timestamp converts a time.Time to a protobuf *timestamp.Timestamp.
|
||||||
|
func Timestamp(t time.Time) *timestamp.Timestamp {
|
||||||
|
return ×tamp.Timestamp{
|
||||||
|
Seconds: t.Unix(),
|
||||||
|
Nanos: int32(t.Nanosecond()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Time converts a protobuf *timestamp.Timestamp to a time.Time.
|
||||||
|
func Time(ts *timestamp.Timestamp) time.Time {
|
||||||
|
return time.Unix(ts.Seconds, int64(ts.Nanos))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Format formats a *timestamp.Timestamp into a string.
|
||||||
|
//
|
||||||
|
// This follows the rules for time.Time.Format().
|
||||||
|
func Format(ts *timestamp.Timestamp, layout string) string {
|
||||||
|
return Time(ts).Format(layout)
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
package timeconv
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestNow(t *testing.T) {
|
||||||
|
now := time.Now()
|
||||||
|
ts := Now()
|
||||||
|
var drift int64 = 5
|
||||||
|
if ts.Seconds < int64(now.Second())-drift {
|
||||||
|
t.Errorf("Unexpected time drift: %d", ts.Seconds)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTimestamp(t *testing.T) {
|
||||||
|
now := time.Now()
|
||||||
|
ts := Timestamp(now)
|
||||||
|
|
||||||
|
if now.Unix() != ts.Seconds {
|
||||||
|
t.Errorf("Unexpected time drift: %d to %d", now.Second(), ts.Seconds)
|
||||||
|
}
|
||||||
|
|
||||||
|
if now.Nanosecond() != int(ts.Nanos) {
|
||||||
|
t.Errorf("Unexpected nano drift: %d to %d", now.Nanosecond(), ts.Nanos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestTime(t *testing.T) {
|
||||||
|
nowts := Now()
|
||||||
|
now := Time(nowts)
|
||||||
|
|
||||||
|
if now.Unix() != nowts.Seconds {
|
||||||
|
t.Errorf("Unexpected time drift %d", now.Unix())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFormat(t *testing.T) {
|
||||||
|
now := time.Now()
|
||||||
|
nowts := Timestamp(now)
|
||||||
|
|
||||||
|
if now.Format(time.ANSIC) != Format(nowts, time.ANSIC) {
|
||||||
|
t.Error("Format mismatch")
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue