Commit 6950fe42 authored by Matt Butcher's avatar Matt Butcher

feat(helm, tiller): add release listings

This adds client and server support for 'helm list'.
parent 2c71fb9f
......@@ -54,12 +54,13 @@ func runInstall(cmd *cobra.Command, args []string) error {
// Might be friendly to wrap our proto model with pretty-printers.
//
func printRelease(rel *release.Release) {
if rel == nil {
return
}
fmt.Printf("release.name: %s\n", rel.Name)
if verbose {
if rel != nil {
fmt.Printf("release.name: %s\n", rel.Name)
fmt.Printf("release.info: %s\n", rel.GetInfo())
fmt.Printf("release.chart: %s\n", rel.GetChart())
}
fmt.Printf("release.info: %s\n", rel.GetInfo())
fmt.Printf("release.chart: %s\n", rel.GetChart())
}
}
......
package main
import (
"fmt"
"github.com/kubernetes/helm/pkg/helm"
"github.com/kubernetes/helm/pkg/proto/hapi/release"
"github.com/spf13/cobra"
)
var listHelp = `
This command lists all of the currently deployed releases.
By default, items are sorted alphabetically.
`
var listCommand = &cobra.Command{
Use: "list [flags] [FILTER]",
Short: "List releases",
Long: listHelp,
RunE: listCmd,
}
var listLong bool
var listMax int
func init() {
listCommand.LocalFlags().BoolVar(&listLong, "l", false, "output long listing format")
listCommand.LocalFlags().IntVar(&listMax, "m", 256, "maximum number of releases to fetch")
RootCommand.AddCommand(listCommand)
}
func listCmd(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
fmt.Println("TODO: Implement filter.")
}
res, err := helm.ListReleases(listMax, 0)
if err != nil {
return err
}
rels := res.Releases
if res.Count+res.Offset < res.Total {
fmt.Println("Not all values were fetched.")
}
// TODO: Add sort here.
// Purty output, ya'll
if listLong {
return formatList(rels)
}
for _, r := range rels {
fmt.Println(r.Name)
}
return nil
}
func formatList(rels []*release.Release) error {
// TODO: Pretty it up
for _, r := range rels {
fmt.Println(r.Name)
}
return nil
}
......@@ -34,7 +34,21 @@ var (
)
func (s *releaseServer) ListReleases(req *services.ListReleasesRequest, stream services.ReleaseService_ListReleasesServer) error {
return errNotImplemented
rels, err := s.env.Releases.List()
if err != nil {
return err
}
l := int64(len(rels))
res := &services.ListReleasesResponse{
Offset: 0,
Count: l,
Total: l,
Releases: rels,
}
stream.Send(res)
return nil
}
func (s *releaseServer) GetReleaseStatus(c ctx.Context, req *services.GetReleaseStatusRequest) (*services.GetReleaseStatusResponse, error) {
......
name: alpine
description: Deploy a basic Alpine Linux pod
version: 0.1.0
home: "https://github.com/kubernetes/helm"
home: https://github.com/kubernetes/helm
......@@ -13,8 +13,20 @@ var Config = &config{
}
// ListReleases lists the current releases.
func ListReleases(limit, offset int) (<-chan *services.ListReleasesResponse, error) {
return nil, ErrNotImplemented
func ListReleases(limit, offset int) (*services.ListReleasesResponse, error) {
c := Config.client()
if err := c.dial(); err != nil {
return nil, err
}
defer c.Close()
req := &services.ListReleasesRequest{}
cli, err := c.impl.ListReleases(context.TODO(), req, c.cfg.CallOpts()...)
if err != nil {
return nil, err
}
return cli.Recv()
}
// GetReleaseStatus returns the given release's status.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment