Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes nil pointer exception in steampipe plugin. Closes #678 #681

Merged
merged 2 commits into from
Jul 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions cmd/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ Find plugins using the public registry at https://hub.steampipe.io.

Examples:

# Install or update a plugin
# Install a plugin
steampipe plugin install aws

# Update a plugin
steampipe plugin update aws

# List installed plugins
steampipe plugin list

Expand All @@ -48,8 +51,6 @@ Examples:
cmd.AddCommand(pluginUninstallCmd())
cmd.AddCommand(pluginUpdateCmd())

cmdconfig.OnCmd(cmd)

return cmd
}

Expand Down
11 changes: 8 additions & 3 deletions cmdconfig/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ func OnCmd(cmd *cobra.Command) *CmdBuilder {

// we will wrap over these two function - need references to call them
originalPreRun := cfg.cmd.PreRun
originalRun := cfg.cmd.Run

cfg.cmd.PreRun = func(cmd *cobra.Command, args []string) {
utils.LogTime(fmt.Sprintf("cmd.%s.PreRun start", cmd.CommandPath()))
defer utils.LogTime(fmt.Sprintf("cmd.%s.PreRun end", cmd.CommandPath()))
// bind flags
for flagName, flag := range cfg.bindings {
viper.GetViper().BindPFlag(flagName, flag)
Expand All @@ -35,11 +35,16 @@ func OnCmd(cmd *cobra.Command) *CmdBuilder {
}
}

// wrap over the original Run function
originalRun := cfg.cmd.Run
cfg.cmd.Run = func(cmd *cobra.Command, args []string) {
utils.LogTime(fmt.Sprintf("cmd.%s.Run start", cmd.CommandPath()))
defer utils.LogTime(fmt.Sprintf("cmd.%s.Run end", cmd.CommandPath()))

originalRun(cmd, args)
// run the original Run
if originalRun != nil {
originalRun(cmd, args)
}
}

return cfg
Expand Down