Skip to content

Commit

Permalink
fix: extract hub.steampipe.io/ as a constant
Browse files Browse the repository at this point in the history
  • Loading branch information
pdecat committed Jul 12, 2023
1 parent 47e6366 commit 2eeffaa
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ func runPluginUpdateCmd(cmd *cobra.Command, args []string) {
ref := ociinstaller.NewSteampipeImageRef(p)
isExists, _ := plugin.Exists(p)
if isExists {
if strings.HasPrefix(ref.DisplayImageRef(), "hub.steampipe.io/") {
if strings.HasPrefix(ref.DisplayImageRef(), constants.SteampipeHubOCIBase) {
runUpdatesFor = append(runUpdatesFor, versionData.Plugins[ref.DisplayImageRef()])
} else {
error_helpers.ShowError(ctx, fmt.Errorf("cannot check updates for plugins not distributed via hub.steampipe.io, you should uninstall then reinstall the plugin to get the latest version"))
Expand Down
2 changes: 2 additions & 0 deletions pkg/constants/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ const (
InstallMessagePluginNotFound = "Not found"
ConnectionErrorPluginFailedToStart = "plugin failed to start"
ConnectionErrorPluginNotInstalled = "plugin not installed"

SteampipeHubOCIBase = "hub.steampipe.io/"
)
4 changes: 3 additions & 1 deletion pkg/ociinstaller/imageref.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package ociinstaller
import (
"fmt"
"strings"

"github.com/turbot/steampipe/pkg/constants"
)

const (
Expand Down Expand Up @@ -88,7 +90,7 @@ func (r *SteampipeImageRef) GetOrgNameAndStream() (string, string, string) {
// plugin.Name looks like `hub.steampipe.io/plugins/turbot/aws@latest`
split := strings.Split(r.DisplayImageRef(), "/")
pluginNameAndStream := strings.Split(split[len(split)-1], "@")
if strings.HasPrefix(r.DisplayImageRef(), "hub.steampipe.io/") {
if strings.HasPrefix(r.DisplayImageRef(), constants.SteampipeHubOCIBase) {
return split[len(split)-2], pluginNameAndStream[0], pluginNameAndStream[1]
}
return strings.Join(split[0:len(split)-2], "/"), pluginNameAndStream[0], pluginNameAndStream[1]
Expand Down

0 comments on commit 2eeffaa

Please sign in to comment.