Commit 4cd0059d authored by fibonacci1729's avatar fibonacci1729

ref(pkg/helm): package helm refactor

includes:
 - (#828) helm client grpc support ported from old pkg/helm
 - comment consistencey & style fix
 - gofmt pkg/helmx
parent fda80296
...@@ -49,6 +49,7 @@ func GetReleaseContent(rlsName string) (*rls.GetReleaseContentResponse, error) { ...@@ -49,6 +49,7 @@ func GetReleaseContent(rlsName string) (*rls.GetReleaseContentResponse, error) {
return NewClient(HelmHost(Config.ServAddr)).ReleaseContent(rlsName) return NewClient(HelmHost(Config.ServAddr)).ReleaseContent(rlsName)
} }
// Soon to be deprecated helm UpdateRelease API. See pkg/helmx.
func UpdateRelease(rlsName string) (*rls.UpdateReleaseResponse, error) { func UpdateRelease(rlsName string) (*rls.UpdateReleaseResponse, error) {
if !EnableNewHelm { if !EnableNewHelm {
return helm.UpdateRelease(rlsName) return helm.UpdateRelease(rlsName)
......
...@@ -7,12 +7,9 @@ import ( ...@@ -7,12 +7,9 @@ import (
rls "k8s.io/helm/pkg/proto/hapi/services" rls "k8s.io/helm/pkg/proto/hapi/services"
) )
// # Options // Option allows specifying various settings configurable by
// // the helm client user for overriding the defaults used when
// Option allows specifying various settings configurable by // issuing rpc's to the Tiller release server.
// the helm client user for overriding the defaults used when
// issuing rpc's to the Tiller release server.
//
type Option func(*options) type Option func(*options)
// options specify optional settings used by the helm client. // options specify optional settings used by the helm client.
...@@ -52,12 +49,9 @@ func HelmHost(host string) Option { ...@@ -52,12 +49,9 @@ func HelmHost(host string) Option {
} }
} }
// # Release List Options // ReleaseListOption allows specifying various settings
// // configurable by the helm client user for overriding
// ReleaseListOption allows specifying various settings // the defaults used when running the `helm list` command.
// configurable by the helm client user for overriding
// the defaults used when running the `helm list` command.
//
type ReleaseListOption func(*options) type ReleaseListOption func(*options)
// ReleaseListOffset specifies the offset into a list of releases. // ReleaseListOffset specifies the offset into a list of releases.
...@@ -95,12 +89,9 @@ func ReleaseListSort(sort int32) ReleaseListOption { ...@@ -95,12 +89,9 @@ func ReleaseListSort(sort int32) ReleaseListOption {
} }
} }
// # Install Options // InstallOption allows specifying various settings
// // configurable by the helm client user for overriding
// InstallOption allows specifying various settings // the defaults used when running the `helm install` command.
// configurable by the helm client user for overriding
// the defaults used when running the `helm install` command.
//
type InstallOption func(*options) type InstallOption func(*options)
// ValueOverrides specifies a list of values to include when installing. // ValueOverrides specifies a list of values to include when installing.
...@@ -117,24 +108,24 @@ func ReleaseName(name string) InstallOption { ...@@ -117,24 +108,24 @@ func ReleaseName(name string) InstallOption {
} }
} }
// # ContentOption -- TODO // ContentOption -- TODO
type ContentOption func(*options) type ContentOption func(*options)
// # StatusOption -- TODO // StatusOption -- TODO
type StatusOption func(*options) type StatusOption func(*options)
// # DeleteOption -- TODO // DeleteOption -- TODO
type DeleteOption func(*options) type DeleteOption func(*options)
// # UpdateOption -- TODO // UpdateOption -- TODO
type UpdateOption func(*options) type UpdateOption func(*options)
// # RPC helpers defined on `options` type. Note: These actually execute the // RPC helpers defined on `options` type. Note: These actually execute the
// the corresponding tiller RPC. There is no particular reason why these // the corresponding tiller RPC. There is no particular reason why these
// are APIs are hung off `options`, they are internal to pkg/helm to remain // are APIs are hung off `options`, they are internal to pkg/helm to remain
// malleable. // malleable.
// TODO: Executes tiller.ListReleases RPC. See issue #828 // Executes tiller.ListReleases RPC.
func (o *options) rpcListReleases(rlc rls.ReleaseServiceClient, opts ...ReleaseListOption) (*rls.ListReleasesResponse, error) { func (o *options) rpcListReleases(rlc rls.ReleaseServiceClient, opts ...ReleaseListOption) (*rls.ListReleasesResponse, error) {
// apply release list options // apply release list options
for _, opt := range opts { for _, opt := range opts {
...@@ -148,33 +139,45 @@ func (o *options) rpcListReleases(rlc rls.ReleaseServiceClient, opts ...ReleaseL ...@@ -148,33 +139,45 @@ func (o *options) rpcListReleases(rlc rls.ReleaseServiceClient, opts ...ReleaseL
return s.Recv() return s.Recv()
} }
// TODO: Executes tiller.InstallRelease RPC. See issue #828 // Executes tiller.InstallRelease RPC.
func (o *options) rpcInstallRelease(chr *cpb.Chart, rlc rls.ReleaseServiceClient, opts ...InstallOption) (*rls.InstallReleaseResponse, error) { func (o *options) rpcInstallRelease(chr *cpb.Chart, rlc rls.ReleaseServiceClient, opts ...InstallOption) (*rls.InstallReleaseResponse, error) {
// apply the install options // apply the install options
for _, opt := range opts { for _, opt := range opts {
opt(o) opt(o)
} }
o.instReq.Chart = chr o.instReq.Chart = chr
o.instReq.DryRun = o.dryRun
return rlc.InstallRelease(context.TODO(), &o.instReq) return rlc.InstallRelease(context.TODO(), &o.instReq)
} }
// TODO: Executes tiller.UninstallRelease RPC. See issue #828 // Executes tiller.UninstallRelease RPC.
func (o *options) rpcDeleteRelease(rlsName string, rlc rls.ReleaseServiceClient, opts ...DeleteOption) (*rls.UninstallReleaseResponse, error) { func (o *options) rpcDeleteRelease(rlsName string, rlc rls.ReleaseServiceClient, opts ...DeleteOption) (*rls.UninstallReleaseResponse, error) {
return nil, fmt.Errorf("helm: rpcDeleteRelease: not implemented") if o.dryRun {
// In the dry run case, just see if the release exists
r, err := o.rpcGetReleaseContent(rlsName, rlc)
if err != nil {
return &rls.UninstallReleaseResponse{}, err
}
return &rls.UninstallReleaseResponse{Release: r.Release}, nil
}
return rlc.UninstallRelease(context.TODO(), &rls.UninstallReleaseRequest{Name: rlsName})
} }
// TODO: Executes tiller.UpdateRelease RPC. See issue #828 // Executes tiller.UpdateRelease RPC.
func (o *options) rpcUpdateRelease(rlsName string, rlc rls.ReleaseServiceClient, opts ...UpdateOption) (*rls.UpdateReleaseResponse, error) { func (o *options) rpcUpdateRelease(rlsName string, rlc rls.ReleaseServiceClient, opts ...UpdateOption) (*rls.UpdateReleaseResponse, error) {
return nil, fmt.Errorf("helm: rpcUpdateRelease: not implemented") return nil, fmt.Errorf("helm: UpdateRelease: not implemented")
} }
// TODO: Executes tiller.GetReleaseStatus RPC. See issue #828 // 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) {
return nil, fmt.Errorf("helm: rpcGetReleaseStatus: not implemented") req := &rls.GetReleaseStatusRequest{Name: rlsName}
return rlc.GetReleaseStatus(context.TODO(), req)
} }
// TODO: Executes tiller.GetReleaseConent. See issue #828 // 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) {
return nil, fmt.Errorf("helm: getReleaseContent: not implemented") req := &rls.GetReleaseContentRequest{Name: rlsName}
return rlc.GetReleaseContent(context.TODO(), req)
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment