github.com/latiif/helm@v2.15.0+incompatible/cmd/helm/plugin_list.go (about) 1 /* 2 Copyright The Helm Authors. 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 */ 15 16 package main 17 18 import ( 19 "fmt" 20 "io" 21 22 "k8s.io/helm/pkg/helm/helmpath" 23 24 "github.com/gosuri/uitable" 25 "github.com/spf13/cobra" 26 ) 27 28 type pluginListCmd struct { 29 home helmpath.Home 30 out io.Writer 31 } 32 33 func newPluginListCmd(out io.Writer) *cobra.Command { 34 pcmd := &pluginListCmd{out: out} 35 cmd := &cobra.Command{ 36 Use: "list", 37 Short: "List installed Helm plugins", 38 RunE: func(cmd *cobra.Command, args []string) error { 39 pcmd.home = settings.Home 40 return pcmd.run() 41 }, 42 } 43 return cmd 44 } 45 46 func (pcmd *pluginListCmd) run() error { 47 debug("pluginDirs: %s", settings.PluginDirs()) 48 plugins, err := findPlugins(settings.PluginDirs()) 49 if err != nil { 50 return err 51 } 52 53 table := uitable.New() 54 table.AddRow("NAME", "VERSION", "DESCRIPTION") 55 for _, p := range plugins { 56 table.AddRow(p.Metadata.Name, p.Metadata.Version, p.Metadata.Description) 57 } 58 fmt.Fprintln(pcmd.out, table) 59 return nil 60 }