From 4011268b8c7034076c6adca88e67222ee6198c72 Mon Sep 17 00:00:00 2001 From: "ys.achinta" Date: Wed, 17 Jun 2020 17:09:53 +0530 Subject: [PATCH] move endpoints to pkg/http --- cmd/service/service.go | 8 ++--- .../http/api}/install/installcontract.go | 0 .../http/api}/install/installhandler.go | 2 +- .../http/api}/list/listcontract.go | 0 .../http/api}/list/listhandler.go | 2 +- .../http/api}/ping/pingcontract.go | 0 .../http/api}/ping/pinghandler.go | 0 pkg/http/list.go | 36 ------------------- {cmd => pkg}/servercontext/context.go | 0 9 files changed, 6 insertions(+), 42 deletions(-) rename {cmd/endpoints => pkg/http/api}/install/installcontract.go (100%) rename {cmd/endpoints => pkg/http/api}/install/installhandler.go (97%) rename {cmd/endpoints => pkg/http/api}/list/listcontract.go (100%) rename {cmd/endpoints => pkg/http/api}/list/listhandler.go (96%) rename {cmd/endpoints => pkg/http/api}/ping/pingcontract.go (100%) rename {cmd/endpoints => pkg/http/api}/ping/pinghandler.go (100%) delete mode 100644 pkg/http/list.go rename {cmd => pkg}/servercontext/context.go (100%) diff --git a/cmd/service/service.go b/cmd/service/service.go index 19fe2811f..c9b9b56be 100644 --- a/cmd/service/service.go +++ b/cmd/service/service.go @@ -4,10 +4,10 @@ import ( "fmt" "net/http" - "helm.sh/helm/v3/cmd/endpoints/install" - "helm.sh/helm/v3/cmd/endpoints/list" - "helm.sh/helm/v3/cmd/endpoints/ping" - "helm.sh/helm/v3/cmd/servercontext" + "helm.sh/helm/v3/pkg/http/api/install" + "helm.sh/helm/v3/pkg/http/api/list" + "helm.sh/helm/v3/pkg/http/api/ping" + "helm.sh/helm/v3/pkg/servercontext" ) func main() { diff --git a/cmd/endpoints/install/installcontract.go b/pkg/http/api/install/installcontract.go similarity index 100% rename from cmd/endpoints/install/installcontract.go rename to pkg/http/api/install/installcontract.go diff --git a/cmd/endpoints/install/installhandler.go b/pkg/http/api/install/installhandler.go similarity index 97% rename from cmd/endpoints/install/installhandler.go rename to pkg/http/api/install/installhandler.go index 53b234ae4..d89a8c5f6 100644 --- a/cmd/endpoints/install/installhandler.go +++ b/pkg/http/api/install/installhandler.go @@ -5,10 +5,10 @@ import ( "fmt" "net/http" - "helm.sh/helm/v3/cmd/servercontext" "helm.sh/helm/v3/pkg/action" "helm.sh/helm/v3/pkg/chart" "helm.sh/helm/v3/pkg/chart/loader" + "helm.sh/helm/v3/pkg/servercontext" ) func Handler() http.Handler { diff --git a/cmd/endpoints/list/listcontract.go b/pkg/http/api/list/listcontract.go similarity index 100% rename from cmd/endpoints/list/listcontract.go rename to pkg/http/api/list/listcontract.go diff --git a/cmd/endpoints/list/listhandler.go b/pkg/http/api/list/listhandler.go similarity index 96% rename from cmd/endpoints/list/listhandler.go rename to pkg/http/api/list/listhandler.go index 59c875bb2..4da9cddef 100644 --- a/cmd/endpoints/list/listhandler.go +++ b/pkg/http/api/list/listhandler.go @@ -5,8 +5,8 @@ import ( "fmt" "net/http" - "helm.sh/helm/v3/cmd/servercontext" "helm.sh/helm/v3/pkg/action" + "helm.sh/helm/v3/pkg/servercontext" ) func Handler() http.Handler { diff --git a/cmd/endpoints/ping/pingcontract.go b/pkg/http/api/ping/pingcontract.go similarity index 100% rename from cmd/endpoints/ping/pingcontract.go rename to pkg/http/api/ping/pingcontract.go diff --git a/cmd/endpoints/ping/pinghandler.go b/pkg/http/api/ping/pinghandler.go similarity index 100% rename from cmd/endpoints/ping/pinghandler.go rename to pkg/http/api/ping/pinghandler.go diff --git a/pkg/http/list.go b/pkg/http/list.go deleted file mode 100644 index 4f9478888..000000000 --- a/pkg/http/list.go +++ /dev/null @@ -1,36 +0,0 @@ -package http - -import ( - "encoding/json" - - "helm.sh/helm/v3/pkg/action" -) - -type helmRelease struct { - Release string `json:"release"` - Namespace string `json:"namespace"` -} - -func List(cfg *action.Configuration) ([]byte, error) { - list := action.NewList(cfg) - - list.SetStateMask() - - results, err := list.Run() - if err != nil { - return nil, err - } - - var helmReleases []helmRelease - - for _, res := range results { - r := helmRelease{Release: res.Name, Namespace: res.Namespace} - helmReleases = append(helmReleases, r) - } - - jsonReleases, err := json.Marshal(helmReleases) - if err != nil { - return nil, err - } - return jsonReleases, err -} diff --git a/cmd/servercontext/context.go b/pkg/servercontext/context.go similarity index 100% rename from cmd/servercontext/context.go rename to pkg/servercontext/context.go