feat(helm): add optional version flag to helm{get,status}

reviewable/pr1154/r1
fibonacci1729 8 years ago
parent 36606cf152
commit e42aa6c09c

@ -48,6 +48,7 @@ type getCmd struct {
release string
out io.Writer
client helm.Interface
version int32
}
func newGetCmd(client helm.Interface, out io.Writer) *cobra.Command {
@ -71,6 +72,9 @@ func newGetCmd(client helm.Interface, out io.Writer) *cobra.Command {
return get.run()
},
}
cmd.PersistentFlags().Int32Var(&get.version, "version", 0, "version of release")
cmd.AddCommand(newGetValuesCmd(nil, out))
cmd.AddCommand(newGetManifestCmd(nil, out))
cmd.AddCommand(newGetHooksCmd(nil, out))
@ -96,7 +100,7 @@ MANIFEST:
// getCmd is the command that implements 'helm get'
func (g *getCmd) run() error {
res, err := g.client.ReleaseContent(g.release)
res, err := g.client.ReleaseContent(g.release, helm.ContentReleaseVersion(g.version))
if err != nil {
return prettyError(err)
}

@ -35,6 +35,7 @@ type statusCmd struct {
release string
out io.Writer
client helm.Interface
version int32
}
func newStatusCmd(client helm.Interface, out io.Writer) *cobra.Command {
@ -58,11 +59,14 @@ func newStatusCmd(client helm.Interface, out io.Writer) *cobra.Command {
return status.run()
},
}
cmd.PersistentFlags().Int32Var(&status.version, "version", 0, "version of release")
return cmd
}
func (s *statusCmd) run() error {
res, err := s.client.ReleaseStatus(s.release)
res, err := s.client.ReleaseStatus(s.release, helm.StatusReleaseVersion(s.version))
if err != nil {
return prettyError(err)
}

@ -50,6 +50,10 @@ type options struct {
updateReq rls.UpdateReleaseRequest
// release uninstall options are applied directly to the uninstall release request
uninstallReq rls.UninstallReleaseRequest
// 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").
@ -198,13 +202,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
@ -281,12 +304,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)
}

Loading…
Cancel
Save