MCPcopy
hub / github.com/turbot/steampipe / showPluginListAsJSON

Function showPluginListAsJSON

cmd/plugin.go:751–800  ·  view source on GitHub ↗
(pluginList []plugin.PluginListItem, failedPluginMap, missingPluginMap map[string][]plugin.PluginConnection, res perror_helpers.ErrorAndWarnings)

Source from the content-addressed store, hash-verified

749}
750
751func showPluginListAsJSON(pluginList []plugin.PluginListItem, failedPluginMap, missingPluginMap map[string][]plugin.PluginConnection, res perror_helpers.ErrorAndWarnings) error {
752 output := pluginJsonOutput{}
753
754 for _, item := range pluginList {
755 installed := installedPlugin{
756 Name: item.Name,
757 Version: item.Version.String(),
758 Connections: item.Connections,
759 }
760 output.Installed = append(output.Installed, installed)
761 }
762
763 for p, item := range failedPluginMap {
764 connections := make([]string, len(item))
765 for i, conn := range item {
766 connections[i] = conn.GetName()
767 }
768 failed := failedPlugin{
769 Name: p,
770 Connections: connections,
771 Reason: pconstants.ConnectionErrorPluginFailedToStart,
772 }
773 output.Failed = append(output.Failed, failed)
774 }
775
776 for p, item := range missingPluginMap {
777 connections := make([]string, len(item))
778 for i, conn := range item {
779 connections[i] = conn.GetName()
780 }
781 missing := failedPlugin{
782 Name: p,
783 Connections: connections,
784 Reason: pconstants.InstallMessagePluginNotInstalled,
785 }
786 output.Failed = append(output.Failed, missing)
787 }
788
789 if len(res.Warnings) > 0 {
790 output.Warnings = res.Warnings
791 }
792
793 jsonOutput, err := json.MarshalIndent(output, "", " ")
794 if err != nil {
795 return err
796 }
797 fmt.Println(string(jsonOutput))
798 fmt.Println()
799 return nil
800}
801
802func runPluginUninstallCmd(cmd *cobra.Command, args []string) {
803 // setup a cancel context and start cancel handler

Callers 1

showPluginListOutputFunction · 0.85

Calls 2

GetNameMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected