Skip to content

Commit

Permalink
Small fixes and comments addressed
Browse files Browse the repository at this point in the history
 - Use composite type for History
 - Fix comments that refer to upgrade name
 - Missing doc comments
 - Missing license header

Signed-off-by: Itxaka <[email protected]>
  • Loading branch information
Itxaka committed Mar 8, 2021
1 parent 4caa308 commit e03c3b9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 27 deletions.
15 changes: 15 additions & 0 deletions cmd/hypper/dependency_build.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main

import (
Expand Down
10 changes: 5 additions & 5 deletions cmd/hypper/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
const upgradeDesc = `
This command upgrades a release to a new version of a chart.
The upgrade arguments must be a release and chart. The chart
The upgrade arguments must be a chart. The chart
argument can be either: a chart reference('example/mariadb'), a path to a chart directory,
a packaged chart, or a fully qualified URL. For chart references, the latest
version will be specified unless the '--version' flag is set.
Expand All @@ -52,13 +52,13 @@ You can specify the '--values'/'-f' flag multiple times. The priority will be gi
last (right-most) file specified. For example, if both myvalues.yaml and override.yaml
contained a key called 'Test', the value set in override.yaml would take precedence:
$ helm upgrade -f myvalues.yaml -f override.yaml redis ./redis
$ helm upgrade -f myvalues.yaml -f override.yaml ./redis
You can specify the '--set' flag multiple times. The priority will be given to the
last (right-most) set specified. For example, if both 'bar' and 'newbar' values are
set for a key called 'foo', the 'newbar' value would take precedence:
$ helm upgrade --set foo=bar --set foo=newbar redis ./redis
$ helm upgrade --set foo=bar --set foo=newbar ./redis
`

func newUpgradeCmd(cfg *action.Configuration, logger log.Logger) *cobra.Command {
Expand All @@ -69,7 +69,7 @@ func newUpgradeCmd(cfg *action.Configuration, logger log.Logger) *cobra.Command

cmd := &cobra.Command{
Use: "upgrade [CHART]",
Short: "upgrade a release",
Short: "upgrade a chart",
Long: upgradeDesc,
Args: require.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -102,7 +102,7 @@ func newUpgradeCmd(cfg *action.Configuration, logger log.Logger) *cobra.Command
logger.Debugf("client.ReleaseName was empty, setting release name to %s", client.ReleaseName)
}

// Fixes #7002 - Support reading values from STDIN for `upgrade` command
// Fixes helm#7002 - Support reading values from STDIN for `upgrade` command
// Must load values AFTER determining if we have to call install so that values loaded from stdin are are not read twice
if client.Install {
// If a release does not exist, install it.
Expand Down
26 changes: 4 additions & 22 deletions pkg/action/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ limitations under the License.
package action

import (
"github.com/pkg/errors"

"helm.sh/helm/v3/pkg/chartutil"
"helm.sh/helm/v3/pkg/release"
"helm.sh/helm/v3/pkg/action"
)

// History is the action for checking the release's ledger.
Expand All @@ -30,29 +27,14 @@ import (
// To list up to one revision of every release in one specific, or in all,
// namespaces, see the List action.
type History struct {
*action.History
cfg *Configuration

Max int
Version int
}

// NewHistory creates a new History object with the given configuration.
func NewHistory(cfg *Configuration) *History {
return &History{
cfg: cfg,
}
}

// Run executes 'helm history' against the given release.
func (h *History) Run(name string) ([]*release.Release, error) {
if err := h.cfg.KubeClient.IsReachable(); err != nil {
return nil, err
}

if err := chartutil.ValidateReleaseName(name); err != nil {
return nil, errors.Errorf("release name is invalid: %s", name)
History: action.NewHistory(cfg.Configuration),
cfg: cfg,
}

h.cfg.Log("getting history for release %s", name)
return h.cfg.Releases.History(name)
}
1 change: 1 addition & 0 deletions pkg/action/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func NewUpgrade(cfg *Configuration) *Upgrade {
}
}

// Name returns the name that should be used.
func (i *Upgrade) Name(chart *chart.Chart, args []string) (string, error) {
// args here will only be: [CHART]
// cobra flags have been already stripped
Expand Down

0 comments on commit e03c3b9

Please sign in to comment.