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

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

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

@ -35,6 +35,7 @@ type statusCmd struct {
release string release string
out io.Writer out io.Writer
client helm.Interface client helm.Interface
version int32
} }
func newStatusCmd(client helm.Interface, out io.Writer) *cobra.Command { 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() return status.run()
}, },
} }
cmd.PersistentFlags().Int32Var(&status.version, "version", 0, "version of release")
return cmd return cmd
} }
func (s *statusCmd) run() error { 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 { if err != nil {
return prettyError(err) return prettyError(err)
} }

@ -50,6 +50,10 @@ type options struct {
updateReq rls.UpdateReleaseRequest updateReq rls.UpdateReleaseRequest
// release uninstall options are applied directly to the uninstall release request // release uninstall options are applied directly to the uninstall release request
uninstallReq rls.UninstallReleaseRequest 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"). // 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) 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) 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) type DeleteOption func(*options)
// UpdateOption allows specifying various settings // 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. // Executes tiller.GetReleaseStatus RPC.
func (o *options) rpcGetReleaseStatus(rlsName string, rlc rls.ReleaseServiceClient, opts ...StatusOption) (*rls.GetReleaseStatusResponse, error) { func (o *options) rpcGetReleaseStatus(rlsName string, rlc rls.ReleaseServiceClient, opts ...StatusOption) (*rls.GetReleaseStatusResponse, error) {
req := &rls.GetReleaseStatusRequest{Name: rlsName} for _, opt := range opts {
return rlc.GetReleaseStatus(context.TODO(), req) opt(o)
}
o.statusReq.Name = rlsName
return rlc.GetReleaseStatus(context.TODO(), &o.statusReq)
} }
// Executes tiller.GetReleaseContent. // Executes tiller.GetReleaseContent.
func (o *options) rpcGetReleaseContent(rlsName string, rlc rls.ReleaseServiceClient, opts ...ContentOption) (*rls.GetReleaseContentResponse, error) { func (o *options) rpcGetReleaseContent(rlsName string, rlc rls.ReleaseServiceClient, opts ...ContentOption) (*rls.GetReleaseContentResponse, error) {
req := &rls.GetReleaseContentRequest{Name: rlsName} for _, opt := range opts {
return rlc.GetReleaseContent(context.TODO(), req) opt(o)
}
o.contentReq.Name = rlsName
return rlc.GetReleaseContent(context.TODO(), &o.contentReq)
} }

Loading…
Cancel
Save