Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: get release values by revision #183

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ func (c *HelmClient) ListReleasesByStateMask(states action.ListStates) ([]*relea
}

// GetReleaseValues returns the (optionally, all computed) values for the specified release.
func (c *HelmClient) GetReleaseValues(name string, allValues bool) (map[string]interface{}, error) {
return c.getReleaseValues(name, allValues)
func (c *HelmClient) GetReleaseValues(name string, allValues bool, version int) (map[string]interface{}, error) {
return c.getReleaseValues(name, allValues, version)
}

// GetRelease returns a release specified by name.
Expand Down Expand Up @@ -801,10 +801,12 @@ func (c *HelmClient) listReleases(state action.ListStates) ([]*release.Release,

// getReleaseValues returns the values for the provided release 'name'.
// If allValues = true is specified, all computed values are returned.
func (c *HelmClient) getReleaseValues(name string, allValues bool) (map[string]interface{}, error) {
// version '0' means the latest reversion.
func (c *HelmClient) getReleaseValues(name string, allValues bool, version int) (map[string]interface{}, error) {
getReleaseValuesClient := action.NewGetValues(c.ActionConfig)

getReleaseValuesClient.AllValues = allValues
getReleaseValuesClient.Version = version

return getReleaseValuesClient.Run(name)
}
Expand Down
3 changes: 2 additions & 1 deletion client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package helmclient
import (
"bytes"
"context"

"helm.sh/helm/v3/pkg/chartutil"

"helm.sh/helm/v3/pkg/action"
Expand Down Expand Up @@ -316,7 +317,7 @@ func ExampleHelmClient_ListDeployedReleases() {

func ExampleHelmClient_GetReleaseValues() {
// Get the values of a deployed release.
if _, err := helmClient.GetReleaseValues("etcd-operator", true); err != nil {
if _, err := helmClient.GetReleaseValues("etcd-operator", true, 0); err != nil {
panic(err)
}
}
Expand Down
2 changes: 1 addition & 1 deletion interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Client interface {
GetRelease(name string) (*release.Release, error)
// RollBack is an interface to abstract a rollback action.
RollBack
GetReleaseValues(name string, allValues bool) (map[string]interface{}, error)
GetReleaseValues(name string, allValues bool, version int) (map[string]interface{}, error)
UninstallRelease(spec *ChartSpec) error
UninstallReleaseByName(name string) error
TemplateChart(spec *ChartSpec, options *HelmTemplateOptions) ([]byte, error)
Expand Down
8 changes: 4 additions & 4 deletions mock/interface.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions mock/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ func TestHelmClientInterfaces(t *testing.T) {

t.Run("GetReleaseValues", func(t *testing.T) {
m := make(map[string]interface{})
mockClient.EXPECT().GetReleaseValues(mockedRelease.Name, true).
mockClient.EXPECT().GetReleaseValues(mockedRelease.Name, true, 0).
Return(m, nil)
rv, err := mockClient.GetReleaseValues(mockedRelease.Name, true)
rv, err := mockClient.GetReleaseValues(mockedRelease.Name, true, 0)
if err != nil {
panic(err)
}
Expand Down