mirror of
https://github.com/turbot/steampipe.git
synced 2025-12-19 18:12:43 -05:00
tidy
This commit is contained in:
@@ -16,9 +16,9 @@ import (
|
||||
pconstants "github.com/turbot/pipe-fittings/constants"
|
||||
perror_helpers "github.com/turbot/pipe-fittings/error_helpers"
|
||||
putils "github.com/turbot/pipe-fittings/ociinstaller"
|
||||
"github.com/turbot/pipe-fittings/ociinstaller/versionfile"
|
||||
pplugin "github.com/turbot/pipe-fittings/plugin"
|
||||
"github.com/turbot/pipe-fittings/utils"
|
||||
"github.com/turbot/pipe-fittings/versionfile"
|
||||
"github.com/turbot/steampipe-plugin-sdk/v5/sperr"
|
||||
"github.com/turbot/steampipe/pkg/cmdconfig"
|
||||
"github.com/turbot/steampipe/pkg/constants"
|
||||
|
||||
@@ -24,8 +24,8 @@ import (
|
||||
"github.com/turbot/go-kit/logging"
|
||||
"github.com/turbot/pipe-fittings/app_specific"
|
||||
perror_helpers "github.com/turbot/pipe-fittings/error_helpers"
|
||||
"github.com/turbot/pipe-fittings/ociinstaller/versionfile"
|
||||
"github.com/turbot/pipe-fittings/utils"
|
||||
"github.com/turbot/pipe-fittings/versionfile"
|
||||
sdklogging "github.com/turbot/steampipe-plugin-sdk/v5/logging"
|
||||
"github.com/turbot/steampipe-plugin-sdk/v5/plugin"
|
||||
"github.com/turbot/steampipe-plugin-sdk/v5/sperr"
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
putils "github.com/turbot/pipe-fittings/utils"
|
||||
"github.com/turbot/steampipe/pkg/constants"
|
||||
"github.com/turbot/steampipe/pkg/filepaths"
|
||||
versionfile "github.com/turbot/steampipe/pkg/ociinstaller/versionfile"
|
||||
"github.com/turbot/steampipe/pkg/ociinstaller/versionfile"
|
||||
)
|
||||
|
||||
// InstallFdw installs the Steampipe Postgres foreign data wrapper from an OCI image
|
||||
@@ -44,7 +44,7 @@ func InstallFdw(ctx context.Context, dbLocation string) (string, error) {
|
||||
return string(image.OCIDescriptor.Digest), nil
|
||||
}
|
||||
|
||||
func updateVersionFileFdw(image *ociinstaller.OciImage[*fdwImage, *FdwIfageConfig]) error {
|
||||
func updateVersionFileFdw(image *ociinstaller.OciImage[*fdwImage, *FdwImageConfig]) error {
|
||||
timeNow := putils.FormatTime(time.Now())
|
||||
v, err := versionfile.LoadDatabaseVersionFile()
|
||||
if err != nil {
|
||||
@@ -59,7 +59,7 @@ func updateVersionFileFdw(image *ociinstaller.OciImage[*fdwImage, *FdwIfageConfi
|
||||
return v.Save()
|
||||
}
|
||||
|
||||
func installFdwFiles(image *ociinstaller.OciImage[*fdwImage, *FdwIfageConfig], tempdir string) error {
|
||||
func installFdwFiles(image *ociinstaller.OciImage[*fdwImage, *FdwImageConfig], tempdir string) error {
|
||||
fdwBinDir := filepaths.GetFDWBinaryDir()
|
||||
fdwBinFileSourcePath := filepath.Join(tempdir, image.Data.BinaryFile)
|
||||
fdwBinFileDestPath := filepath.Join(fdwBinDir, constants.FdwBinaryFileName)
|
||||
|
||||
@@ -8,18 +8,18 @@ import (
|
||||
)
|
||||
|
||||
type fdwDownloader struct {
|
||||
ociinstaller.OciDownloader[*fdwImage, *FdwIfageConfig]
|
||||
ociinstaller.OciDownloader[*fdwImage, *FdwImageConfig]
|
||||
}
|
||||
|
||||
func (p *fdwDownloader) EmptyConfig() *FdwIfageConfig {
|
||||
return &FdwIfageConfig{}
|
||||
func (p *fdwDownloader) EmptyConfig() *FdwImageConfig {
|
||||
return &FdwImageConfig{}
|
||||
}
|
||||
|
||||
func newFdwDownloader() *fdwDownloader {
|
||||
res := &fdwDownloader{}
|
||||
|
||||
// create the base downloader, passing res as the image provider
|
||||
ociDownloader := ociinstaller.NewOciDownloader[*fdwImage, *FdwIfageConfig](constants.BaseImageRef, SteampipeMediaTypeProvider{}, res)
|
||||
ociDownloader := ociinstaller.NewOciDownloader[*fdwImage, *FdwImageConfig](constants.BaseImageRef, SteampipeMediaTypeProvider{}, res)
|
||||
|
||||
res.OciDownloader = *ociDownloader
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ func (s *fdwImage) Type() ociinstaller.ImageType {
|
||||
return ImageTypeFdw
|
||||
}
|
||||
|
||||
type FdwIfageConfig struct {
|
||||
type FdwImageConfig struct {
|
||||
ociinstaller.OciConfigBase
|
||||
Fdw struct {
|
||||
Name string `json:"name,omitempty"`
|
||||
|
||||
@@ -3,7 +3,7 @@ package versionfile
|
||||
import (
|
||||
"encoding/json"
|
||||
filehelpers "github.com/turbot/go-kit/files"
|
||||
versionfile2 "github.com/turbot/pipe-fittings/ociinstaller/versionfile"
|
||||
"github.com/turbot/pipe-fittings/versionfile"
|
||||
"github.com/turbot/steampipe/pkg/filepaths"
|
||||
"log"
|
||||
"os"
|
||||
@@ -12,15 +12,15 @@ import (
|
||||
const DatabaseStructVersion = 20220411
|
||||
|
||||
type DatabaseVersionFile struct {
|
||||
FdwExtension versionfile2.InstalledVersion `json:"fdw_extension"`
|
||||
EmbeddedDB versionfile2.InstalledVersion `json:"embedded_db"`
|
||||
StructVersion int64 `json:"struct_version"`
|
||||
FdwExtension versionfile.InstalledVersion `json:"fdw_extension"`
|
||||
EmbeddedDB versionfile.InstalledVersion `json:"embedded_db"`
|
||||
StructVersion int64 `json:"struct_version"`
|
||||
}
|
||||
|
||||
func NewDBVersionFile() *DatabaseVersionFile {
|
||||
return &DatabaseVersionFile{
|
||||
FdwExtension: versionfile2.InstalledVersion{},
|
||||
EmbeddedDB: versionfile2.InstalledVersion{},
|
||||
FdwExtension: versionfile.InstalledVersion{},
|
||||
EmbeddedDB: versionfile.InstalledVersion{},
|
||||
StructVersion: DatabaseStructVersion,
|
||||
}
|
||||
}
|
||||
@@ -47,12 +47,12 @@ func readDatabaseVersionFile(path string) (*DatabaseVersionFile, error) {
|
||||
log.Println("[ERROR]", "Error while reading DB version file", err)
|
||||
return nil, err
|
||||
}
|
||||
if data.FdwExtension == (versionfile2.InstalledVersion{}) {
|
||||
data.FdwExtension = versionfile2.InstalledVersion{}
|
||||
if data.FdwExtension == (versionfile.InstalledVersion{}) {
|
||||
data.FdwExtension = versionfile.InstalledVersion{}
|
||||
}
|
||||
|
||||
if data.EmbeddedDB == (versionfile2.InstalledVersion{}) {
|
||||
data.EmbeddedDB = versionfile2.InstalledVersion{}
|
||||
if data.EmbeddedDB == (versionfile.InstalledVersion{}) {
|
||||
data.EmbeddedDB = versionfile.InstalledVersion{}
|
||||
}
|
||||
|
||||
return &data, nil
|
||||
|
||||
@@ -3,7 +3,6 @@ package plugin
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
plugin2 "github.com/turbot/pipe-fittings/plugin"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -12,8 +11,9 @@ import (
|
||||
"github.com/turbot/go-kit/files"
|
||||
"github.com/turbot/pipe-fittings/filepaths"
|
||||
"github.com/turbot/pipe-fittings/ociinstaller"
|
||||
"github.com/turbot/pipe-fittings/ociinstaller/versionfile"
|
||||
"github.com/turbot/pipe-fittings/plugin"
|
||||
"github.com/turbot/pipe-fittings/statushooks"
|
||||
"github.com/turbot/pipe-fittings/versionfile"
|
||||
"github.com/turbot/steampipe-plugin-sdk/v5/sperr"
|
||||
)
|
||||
|
||||
@@ -50,7 +50,7 @@ func Remove(ctx context.Context, image string, pluginConnections map[string][]Pl
|
||||
}
|
||||
|
||||
// Install installs a plugin in the local file system
|
||||
func Install(ctx context.Context, plugin plugin2.ResolvedPluginVersion, sub chan struct{}, baseImageRef string, mediaTypesProvider ociinstaller.MediaTypeProvider, opts ...ociinstaller.PluginInstallOption) (*ociinstaller.OciImage[*ociinstaller.PluginImage, *ociinstaller.PluginImageConfig], error) {
|
||||
func Install(ctx context.Context, plugin plugin.ResolvedPluginVersion, sub chan struct{}, baseImageRef string, mediaTypesProvider ociinstaller.MediaTypeProvider, opts ...ociinstaller.PluginInstallOption) (*ociinstaller.OciImage[*ociinstaller.PluginImage, *ociinstaller.PluginImageConfig], error) {
|
||||
// Note: we pass the plugin info as strings here rather than passing the ResolvedPluginVersion struct as that causes circular dependency
|
||||
image, err := ociinstaller.InstallPlugin(ctx, plugin.GetVersionTag(), plugin.Constraint, sub, baseImageRef, mediaTypesProvider, opts...)
|
||||
return image, err
|
||||
@@ -59,7 +59,7 @@ func Install(ctx context.Context, plugin plugin2.ResolvedPluginVersion, sub chan
|
||||
// PluginListItem is a struct representing an item in the list of plugins
|
||||
type PluginListItem struct {
|
||||
Name string
|
||||
Version *plugin2.PluginVersionString
|
||||
Version *plugin.PluginVersionString
|
||||
Connections []string
|
||||
}
|
||||
|
||||
@@ -85,14 +85,14 @@ func List(ctx context.Context, pluginConnectionMap map[string][]PluginConnection
|
||||
// for local plugin
|
||||
item := PluginListItem{
|
||||
Name: fullPluginName,
|
||||
Version: plugin2.LocalPluginVersionString(),
|
||||
Version: plugin.LocalPluginVersionString(),
|
||||
}
|
||||
// check if this plugin is recorded in plugin versions
|
||||
installation, found := pluginVersions[fullPluginName]
|
||||
if found {
|
||||
// if not a local plugin, get the semver version
|
||||
if !detectLocalPlugin(installation, pluginBinary) {
|
||||
item.Version, err = plugin2.NewPluginVersionString(installation.Version)
|
||||
item.Version, err = plugin.NewPluginVersionString(installation.Version)
|
||||
if err != nil {
|
||||
return nil, sperr.WrapWithMessage(err, "could not evaluate plugin version %s", installation.Version)
|
||||
}
|
||||
|
||||
@@ -4,14 +4,14 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/turbot/pipe-fittings/ociinstaller"
|
||||
"github.com/turbot/pipe-fittings/ociinstaller/versionfile"
|
||||
plugin2 "github.com/turbot/pipe-fittings/plugin"
|
||||
"github.com/turbot/pipe-fittings/plugin"
|
||||
"github.com/turbot/pipe-fittings/versionfile"
|
||||
)
|
||||
|
||||
// GetInstalledPlugins returns the list of plugins keyed by the shortname (org/name) and its specific version
|
||||
// Does not validate/check of available connections
|
||||
func GetInstalledPlugins(ctx context.Context, pluginVersions map[string]*versionfile.InstalledVersion) (map[string]*plugin2.PluginVersionString, error) {
|
||||
installedPlugins := make(map[string]*plugin2.PluginVersionString)
|
||||
func GetInstalledPlugins(ctx context.Context, pluginVersions map[string]*versionfile.InstalledVersion) (map[string]*plugin.PluginVersionString, error) {
|
||||
installedPlugins := make(map[string]*plugin.PluginVersionString)
|
||||
installedPluginsData, _ := List(ctx, nil, pluginVersions)
|
||||
for _, plugin := range installedPluginsData {
|
||||
org, name, _ := ociinstaller.NewImageRef(plugin.Name).GetOrgNameAndStream()
|
||||
|
||||
@@ -18,10 +18,10 @@ import (
|
||||
perror_helpers "github.com/turbot/pipe-fittings/error_helpers"
|
||||
pfilepaths "github.com/turbot/pipe-fittings/filepaths"
|
||||
"github.com/turbot/pipe-fittings/hclhelpers"
|
||||
"github.com/turbot/pipe-fittings/ociinstaller/versionfile"
|
||||
"github.com/turbot/pipe-fittings/options"
|
||||
pparse "github.com/turbot/pipe-fittings/parse"
|
||||
"github.com/turbot/pipe-fittings/utils"
|
||||
"github.com/turbot/pipe-fittings/versionfile"
|
||||
"github.com/turbot/pipe-fittings/workspace_profile"
|
||||
"github.com/turbot/steampipe-plugin-sdk/v5/sperr"
|
||||
"github.com/turbot/steampipe/pkg/constants"
|
||||
|
||||
@@ -2,7 +2,6 @@ package steampipeconfig
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/turbot/pipe-fittings/constants"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
@@ -10,12 +9,13 @@ import (
|
||||
"github.com/hashicorp/go-version"
|
||||
"github.com/turbot/go-kit/helpers"
|
||||
typehelpers "github.com/turbot/go-kit/types"
|
||||
"github.com/turbot/pipe-fittings/constants"
|
||||
"github.com/turbot/pipe-fittings/error_helpers"
|
||||
"github.com/turbot/pipe-fittings/filepaths"
|
||||
"github.com/turbot/pipe-fittings/ociinstaller"
|
||||
"github.com/turbot/pipe-fittings/ociinstaller/versionfile"
|
||||
"github.com/turbot/pipe-fittings/options"
|
||||
"github.com/turbot/pipe-fittings/plugin"
|
||||
"github.com/turbot/pipe-fittings/versionfile"
|
||||
"github.com/turbot/pipe-fittings/workspace_profile"
|
||||
"github.com/turbot/steampipe-plugin-sdk/v5/sperr"
|
||||
"github.com/turbot/steampipe/pkg/steampipeconfig/modconfig"
|
||||
|
||||
Reference in New Issue
Block a user