Show link to plugin docs after install. Update the welcome message. Closes #53

This commit is contained in:
kaidaguerre
2021-01-28 13:42:40 +00:00
committed by GitHub
parent 112fdc609e
commit dbc19fbd54
4 changed files with 23 additions and 17 deletions

View File

@@ -161,9 +161,9 @@ func runPluginInstallCmd(cmd *cobra.Command, args []string) {
// args to 'plugin install' -- one or more plugins to install
// These can be simple names ('aws') for "standard" plugins, or
// full refs to the OCI image (us-docker.pkg.dev/steampipe/plugin/turbot/aws:1.0.0)
for _, arg := range args {
if _, err := pluginmanager.Install(arg); err != nil {
msg := fmt.Sprintf("plugin install failed for plugin '%s'", arg)
for _, plugin := range args {
if image, err := pluginmanager.Install(plugin); err != nil {
msg := fmt.Sprintf("plugin install failed for plugin '%s'", plugin)
if strings.HasSuffix(err.Error(), "not found") {
msg += ": not found"
} else {
@@ -172,9 +172,14 @@ func runPluginInstallCmd(cmd *cobra.Command, args []string) {
utils.ShowError(fmt.Errorf(msg))
return
} else {
fmt.Println("Installed plugin:", arg)
fmt.Println("Installed plugin:", plugin)
org := image.Config.Plugin.Organization
if org == "turbot" {
fmt.Println(fmt.Sprintf("For documentation see https://hub.steampipe.io/plugins/%s/%s\n", org, plugin))
}
}
}
}
func runPluginListCmd(cmd *cobra.Command, args []string) {

View File

@@ -64,8 +64,8 @@ func (c *InteractiveClient) InteractiveQuery(resultsStreamer *ResultStreamer, on
resultsStreamer.close()
}()
fmt.Printf("Welcome to Steampipe v%s. For help, type '.help'\n", version.String())
fmt.Println("Type \".inspect\" for more information.")
fmt.Printf("Welcome to Steampipe v%s\n", version.String())
fmt.Printf("For more information, type %s\n", constants.Bold(".help"))
for {
rerun := c.runInteractivePrompt(resultsStreamer)

View File

@@ -13,7 +13,7 @@ import (
)
// InstallPlugin :: Install a plugin from an OCI Image
func InstallPlugin(imageRef string) (string, error) {
func InstallPlugin(imageRef string) (*SteampipeImage, error) {
tempDir := NewTempDir(imageRef)
defer tempDir.Delete()
@@ -22,23 +22,23 @@ func InstallPlugin(imageRef string) (string, error) {
image, err := imageDownloader.Download(ref.ActualImageRef(), "plugin", tempDir.Path)
if err != nil {
return "", err
return nil, err
}
if err = installPluginBinary(image, tempDir.Path); err != nil {
return "", fmt.Errorf("plugin installation failed: %s", err)
return nil, fmt.Errorf("plugin installation failed: %s", err)
}
if err = installPluginDocs(image, tempDir.Path); err != nil {
return "", fmt.Errorf("plugin installation failed: %s", err)
return nil, fmt.Errorf("plugin installation failed: %s", err)
}
if err = installPluginConfigFiles(image, tempDir.Path); err != nil {
return "", fmt.Errorf("plugin installation failed: %s", err)
return nil, fmt.Errorf("plugin installation failed: %s", err)
}
if err := updateVersionFilePlugin(image); err != nil {
return string(image.OCIDescriptor.Digest), err
return nil, err
}
return string(image.OCIDescriptor.Digest), nil
return image, nil
}
func updateVersionFilePlugin(image *SteampipeImage) error {

View File

@@ -56,11 +56,12 @@ func Remove(image string, pluginConnections map[string][]string) error {
}
// Install :: install plugin in the local file system
func Install(image string) (string, error) {
spinner := utils.ShowSpinner(fmt.Sprintf("Installing plugin %s...", image))
func Install(plugin string) (*ociinstaller.SteampipeImage, error) {
spinner := utils.ShowSpinner(fmt.Sprintf("Installing plugin %s...", plugin))
defer utils.StopSpinner(spinner)
digest, err := ociinstaller.InstallPlugin(image)
return digest, err
image, err := ociinstaller.InstallPlugin(plugin)
return image, err
}
// PluginListItem :: an item in the list of plugins