From 327080161dce6921ec5ca085d404b7cadbdc3ae7 Mon Sep 17 00:00:00 2001 From: Mike Lundy Date: Mon, 16 Jul 2018 17:10:16 -0700 Subject: [PATCH 1/2] [fake] make InstallReleaseFromChart obey DryRun --- pkg/helm/fake.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/helm/fake.go b/pkg/helm/fake.go index 2f0ad90b8..39909cfcd 100644 --- a/pkg/helm/fake.go +++ b/pkg/helm/fake.go @@ -97,7 +97,9 @@ func (c *FakeClient) InstallReleaseFromChart(chart *chart.Chart, ns string, opts } release := ReleaseMock(&MockReleaseOptions{Name: releaseName, Namespace: ns, Description: releaseDescription}) - c.Rels = append(c.Rels, release) + if !c.Opts.dryRun { + c.Rels = append(c.Rels, release) + } return &rls.InstallReleaseResponse{ Release: release, From a6ab04be4d6f214e664a388101cdd8ace56015ab Mon Sep 17 00:00:00 2001 From: Mike Lundy Date: Mon, 16 Jul 2018 17:15:56 -0700 Subject: [PATCH 2/2] [fake] return the correct error message for missing releases --- pkg/helm/fake.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/helm/fake.go b/pkg/helm/fake.go index 39909cfcd..05235c92a 100644 --- a/pkg/helm/fake.go +++ b/pkg/helm/fake.go @@ -18,7 +18,6 @@ package helm // import "k8s.io/helm/pkg/helm" import ( "errors" - "fmt" "math/rand" "sync" @@ -27,6 +26,7 @@ import ( "k8s.io/helm/pkg/proto/hapi/release" rls "k8s.io/helm/pkg/proto/hapi/services" "k8s.io/helm/pkg/proto/hapi/version" + storage "k8s.io/helm/pkg/storage/driver" ) // FakeClient implements Interface @@ -117,7 +117,7 @@ func (c *FakeClient) DeleteRelease(rlsName string, opts ...DeleteOption) (*rls.U } } - return nil, fmt.Errorf("No such release: %s", rlsName) + return nil, storage.ErrReleaseNotFound(rlsName) } // GetVersion returns a fake version @@ -161,7 +161,7 @@ func (c *FakeClient) ReleaseStatus(rlsName string, opts ...StatusOption) (*rls.G }, nil } } - return nil, fmt.Errorf("No such release: %s", rlsName) + return nil, storage.ErrReleaseNotFound(rlsName) } // ReleaseContent returns the configuration for the matching release name in the fake release client. @@ -173,7 +173,7 @@ func (c *FakeClient) ReleaseContent(rlsName string, opts ...ContentOption) (resp }, nil } } - return resp, fmt.Errorf("No such release: %s", rlsName) + return resp, storage.ErrReleaseNotFound(rlsName) } // ReleaseHistory returns a release's revision history.