Commit bb8fca9b authored by Matt Butcher's avatar Matt Butcher

Merge pull request #39 from technosophos/fix/storage-gofmt

fix(*): style fixes
parents 33a85a3a b708bde7
...@@ -15,13 +15,13 @@ var homeCommand = &cobra.Command{ ...@@ -15,13 +15,13 @@ var homeCommand = &cobra.Command{
Use: "home", Use: "home",
Short: "Displays the location of HELM_HOME", Short: "Displays the location of HELM_HOME",
Long: longHomeHelp, Long: longHomeHelp,
Run: Home, Run: home,
} }
func init() { func init() {
RootCommand.AddCommand(homeCommand) RootCommand.AddCommand(homeCommand)
} }
func Home(cmd *cobra.Command, args []string) { func home(cmd *cobra.Command, args []string) {
cmd.Printf(os.ExpandEnv(helmHome) + "\n") cmd.Printf(os.ExpandEnv(helmHome) + "\n")
} }
...@@ -32,16 +32,16 @@ var initCmd = &cobra.Command{ ...@@ -32,16 +32,16 @@ var initCmd = &cobra.Command{
Use: "init", Use: "init",
Short: "Initialize Helm on both client and server.", Short: "Initialize Helm on both client and server.",
Long: installDesc, Long: installDesc,
RunE: RunInit, RunE: runInit,
} }
// RunInit initializes local config and installs tiller to Kubernetes Cluster // runInit initializes local config and installs tiller to Kubernetes Cluster
func RunInit(cmd *cobra.Command, args []string) error { func runInit(cmd *cobra.Command, args []string) error {
if len(args) != 0 { if len(args) != 0 {
return errors.New("This command does not accept arguments. \n") return errors.New("This command does not accept arguments. \n")
} }
if err := EnsureHome(os.ExpandEnv(helmHome)); err != nil { if err := ensureHome(os.ExpandEnv(helmHome)); err != nil {
return err return err
} }
...@@ -75,11 +75,11 @@ func buildKubectlRunner(kubectlPath string) kubectl.Runner { ...@@ -75,11 +75,11 @@ func buildKubectlRunner(kubectlPath string) kubectl.Runner {
return &kubectl.RealRunner{} return &kubectl.RealRunner{}
} }
// EnsureHome checks to see if $HELM_HOME exists // ensureHome checks to see if $HELM_HOME exists
// //
// If $HELM_HOME does not exist, this function will create it. // If $HELM_HOME does not exist, this function will create it.
func EnsureHome(home string) error { func ensureHome(home string) error {
configDirectories := []string{home, CacheDirectory(home)} configDirectories := []string{home, cacheDirectory(home)}
for _, p := range configDirectories { for _, p := range configDirectories {
if fi, err := os.Stat(p); err != nil { if fi, err := os.Stat(p); err != nil {
...@@ -88,26 +88,26 @@ func EnsureHome(home string) error { ...@@ -88,26 +88,26 @@ func EnsureHome(home string) error {
return fmt.Errorf("Could not create %s: %s", p, err) return fmt.Errorf("Could not create %s: %s", p, err)
} }
} else if !fi.IsDir() { } else if !fi.IsDir() {
return fmt.Errorf("%s must be a directory.", p) return fmt.Errorf("%s must be a directory", p)
} }
} }
repoPath := RepositoriesFile(home) repoPath := repositoriesFile(home)
if fi, err := os.Stat(repoPath); err != nil { if fi, err := os.Stat(repoPath); err != nil {
fmt.Printf("Creating %s \n", repoPath) fmt.Printf("Creating %s \n", repoPath)
if err := ioutil.WriteFile(repoPath, []byte("test-charts: https://www.googleapis.com/storage/v1/b/test-charts/o\n"), 0644); err != nil { if err := ioutil.WriteFile(repoPath, []byte("test-charts: https://www.googleapis.com/storage/v1/b/test-charts/o\n"), 0644); err != nil {
return err return err
} }
} else if fi.IsDir() { } else if fi.IsDir() {
return fmt.Errorf("%s must be a file, not a directory.", repoPath) return fmt.Errorf("%s must be a file, not a directory", repoPath)
} }
return nil return nil
} }
func CacheDirectory(home string) string { func cacheDirectory(home string) string {
return filepath.Join(home, cachePath) return filepath.Join(home, cachePath)
} }
func RepositoriesFile(home string) string { func repositoriesFile(home string) string {
return filepath.Join(home, repositoriesPath) return filepath.Join(home, repositoriesPath)
} }
...@@ -7,12 +7,12 @@ import ( ...@@ -7,12 +7,12 @@ import (
) )
func TestEnsureHome(t *testing.T) { func TestEnsureHome(t *testing.T) {
home := CreateTmpHome() home := createTmpHome()
if err := EnsureHome(home); err != nil { if err := ensureHome(home); err != nil {
t.Errorf("%s", err) t.Errorf("%s", err)
} }
dirs := []string{home, CacheDirectory(home)} dirs := []string{home, cacheDirectory(home)}
for _, dir := range dirs { for _, dir := range dirs {
if fi, err := os.Stat(dir); err != nil { if fi, err := os.Stat(dir); err != nil {
t.Errorf("%s", err) t.Errorf("%s", err)
...@@ -21,7 +21,7 @@ func TestEnsureHome(t *testing.T) { ...@@ -21,7 +21,7 @@ func TestEnsureHome(t *testing.T) {
} }
} }
if fi, err := os.Stat(RepositoriesFile(home)); err != nil { if fi, err := os.Stat(repositoriesFile(home)); err != nil {
t.Errorf("%s", err) t.Errorf("%s", err)
} else if fi.IsDir() { } else if fi.IsDir() {
t.Errorf("%s should not be a directory", fi) t.Errorf("%s should not be a directory", fi)
...@@ -29,7 +29,7 @@ func TestEnsureHome(t *testing.T) { ...@@ -29,7 +29,7 @@ func TestEnsureHome(t *testing.T) {
} }
func CreateTmpHome() string { func createTmpHome() string {
tmpHome, _ := ioutil.TempDir("", "helm_home") tmpHome, _ := ioutil.TempDir("", "helm_home")
defer os.Remove(tmpHome) defer os.Remove(tmpHome)
return tmpHome return tmpHome
......
...@@ -13,7 +13,7 @@ import ( ...@@ -13,7 +13,7 @@ import (
// rootServer is the root gRPC server. // rootServer is the root gRPC server.
// //
// Each gRPC service registers itself to this server during init(). // Each gRPC service registers itself to this server during init().
var rootServer *grpc.Server = grpc.NewServer() var rootServer = grpc.NewServer()
var env = environment.New() var env = environment.New()
const globalUsage = `The Kubernetes Helm server. const globalUsage = `The Kubernetes Helm server.
......
...@@ -8,8 +8,10 @@ import ( ...@@ -8,8 +8,10 @@ import (
"github.com/BurntSushi/toml" "github.com/BurntSushi/toml"
) )
// ErrNoTable indicates that a chart does not have a matching table.
var ErrNoTable = errors.New("no table") var ErrNoTable = errors.New("no table")
// Values represents a collection of chart values.
type Values map[string]interface{} type Values map[string]interface{}
// Table gets a table (TOML subsection) from a Values object. // Table gets a table (TOML subsection) from a Values object.
......
//go:generate protoc -I ../../_proto ../../_proto/helm.proto --go_out=plugins=grpc:.
/*Package hapi contains the Helm API (HAPI).
Helm uses gRPC to handle communication between client and server. This package
contains the definitions of the API objeccts.
The files in this package that end with the extension *.pb.go are automatically
generated by Protobuf for use with gRPC.
*/
package hapi
// Code generated by protoc-gen-go.
// source: helm.proto
// DO NOT EDIT!
/*
Package hapi is a generated protocol buffer package.
hapi: The Helm API
It is generated from these files:
helm.proto
It has these top-level messages:
PingRequest
PingResponse
Chart
Values
Release
*/
package hapi
import proto "github.com/golang/protobuf/proto"
import fmt "fmt"
import math "math"
import (
context "golang.org/x/net/context"
grpc "google.golang.org/grpc"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
const _ = proto.ProtoPackageIsVersion1
// The readiness test request.
type PingRequest struct {
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
}
func (m *PingRequest) Reset() { *m = PingRequest{} }
func (m *PingRequest) String() string { return proto.CompactTextString(m) }
func (*PingRequest) ProtoMessage() {}
func (*PingRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} }
// The readiness test response.
type PingResponse struct {
Status string `protobuf:"bytes,1,opt,name=status" json:"status,omitempty"`
}
func (m *PingResponse) Reset() { *m = PingResponse{} }
func (m *PingResponse) String() string { return proto.CompactTextString(m) }
func (*PingResponse) ProtoMessage() {}
func (*PingResponse) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} }
type Chart struct {
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
}
func (m *Chart) Reset() { *m = Chart{} }
func (m *Chart) String() string { return proto.CompactTextString(m) }
func (*Chart) ProtoMessage() {}
func (*Chart) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} }
type Values struct {
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
}
func (m *Values) Reset() { *m = Values{} }
func (m *Values) String() string { return proto.CompactTextString(m) }
func (*Values) ProtoMessage() {}
func (*Values) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} }
type Release struct {
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
}
func (m *Release) Reset() { *m = Release{} }
func (m *Release) String() string { return proto.CompactTextString(m) }
func (*Release) ProtoMessage() {}
func (*Release) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} }
func init() {
proto.RegisterType((*PingRequest)(nil), "hapi.PingRequest")
proto.RegisterType((*PingResponse)(nil), "hapi.PingResponse")
proto.RegisterType((*Chart)(nil), "hapi.Chart")
proto.RegisterType((*Values)(nil), "hapi.Values")
proto.RegisterType((*Release)(nil), "hapi.Release")
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConn
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion1
// Client API for Probe service
type ProbeClient interface {
// Run a readiness test.
Ready(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PingResponse, error)
}
type probeClient struct {
cc *grpc.ClientConn
}
func NewProbeClient(cc *grpc.ClientConn) ProbeClient {
return &probeClient{cc}
}
func (c *probeClient) Ready(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PingResponse, error) {
out := new(PingResponse)
err := grpc.Invoke(ctx, "/hapi.Probe/Ready", in, out, c.cc, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for Probe service
type ProbeServer interface {
// Run a readiness test.
Ready(context.Context, *PingRequest) (*PingResponse, error)
}
func RegisterProbeServer(s *grpc.Server, srv ProbeServer) {
s.RegisterService(&_Probe_serviceDesc, srv)
}
func _Probe_Ready_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error) (interface{}, error) {
in := new(PingRequest)
if err := dec(in); err != nil {
return nil, err
}
out, err := srv.(ProbeServer).Ready(ctx, in)
if err != nil {
return nil, err
}
return out, nil
}
var _Probe_serviceDesc = grpc.ServiceDesc{
ServiceName: "hapi.Probe",
HandlerType: (*ProbeServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "Ready",
Handler: _Probe_Ready_Handler,
},
},
Streams: []grpc.StreamDesc{},
}
var fileDescriptor0 = []byte{
// 182 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xe2, 0xca, 0x48, 0xcd, 0xc9,
0xd5, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0xc9, 0x48, 0x2c, 0xc8, 0x54, 0x52, 0xe4, 0xe2,
0x0e, 0xc8, 0xcc, 0x4b, 0x0f, 0x4a, 0x2d, 0x2c, 0x4d, 0x2d, 0x2e, 0x11, 0x12, 0xe2, 0x62, 0xc9,
0x4b, 0xcc, 0x4d, 0x95, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0x02, 0xb3, 0x95, 0xd4, 0xb8, 0x78,
0x20, 0x4a, 0x8a, 0x0b, 0xf2, 0xf3, 0x8a, 0x53, 0x85, 0xc4, 0xb8, 0xd8, 0x8a, 0x4b, 0x12, 0x4b,
0x4a, 0x8b, 0xa1, 0xaa, 0xa0, 0x3c, 0x25, 0x69, 0x2e, 0x56, 0xe7, 0x8c, 0xc4, 0x22, 0xec, 0x86,
0xc8, 0x70, 0xb1, 0x85, 0x25, 0xe6, 0x00, 0xed, 0xc0, 0x2a, 0x2b, 0xcb, 0xc5, 0x1e, 0x94, 0x9a,
0x93, 0x9a, 0x08, 0x34, 0x1d, 0x8b, 0xb4, 0x91, 0x25, 0x17, 0x6b, 0x40, 0x51, 0x7e, 0x52, 0xaa,
0x90, 0x01, 0x17, 0x6b, 0x50, 0x6a, 0x62, 0x4a, 0xa5, 0x90, 0xa0, 0x1e, 0xc8, 0xf5, 0x7a, 0x48,
0x4e, 0x97, 0x12, 0x42, 0x16, 0x82, 0x38, 0x55, 0x89, 0xc1, 0x89, 0x93, 0x8b, 0xbd, 0x38, 0x43,
0x0f, 0xe4, 0xed, 0x24, 0x36, 0xb0, 0xbf, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x1e, 0x2f,
0xf3, 0xed, 0x05, 0x01, 0x00, 0x00,
}
...@@ -11,12 +11,14 @@ type Memory struct { ...@@ -11,12 +11,14 @@ type Memory struct {
releases map[string]*release.Release releases map[string]*release.Release
} }
// NewMemory creates a new in-memory storage.
func NewMemory() *Memory { func NewMemory() *Memory {
return &Memory{ return &Memory{
releases: map[string]*release.Release{}, releases: map[string]*release.Release{},
} }
} }
// ErrNotFound indicates that a release is not found.
var ErrNotFound = errors.New("release not found") var ErrNotFound = errors.New("release not found")
// Read returns the named Release. // Read returns the named Release.
...@@ -36,12 +38,10 @@ func (m *Memory) Create(rel *release.Release) error { ...@@ -36,12 +38,10 @@ func (m *Memory) Create(rel *release.Release) error {
return nil return nil
} }
var ErrNoRelease = errors.New("no release found")
// Update sets a release. // Update sets a release.
func (m *Memory) Update(rel *release.Release) error { func (m *Memory) Update(rel *release.Release) error {
if _, ok := m.releases[rel.Name]; !ok { if _, ok := m.releases[rel.Name]; !ok {
return ErrNoRelease return ErrNotFound
} }
// FIXME: When Release is done, we need to do this right by marking the old // FIXME: When Release is done, we need to do this right by marking the old
...@@ -50,16 +50,17 @@ func (m *Memory) Update(rel *release.Release) error { ...@@ -50,16 +50,17 @@ func (m *Memory) Update(rel *release.Release) error {
return nil return nil
} }
// Delete removes a release.
func (m *Memory) Delete(name string) (*release.Release, error) { func (m *Memory) Delete(name string) (*release.Release, error) {
rel, ok := m.releases[name] rel, ok := m.releases[name]
if !ok { if !ok {
return nil, ErrNoRelease return nil, ErrNotFound
} }
delete(m.releases, name) delete(m.releases, name)
return rel, nil return rel, nil
} }
// List returns all releases // List returns all releases.
func (m *Memory) List() ([]*release.Release, error) { func (m *Memory) List() ([]*release.Release, error) {
buf := make([]*release.Release, len(m.releases)) buf := make([]*release.Release, len(m.releases))
i := 0 i := 0
...@@ -69,6 +70,8 @@ func (m *Memory) List() ([]*release.Release, error) { ...@@ -69,6 +70,8 @@ func (m *Memory) List() ([]*release.Release, error) {
} }
return buf, nil return buf, nil
} }
// Query searches all releases for matches.
func (m *Memory) Query(labels map[string]string) ([]*release.Release, error) { func (m *Memory) Query(labels map[string]string) ([]*release.Release, error) {
return []*release.Release{}, errors.New("Cannot implement until release.Release is defined.") return []*release.Release{}, errors.New("Cannot implement until release.Release is defined.")
} }
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