mirror of
https://github.com/helm/helm.git
synced 2026-08-08 00:51:55 +00:00
fix(*): fix misc style issues
This commit is contained in:
@@ -15,13 +15,13 @@ var homeCommand = &cobra.Command{
|
||||
Use: "home",
|
||||
Short: "Displays the location of HELM_HOME",
|
||||
Long: longHomeHelp,
|
||||
Run: Home,
|
||||
Run: home,
|
||||
}
|
||||
|
||||
func init() {
|
||||
RootCommand.AddCommand(homeCommand)
|
||||
}
|
||||
|
||||
func Home(cmd *cobra.Command, args []string) {
|
||||
func home(cmd *cobra.Command, args []string) {
|
||||
cmd.Printf(os.ExpandEnv(helmHome) + "\n")
|
||||
}
|
||||
|
||||
@@ -32,16 +32,16 @@ var initCmd = &cobra.Command{
|
||||
Use: "init",
|
||||
Short: "Initialize Helm on both client and server.",
|
||||
Long: installDesc,
|
||||
RunE: RunInit,
|
||||
RunE: runInit,
|
||||
}
|
||||
|
||||
// RunInit initializes local config and installs tiller to Kubernetes Cluster
|
||||
func RunInit(cmd *cobra.Command, args []string) error {
|
||||
// runInit initializes local config and installs tiller to Kubernetes Cluster
|
||||
func runInit(cmd *cobra.Command, args []string) error {
|
||||
if len(args) != 0 {
|
||||
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
|
||||
}
|
||||
|
||||
@@ -75,11 +75,11 @@ func buildKubectlRunner(kubectlPath string) kubectl.Runner {
|
||||
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.
|
||||
func EnsureHome(home string) error {
|
||||
configDirectories := []string{home, CacheDirectory(home)}
|
||||
func ensureHome(home string) error {
|
||||
configDirectories := []string{home, cacheDirectory(home)}
|
||||
|
||||
for _, p := range configDirectories {
|
||||
if fi, err := os.Stat(p); err != nil {
|
||||
@@ -88,26 +88,26 @@ func EnsureHome(home string) error {
|
||||
return fmt.Errorf("Could not create %s: %s", p, err)
|
||||
}
|
||||
} 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 {
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
} 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
|
||||
}
|
||||
|
||||
func CacheDirectory(home string) string {
|
||||
func cacheDirectory(home string) string {
|
||||
return filepath.Join(home, cachePath)
|
||||
}
|
||||
|
||||
func RepositoriesFile(home string) string {
|
||||
func repositoriesFile(home string) string {
|
||||
return filepath.Join(home, repositoriesPath)
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
// rootServer is the root gRPC server.
|
||||
//
|
||||
// Each gRPC service registers itself to this server during init().
|
||||
var rootServer *grpc.Server = grpc.NewServer()
|
||||
var rootServer = grpc.NewServer()
|
||||
var env = environment.New()
|
||||
|
||||
const globalUsage = `The Kubernetes Helm server.
|
||||
|
||||
@@ -8,8 +8,10 @@ import (
|
||||
"github.com/BurntSushi/toml"
|
||||
)
|
||||
|
||||
// ErrNoTable indicates that a chart does not have a matching table.
|
||||
var ErrNoTable = errors.New("no table")
|
||||
|
||||
// Values represents a collection of chart values.
|
||||
type Values map[string]interface{}
|
||||
|
||||
// Table gets a table (TOML subsection) from a Values object.
|
||||
|
||||
@@ -11,12 +11,14 @@ type Memory struct {
|
||||
releases map[string]*release.Release
|
||||
}
|
||||
|
||||
// NewMemory creates a new in-memory storage.
|
||||
func NewMemory() *Memory {
|
||||
return &Memory{
|
||||
releases: map[string]*release.Release{},
|
||||
}
|
||||
}
|
||||
|
||||
// ErrNotFound indicates that a release is not found.
|
||||
var ErrNotFound = errors.New("release not found")
|
||||
|
||||
// Read returns the named Release.
|
||||
@@ -36,12 +38,10 @@ func (m *Memory) Create(rel *release.Release) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
var ErrNoRelease = errors.New("no release found")
|
||||
|
||||
// Update sets a release.
|
||||
func (m *Memory) Update(rel *release.Release) error {
|
||||
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
|
||||
@@ -50,16 +50,17 @@ func (m *Memory) Update(rel *release.Release) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Delete removes a release.
|
||||
func (m *Memory) Delete(name string) (*release.Release, error) {
|
||||
rel, ok := m.releases[name]
|
||||
if !ok {
|
||||
return nil, ErrNoRelease
|
||||
return nil, ErrNotFound
|
||||
}
|
||||
delete(m.releases, name)
|
||||
return rel, nil
|
||||
}
|
||||
|
||||
// List returns all releases
|
||||
// List returns all releases.
|
||||
func (m *Memory) List() ([]*release.Release, error) {
|
||||
buf := make([]*release.Release, len(m.releases))
|
||||
i := 0
|
||||
@@ -69,6 +70,8 @@ func (m *Memory) List() ([]*release.Release, error) {
|
||||
}
|
||||
return buf, nil
|
||||
}
|
||||
|
||||
// Query searches all releases for matches.
|
||||
func (m *Memory) Query(labels map[string]string) ([]*release.Release, error) {
|
||||
return []*release.Release{}, errors.New("Cannot implement until release.Release is defined.")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user