Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 17335ae

Browse files
author
aiordache
committed
add list command
Signed-off-by: aiordache <[email protected]>
1 parent 7146964 commit 17335ae

File tree

3 files changed

+25
-32
lines changed

3 files changed

+25
-32
lines changed

compose/compose.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@ type ComposeProject struct {
1818
Name string `yaml:"-" json:"-"`
1919
}
2020

21-
type ComposeResult struct {
22-
Info string
23-
Status string
24-
Descriptin string
25-
}
26-
2721
func Load(name string, configpaths []string) (*ComposeProject, error) {
2822
if name == "" {
2923
name = "docker-compose"
@@ -68,3 +62,7 @@ func (cp *ComposeProject) Install(name, path string) error {
6862
func (cp *ComposeProject) Uninstall(name string) error {
6963
return cp.helm.Uninstall(name)
7064
}
65+
66+
func (cp *ComposeProject) List() (map[string]interface{}, error) {
67+
return cp.helm.ListReleases()
68+
}

compose/internal/env.go

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,11 @@ import (
1111
"github.com/docker/helm-prototype/pkg/compose/internal/utils"
1212
chart "helm.sh/helm/v3/pkg/chart"
1313
util "helm.sh/helm/v3/pkg/chartutil"
14+
helmenv "helm.sh/helm/v3/pkg/cli"
1415
)
1516

16-
// Kind is "kubernetes" or "docker"
17-
type Kind string
18-
19-
const (
20-
// Kubernetes specifies to use a kubernetes cluster.
21-
Kubernetes Kind = "kubernetes"
22-
// Docker specifies to use Docker engine.
23-
DockerEngine Kind = "docker"
24-
)
25-
26-
type Engine struct {
27-
Namespace string
28-
29-
Kind Kind
30-
31-
Config string
32-
// Context is the name of the kubeconfig/docker context.
33-
Context string
34-
// Token used for authentication (kubernetes)
35-
Token string
36-
// Kubernetes API Server Endpoint for authentication
37-
APIServer string
38-
}
39-
40-
func GetDefault() *Engine {
41-
return &Engine{Kind: Kubernetes}
17+
func GetDefault() *helmenv.EnvSettings {
18+
return helmenv.New()
4219
}
4320

4421
func Environment() map[string]string {

compose/internal/helm/helm.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,21 @@ func (hc *HelmActions) Get(name string) (*release.Release, error) {
9595
actGet := action.NewGet(hc.Config)
9696
return actGet.Run(name)
9797
}
98+
99+
func (hc *HelmActions) ListReleases() (map[string]interface{}, error) {
100+
hc.initKubeClient()
101+
102+
actList := action.NewList(hc.Config)
103+
releases, err := actList.Run()
104+
if err != nil {
105+
return map[string]interface{}{}, err
106+
}
107+
result := map[string]interface{}{}
108+
for _, rel := range releases {
109+
result[rel.Name] = map[string]string{
110+
"Status": string(rel.Info.Status),
111+
"Description": rel.Info.Description,
112+
}
113+
}
114+
return result, nil
115+
}

0 commit comments

Comments
 (0)