pull/8410/merge
Abhijeet Kasurde 5 years ago committed by GitHub
commit 91c518f0d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -193,7 +193,7 @@ below.
3. Discussion 3. Discussion
- issues that are labeled as `feature` or `bug` should be connected to the PR that resolves it. - issues that are labeled as `feature` or `bug` should be connected to the PR that resolves it.
- Whoever is working on a `feature` or `bug` issue (whether a maintainer or someone from the - Whoever is working on a `feature` or `bug` issue (whether a maintainer or someone from the
community), should either assign the issue to themself or make a comment in the issue saying community), should either assign the issue to themselves or make a comment in the issue saying
that they are taking it. that they are taking it.
- `proposal` and `support/question` issues should stay open until resolved or if they have not - `proposal` and `support/question` issues should stay open until resolved or if they have not
been active for more than 30 days. This will help keep the issue queue to a manageable size been active for more than 30 days. This will help keep the issue queue to a manageable size

@ -16,17 +16,18 @@ limitations under the License.
package main package main
import ( import (
"fmt"
"io" "io"
"strings" "strings"
"github.com/gosuri/uitable" "github.com/gosuri/uitable"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"helm.sh/helm/v3/pkg/cli/output"
"helm.sh/helm/v3/pkg/plugin" "helm.sh/helm/v3/pkg/plugin"
) )
func newPluginListCmd(out io.Writer) *cobra.Command { func newPluginListCmd(out io.Writer) *cobra.Command {
var outfmt output.Format
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "list", Use: "list",
Aliases: []string{"ls"}, Aliases: []string{"ls"},
@ -39,16 +40,33 @@ func newPluginListCmd(out io.Writer) *cobra.Command {
return err return err
} }
return outfmt.Write(out, &pluginListWriter{plugins})
},
}
bindOutputFlag(cmd, &outfmt)
return cmd
}
type pluginListWriter struct {
plugins []*plugin.Plugin
}
func (p *pluginListWriter) WriteTable(out io.Writer) error {
table := uitable.New() table := uitable.New()
table.AddRow("NAME", "VERSION", "DESCRIPTION") table.AddRow("NAME", "VERSION", "DESCRIPTION")
for _, p := range plugins { for _, p := range p.plugins {
table.AddRow(p.Metadata.Name, p.Metadata.Version, p.Metadata.Description) table.AddRow(p.Metadata.Name, p.Metadata.Version, p.Metadata.Description)
} }
fmt.Fprintln(out, table) return output.EncodeTable(out, table)
return nil
},
} }
return cmd
func (p *pluginListWriter) WriteJSON(out io.Writer) error {
return output.EncodeJSON(out, p.plugins)
}
func (p *pluginListWriter) WriteYAML(out io.Writer) error {
return output.EncodeYAML(out, p.plugins)
} }
// Provide dynamic auto-completion for plugin names // Provide dynamic auto-completion for plugin names

@ -0,0 +1,42 @@
/*
Copyright The Helm Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main
import (
"testing"
)
func TestPluginListCmd(t *testing.T) {
tests := []cmdTestCase{{
name: "List plugins",
cmd: "plugin list",
golden: "output/plugin-list.txt",
}, {
name: "List plugins with JSON",
cmd: "plugin list -o json",
golden: "output/plugin-list-json.txt",
}, {
name: "List plugins with YAML",
cmd: "plugin list -o yaml",
golden: "output/plugin-list-yaml.txt",
}}
runTestCmd(t, tests)
}
func TestPluginListOutputCompletion(t *testing.T) {
outputFlagCompletionTest(t, "plugin list")
}

@ -0,0 +1 @@
NAME VERSION DESCRIPTION
Loading…
Cancel
Save