From caa782e51363375fb8671b3681fb2e88f95a65ec Mon Sep 17 00:00:00 2001 From: fibonacci1729 Date: Wed, 24 Aug 2016 15:09:04 -0600 Subject: [PATCH] chore(storage-naming): introduce helm option --- pkg/helm/option.go | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/pkg/helm/option.go b/pkg/helm/option.go index 2af4742da..8225456c6 100644 --- a/pkg/helm/option.go +++ b/pkg/helm/option.go @@ -47,6 +47,10 @@ type options struct { instReq rls.InstallReleaseRequest // release update options are applied directly to the update release request updateReq rls.UpdateReleaseRequest + // release get status options are applied directly to the get release status request + statusReq rls.GetReleaseStatusRequest + // release get content options are applied directly to the get release content request + contentReq rls.GetReleaseContentRequest } // Home specifies the location of helm home, (default = "$HOME/.helm"). @@ -178,13 +182,32 @@ func InstallReuseName(reuse bool) InstallOption { } } -// ContentOption -- TODO +// ContentOption allows setting optional attributes when +// performing a GetReleaseContent tiller rpc. type ContentOption func(*options) -// StatusOption -- TODO +// ContentReleaseVersion will instruct Tiller to retrieve the content +// of a paritcular version of a release. +func ContentReleaseVersion(version int32) ContentOption { + return func(opts *options) { + opts.contentReq.Version = version + } +} + +// StatusOption allows setting optional attributes when +// performing a GetReleaseStatus tiller rpc. type StatusOption func(*options) -// DeleteOption -- TODO +// StatusReleaseVersion will instruct Tiller to retrieve the status +// of a paritcular version of a release. +func StatusReleaseVersion(version int32) StatusOption { + return func(opts *options) { + opts.statusReq.Version = version + } +} + +// DeleteOption allows setting optional attributes when +// performing a UninstallRelease tiller rpc. type DeleteOption func(*options) // UpdateOption allows specifying various settings @@ -257,12 +280,18 @@ func (o *options) rpcUpdateRelease(rlsName string, chr *cpb.Chart, rlc rls.Relea // Executes tiller.GetReleaseStatus RPC. func (o *options) rpcGetReleaseStatus(rlsName string, rlc rls.ReleaseServiceClient, opts ...StatusOption) (*rls.GetReleaseStatusResponse, error) { - req := &rls.GetReleaseStatusRequest{Name: rlsName} - return rlc.GetReleaseStatus(context.TODO(), req) + for _, opt := range opts { + opt(o) + } + o.statusReq.Name = rlsName + return rlc.GetReleaseStatus(context.TODO(), &o.statusReq) } // Executes tiller.GetReleaseContent. func (o *options) rpcGetReleaseContent(rlsName string, rlc rls.ReleaseServiceClient, opts ...ContentOption) (*rls.GetReleaseContentResponse, error) { - req := &rls.GetReleaseContentRequest{Name: rlsName} - return rlc.GetReleaseContent(context.TODO(), req) + for _, opt := range opts { + opt(o) + } + o.contentReq.Name = rlsName + return rlc.GetReleaseContent(context.TODO(), &o.contentReq) }