(out io.Writer)
| 30 | ) |
| 31 | |
| 32 | func newPluginListCmd(out io.Writer) *cobra.Command { |
| 33 | var pluginType string |
| 34 | cmd := &cobra.Command{ |
| 35 | Use: "list", |
| 36 | Aliases: []string{"ls"}, |
| 37 | Short: "list installed Helm plugins", |
| 38 | ValidArgsFunction: noMoreArgsCompFunc, |
| 39 | RunE: func(_ *cobra.Command, _ []string) error { |
| 40 | slog.Debug("pluginDirs", "directory", settings.PluginsDirectory) |
| 41 | dirs := filepath.SplitList(settings.PluginsDirectory) |
| 42 | descriptor := plugin.Descriptor{ |
| 43 | Type: pluginType, |
| 44 | } |
| 45 | plugins, err := plugin.FindPlugins(dirs, descriptor) |
| 46 | if err != nil { |
| 47 | return err |
| 48 | } |
| 49 | |
| 50 | // Get signing info for all plugins |
| 51 | signingInfo := plugin.GetSigningInfoForPlugins(plugins) |
| 52 | |
| 53 | table := uitable.New() |
| 54 | table.AddRow("NAME", "VERSION", "TYPE", "APIVERSION", "PROVENANCE", "SOURCE") |
| 55 | for _, p := range plugins { |
| 56 | m := p.Metadata() |
| 57 | sourceURL := m.SourceURL |
| 58 | if sourceURL == "" { |
| 59 | sourceURL = "unknown" |
| 60 | } |
| 61 | // Get signing status |
| 62 | signedStatus := "unknown" |
| 63 | if info, ok := signingInfo[m.Name]; ok { |
| 64 | signedStatus = info.Status |
| 65 | } |
| 66 | table.AddRow(m.Name, m.Version, m.Type, m.APIVersion, signedStatus, sourceURL) |
| 67 | } |
| 68 | fmt.Fprintln(out, table) |
| 69 | return nil |
| 70 | }, |
| 71 | } |
| 72 | |
| 73 | f := cmd.Flags() |
| 74 | f.StringVar(&pluginType, "type", "", "Plugin type") |
| 75 | |
| 76 | return cmd |
| 77 | } |
| 78 | |
| 79 | // Returns all plugins from plugins, except those with names matching ignoredPluginNames |
| 80 | func filterPlugins(plugins []plugin.Plugin, ignoredPluginNames []string) []plugin.Plugin { |
no test coverage detected
searching dependent graphs…