mirror of https://github.com/docker/compose.git
add list command
Signed-off-by: aiordache <anca.iordache@docker.com>
This commit is contained in:
parent
7146964168
commit
17335ae06c
|
@ -18,12 +18,6 @@ type ComposeProject struct {
|
|||
Name string `yaml:"-" json:"-"`
|
||||
}
|
||||
|
||||
type ComposeResult struct {
|
||||
Info string
|
||||
Status string
|
||||
Descriptin string
|
||||
}
|
||||
|
||||
func Load(name string, configpaths []string) (*ComposeProject, error) {
|
||||
if name == "" {
|
||||
name = "docker-compose"
|
||||
|
@ -68,3 +62,7 @@ func (cp *ComposeProject) Install(name, path string) error {
|
|||
func (cp *ComposeProject) Uninstall(name string) error {
|
||||
return cp.helm.Uninstall(name)
|
||||
}
|
||||
|
||||
func (cp *ComposeProject) List() (map[string]interface{}, error) {
|
||||
return cp.helm.ListReleases()
|
||||
}
|
||||
|
|
|
@ -11,34 +11,11 @@ import (
|
|||
"github.com/docker/helm-prototype/pkg/compose/internal/utils"
|
||||
chart "helm.sh/helm/v3/pkg/chart"
|
||||
util "helm.sh/helm/v3/pkg/chartutil"
|
||||
helmenv "helm.sh/helm/v3/pkg/cli"
|
||||
)
|
||||
|
||||
// Kind is "kubernetes" or "docker"
|
||||
type Kind string
|
||||
|
||||
const (
|
||||
// Kubernetes specifies to use a kubernetes cluster.
|
||||
Kubernetes Kind = "kubernetes"
|
||||
// Docker specifies to use Docker engine.
|
||||
DockerEngine Kind = "docker"
|
||||
)
|
||||
|
||||
type Engine struct {
|
||||
Namespace string
|
||||
|
||||
Kind Kind
|
||||
|
||||
Config string
|
||||
// Context is the name of the kubeconfig/docker context.
|
||||
Context string
|
||||
// Token used for authentication (kubernetes)
|
||||
Token string
|
||||
// Kubernetes API Server Endpoint for authentication
|
||||
APIServer string
|
||||
}
|
||||
|
||||
func GetDefault() *Engine {
|
||||
return &Engine{Kind: Kubernetes}
|
||||
func GetDefault() *helmenv.EnvSettings {
|
||||
return helmenv.New()
|
||||
}
|
||||
|
||||
func Environment() map[string]string {
|
||||
|
|
|
@ -95,3 +95,21 @@ func (hc *HelmActions) Get(name string) (*release.Release, error) {
|
|||
actGet := action.NewGet(hc.Config)
|
||||
return actGet.Run(name)
|
||||
}
|
||||
|
||||
func (hc *HelmActions) ListReleases() (map[string]interface{}, error) {
|
||||
hc.initKubeClient()
|
||||
|
||||
actList := action.NewList(hc.Config)
|
||||
releases, err := actList.Run()
|
||||
if err != nil {
|
||||
return map[string]interface{}{}, err
|
||||
}
|
||||
result := map[string]interface{}{}
|
||||
for _, rel := range releases {
|
||||
result[rel.Name] = map[string]string{
|
||||
"Status": string(rel.Info.Status),
|
||||
"Description": rel.Info.Description,
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue