working on it

This commit is contained in:
kai
2024-08-30 15:21:05 +01:00
committed by Puskar Basu
parent faead86d26
commit cd07bf20f1
148 changed files with 309 additions and 1711 deletions

View File

@@ -5,7 +5,6 @@ import (
"encoding/json"
"errors"
"fmt"
putils "github.com/turbot/pipe-fittings/ociinstaller"
"strings"
"sync"
"time"
@@ -15,7 +14,10 @@ import (
"github.com/spf13/viper"
"github.com/turbot/go-kit/helpers"
perror_helpers "github.com/turbot/pipe-fittings/error_helpers"
putils "github.com/turbot/pipe-fittings/ociinstaller"
"github.com/turbot/pipe-fittings/ociinstaller/versionfile"
"github.com/turbot/pipe-fittings/plugin"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe-plugin-sdk/v5/sperr"
"github.com/turbot/steampipe/pkg/cmdconfig"
"github.com/turbot/steampipe/pkg/constants"
@@ -25,11 +27,9 @@ import (
"github.com/turbot/steampipe/pkg/error_helpers"
"github.com/turbot/steampipe/pkg/installationstate"
"github.com/turbot/steampipe/pkg/ociinstaller"
"github.com/turbot/steampipe/pkg/plugin"
"github.com/turbot/steampipe/pkg/statushooks"
"github.com/turbot/steampipe/pkg/steampipeconfig"
"github.com/turbot/steampipe/pkg/steampipeconfig/modconfig"
"github.com/turbot/steampipe/pkg/utils"
)
type installedPlugin struct {
@@ -489,7 +489,7 @@ func runPluginUpdateCmd(cmd *cobra.Command, args []string) {
defer cancel()
statushooks.SetStatus(ctx, "Checking for available updates")
reports := plugin.GetUpdateReport(timeoutCtx, state.InstallationID, runUpdatesFor)
reports := plugin.GetUpdateReport(timeoutCtx, state.InstallationID, runUpdatesFor, constants.SteampipeHubOCIBase)
statushooks.Done(ctx)
if len(reports) == 0 {
// this happens if for some reason the update server could not be contacted,
@@ -535,7 +535,7 @@ func runPluginUpdateCmd(cmd *cobra.Command, args []string) {
fmt.Println()
}
func doPluginUpdate(ctx context.Context, bar *uiprogress.Bar, pvr plugin.VersionCheckReport, wg *sync.WaitGroup, returnChannel chan *display.PluginInstallReport) {
func doPluginUpdate(ctx context.Context, bar *uiprogress.Bar, pvr plugin.PluginVersionCheckReport, wg *sync.WaitGroup, returnChannel chan *display.PluginInstallReport) {
var report *display.PluginInstallReport
if plugin.UpdateRequired(pvr) {

View File

@@ -14,6 +14,7 @@ import (
"github.com/spf13/viper"
"github.com/thediveo/enumflag/v2"
"github.com/turbot/go-kit/helpers"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe-plugin-sdk/v5/sperr"
"github.com/turbot/steampipe/pkg/cloud"
"github.com/turbot/steampipe/pkg/cmdconfig"
@@ -29,7 +30,6 @@ import (
"github.com/turbot/steampipe/pkg/snapshot"
"github.com/turbot/steampipe/pkg/statushooks"
"github.com/turbot/steampipe/pkg/steampipeconfig/modconfig"
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/steampipe/pkg/workspace"
)

View File

@@ -9,16 +9,17 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
filehelpers "github.com/turbot/go-kit/files"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/error_helpers"
"github.com/turbot/steampipe/pkg/filepaths"
"github.com/turbot/steampipe/pkg/statushooks"
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/steampipe/pkg/version"
)
var exitCode int
// rootCmd represents the base command when called without any subcommands
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "steampipe [--version] [--help] COMMAND [args]",

View File

@@ -14,6 +14,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/turbot/go-kit/helpers"
putils "github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe-plugin-sdk/v5/sperr"
"github.com/turbot/steampipe/pkg/cmdconfig"
"github.com/turbot/steampipe/pkg/constants"
@@ -136,9 +137,9 @@ func serviceRestartCmd() *cobra.Command {
func runServiceStartCmd(cmd *cobra.Command, _ []string) {
ctx := cmd.Context()
utils.LogTime("runServiceStartCmd start")
putils.LogTime("runServiceStartCmd start")
defer func() {
utils.LogTime("runServiceStartCmd end")
putils.LogTime("runServiceStartCmd end")
if r := recover(); r != nil {
error_helpers.ShowError(ctx, helpers.ToError(r))
if exitCode == constants.ExitCodeSuccessful {
@@ -304,9 +305,9 @@ func runServiceInForeground(ctx context.Context) {
func runServiceRestartCmd(cmd *cobra.Command, _ []string) {
ctx := cmd.Context()
utils.LogTime("runServiceRestartCmd start")
putils.LogTime("runServiceRestartCmd start")
defer func() {
utils.LogTime("runServiceRestartCmd end")
putils.LogTime("runServiceRestartCmd end")
if r := recover(); r != nil {
error_helpers.ShowError(ctx, helpers.ToError(r))
if exitCode == constants.ExitCodeSuccessful {
@@ -380,9 +381,9 @@ to force a restart.
func runServiceStatusCmd(cmd *cobra.Command, _ []string) {
ctx := cmd.Context()
utils.LogTime("runServiceStatusCmd status")
putils.LogTime("runServiceStatusCmd status")
defer func() {
utils.LogTime("runServiceStatusCmd end")
putils.LogTime("runServiceStatusCmd end")
if r := recover(); r != nil {
error_helpers.ShowError(ctx, helpers.ToError(r))
}
@@ -424,14 +425,14 @@ func composeStateError(dbStateErr error, pmStateErr error) error {
func runServiceStopCmd(cmd *cobra.Command, _ []string) {
ctx := cmd.Context()
utils.LogTime("runServiceStopCmd stop")
putils.LogTime("runServiceStopCmd stop")
var status db_local.StopStatus
var dbStopError error
var dbState *db_local.RunningDBInstanceInfo
defer func() {
utils.LogTime("runServiceStopCmd end")
putils.LogTime("runServiceStopCmd end")
if r := recover(); r != nil {
error_helpers.ShowError(ctx, helpers.ToError(r))
if exitCode == constants.ExitCodeSuccessful {

View File

@@ -12,10 +12,10 @@ import (
"github.com/hashicorp/go-version"
_ "github.com/jackc/pgx/v5/stdlib"
"github.com/turbot/go-kit/helpers"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/cmd"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/error_helpers"
"github.com/turbot/steampipe/pkg/utils"
)
var exitCode int = constants.ExitCodeSuccessful

View File

@@ -11,11 +11,11 @@ import (
"github.com/spf13/viper"
filehelpers "github.com/turbot/go-kit/files"
"github.com/turbot/pipe-fittings/utils"
steampipecloud "github.com/turbot/steampipe-cloud-sdk-go"
"github.com/turbot/steampipe-plugin-sdk/v5/sperr"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/filepaths"
"github.com/turbot/steampipe/pkg/utils"
)
var UnconfirmedError = "Not confirmed"

View File

@@ -0,0 +1,58 @@
package cmdconfig
import (
"github.com/Masterminds/semver/v3"
"github.com/spf13/viper"
"os"
"path/filepath"
"strings"
"github.com/turbot/go-kit/files"
"github.com/turbot/pipe-fittings/app_specific"
"github.com/turbot/pipe-fittings/cmdconfig"
"github.com/turbot/pipe-fittings/error_helpers"
)
// TODO kai FIX ME!!!!!
// SetAppSpecificConstants sets app specific constants defined in pipe-fittings
func SetAppSpecificConstants() {
app_specific.AppName = "steampipe"
versionString := viper.GetString("main.version")
app_specific.AppVersion = semver.MustParse(versionString)
// set all app specific env var keys
app_specific.SetAppSpecificEnvVarKeys("STEAMPIPE_")
app_specific.ConfigExtension = ".tpc"
// set the command pre and post hooks
cmdconfig.CustomPreRunHook = preRunHook
cmdconfig.CustomPostRunHook = postRunHook
// Version check
app_specific.VersionCheckHost = "hub.steampipe.io"
app_specific.VersionCheckPath = "api/cli/version/latest"
// set the default install dir
defaultInstallDir, err := files.Tildefy("~/.steampipe")
error_helpers.FailOnError(err)
app_specific.DefaultInstallDir = defaultInstallDir
// set the default config path
globalConfigPath := filepath.Join(defaultInstallDir, "config")
// check whether install-dir env has been set - if so, respect it
if envInstallDir, ok := os.LookupEnv(app_specific.EnvInstallDir); ok {
globalConfigPath = filepath.Join(envInstallDir, "config")
app_specific.InstallDir = envInstallDir
} else {
/*
NOTE:
If InstallDir is settable outside of default & env var, need to add
the following code to end of initGlobalConfig in init.go
app_specific.InstallDir = viper.GetString(constants.ArgInstallDir) at end of
*/
app_specific.InstallDir = defaultInstallDir
}
app_specific.DefaultConfigPath = strings.Join([]string{".", globalConfigPath}, ":")
}

View File

@@ -7,9 +7,9 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/error_helpers"
"github.com/turbot/steampipe/pkg/utils"
)
type CmdBuilder struct {

View File

@@ -21,6 +21,7 @@ import (
filehelpers "github.com/turbot/go-kit/files"
"github.com/turbot/go-kit/helpers"
"github.com/turbot/go-kit/logging"
"github.com/turbot/pipe-fittings/utils"
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"
@@ -31,7 +32,6 @@ import (
"github.com/turbot/steampipe/pkg/filepaths"
"github.com/turbot/steampipe/pkg/steampipeconfig"
"github.com/turbot/steampipe/pkg/task"
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/steampipe/pkg/version"
)

View File

@@ -16,6 +16,7 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/turbot/go-kit/helpers"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/v5/plugin"
"github.com/turbot/steampipe-plugin-sdk/v5/sperr"
@@ -25,7 +26,6 @@ import (
"github.com/turbot/steampipe/pkg/error_helpers"
"github.com/turbot/steampipe/pkg/introspection"
"github.com/turbot/steampipe/pkg/steampipeconfig"
"github.com/turbot/steampipe/pkg/utils"
"golang.org/x/exp/maps"
"golang.org/x/sync/semaphore"
)

View File

@@ -1,8 +1,8 @@
package dashboardevents
import (
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/dashboard/dashboardtypes"
"github.com/turbot/steampipe/pkg/utils"
"time"
)

View File

@@ -11,11 +11,11 @@ import (
"github.com/jackc/pgx/v5/pgconn"
"github.com/jackc/pgx/v5/pgxpool"
"github.com/spf13/viper"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/db/db_common"
"github.com/turbot/steampipe/pkg/serversettings"
"github.com/turbot/steampipe/pkg/steampipeconfig"
"github.com/turbot/steampipe/pkg/utils"
"golang.org/x/exp/maps"
"golang.org/x/sync/semaphore"
)

View File

@@ -8,10 +8,10 @@ import (
"github.com/jackc/pgx/v5/pgxpool"
"github.com/spf13/viper"
"github.com/turbot/go-kit/helpers"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/constants/runtime"
"github.com/turbot/steampipe/pkg/db/db_common"
"github.com/turbot/steampipe/pkg/utils"
)
const (

View File

@@ -14,12 +14,12 @@ import (
"github.com/jackc/pgx/v5/pgtype"
"github.com/spf13/viper"
"github.com/turbot/go-kit/helpers"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/db/db_common"
"github.com/turbot/steampipe/pkg/error_helpers"
"github.com/turbot/steampipe/pkg/query/queryresult"
"github.com/turbot/steampipe/pkg/statushooks"
"github.com/turbot/steampipe/pkg/utils"
"golang.org/x/text/language"
"golang.org/x/text/message"
)

View File

@@ -3,8 +3,8 @@ package db_common
import (
"context"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/query/queryresult"
"github.com/turbot/steampipe/pkg/utils"
)
// ExecuteQuery executes a single query. If shutdownAfterCompletion is true, shutdown the client after completion

View File

@@ -8,8 +8,8 @@ import (
"github.com/jackc/pgx/v5"
typeHelpers "github.com/turbot/go-kit/types"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/utils"
)
type schemaRecord struct {

View File

@@ -1,7 +1,7 @@
package db_common
import (
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/pipe-fittings/utils"
"golang.org/x/exp/maps"
"regexp"
"sort"

View File

@@ -10,10 +10,10 @@ import (
"github.com/jackc/pgx/v5/pgxpool"
"github.com/pkg/errors"
"github.com/sethvargo/go-retry"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/error_helpers"
"github.com/turbot/steampipe/pkg/statushooks"
"github.com/turbot/steampipe/pkg/utils"
)
var ErrServiceInRecoveryMode = errors.New("service is in recovery mode")

View File

@@ -16,6 +16,7 @@ import (
"github.com/turbot/go-kit/files"
"github.com/shirou/gopsutil/process"
putils "github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/error_helpers"
"github.com/turbot/steampipe/pkg/filepaths"
@@ -349,7 +350,7 @@ func runRestoreUsingList(ctx context.Context, info *RunningDBInstanceInfo, listF
// This needs to be done because the pg_dump will always set a blank search path in the backup archive
// and backed up MATERIALIZED VIEWS may have functions with unqualified table names
func partitionTableOfContents(ctx context.Context, tableOfContentsOfBackup []string) (string, string, error) {
onlyRefresh, withoutRefresh := utils.Partition(tableOfContentsOfBackup, func(v string) bool {
onlyRefresh, withoutRefresh := putils.Partition(tableOfContentsOfBackup, func(v string) bool {
return strings.Contains(strings.ToUpper(v), "MATERIALIZED VIEW DATA")
})
@@ -420,7 +421,7 @@ func retainBackup(ctx context.Context) error {
textBackupFilePath := filepath.Join(backupDir, textBackupRetentionFileName)
log.Println("[TRACE] moving database back up to", binaryBackupFilePath)
if err := utils.MoveFile(filepaths.DatabaseBackupFilePath(), binaryBackupFilePath); err != nil {
if err := putils.MoveFile(filepaths.DatabaseBackupFilePath(), binaryBackupFilePath); err != nil {
return err
}
log.Println("[TRACE] converting database back up to", textBackupFilePath)
@@ -475,7 +476,7 @@ func trimBackups() {
}
// retain only the .dump files (just to get the unique backups)
files = utils.Filter(files, func(v fs.DirEntry) bool {
files = putils.Filter(files, func(v fs.DirEntry) bool {
if v.Type().IsDir() {
return false
}
@@ -484,7 +485,7 @@ func trimBackups() {
})
// map to the names of the backups, without extensions
names := utils.Map(files, func(v fs.DirEntry) string {
names := putils.Map(files, func(v fs.DirEntry) string {
return strings.TrimSuffix(v.Name(), filepath.Ext(v.Name()))
})

View File

@@ -10,6 +10,7 @@ import (
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgxpool"
"github.com/spf13/viper"
putils "github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe-plugin-sdk/v5/sperr"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/constants/runtime"
@@ -23,8 +24,8 @@ func getLocalSteampipeConnectionString(opts *CreateDbOptions) (string, error) {
if opts == nil {
opts = &CreateDbOptions{}
}
utils.LogTime("db.createDbClient start")
defer utils.LogTime("db.createDbClient end")
putils.LogTime("db.createDbClient start")
defer putils.LogTime("db.createDbClient end")
// load the db status
info, err := GetState()
@@ -58,7 +59,7 @@ func getLocalSteampipeConnectionString(opts *CreateDbOptions) (string, error) {
"dbname": opts.DatabaseName,
}
log.Println("[TRACE] SQLInfoMap >>>", psqlInfoMap)
psqlInfoMap = utils.MergeMaps(psqlInfoMap, dsnSSLParams())
psqlInfoMap = putils.MergeMaps(psqlInfoMap, dsnSSLParams())
log.Println("[TRACE] SQLInfoMap >>>", psqlInfoMap)
psqlInfo := []string{}
@@ -80,8 +81,8 @@ type CreateDbOptions struct {
// that was created during installation.
// NOTE: this connection will use the ServiceConnectionAppName
func CreateLocalDbConnection(ctx context.Context, opts *CreateDbOptions) (*pgx.Conn, error) {
utils.LogTime("db.CreateLocalDbConnection start")
defer utils.LogTime("db.CreateLocalDbConnection end")
putils.LogTime("db.CreateLocalDbConnection start")
defer putils.LogTime("db.CreateLocalDbConnection end")
psqlInfo, err := getLocalSteampipeConnectionString(opts)
if err != nil {
@@ -118,8 +119,8 @@ func CreateLocalDbConnection(ctx context.Context, opts *CreateDbOptions) (*pgx.C
// CreateConnectionPool creates a connection pool using the provided options
// NOTE: this connection pool will use the ServiceConnectionAppName
func CreateConnectionPool(ctx context.Context, opts *CreateDbOptions, maxConnections int) (*pgxpool.Pool, error) {
utils.LogTime("db_client.establishConnectionPool start")
defer utils.LogTime("db_client.establishConnectionPool end")
putils.LogTime("db_client.establishConnectionPool start")
defer putils.LogTime("db_client.establishConnectionPool end")
psqlInfo, err := getLocalSteampipeConnectionString(opts)
if err != nil {
@@ -172,8 +173,8 @@ func CreateConnectionPool(ctx context.Context, opts *CreateDbOptions, maxConnect
// this is called immediately after the service process is started and hence
// all special handling related to service startup failures SHOULD be handled here
func createMaintenanceClient(ctx context.Context, port int) (*pgx.Conn, error) {
utils.LogTime("db_local.createMaintenanceClient start")
defer utils.LogTime("db_local.createMaintenanceClient end")
putils.LogTime("db_local.createMaintenanceClient start")
defer putils.LogTime("db_local.createMaintenanceClient end")
connStr := fmt.Sprintf("host=127.0.0.1 port=%d user=%s dbname=postgres sslmode=disable application_name=%s", port, constants.DatabaseSuperUser, runtime.ServiceConnectionAppName)

View File

@@ -14,6 +14,7 @@ import (
psutils "github.com/shirou/gopsutil/process"
filehelpers "github.com/turbot/go-kit/files"
"github.com/turbot/go-kit/helpers"
putils "github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/filepaths"
"github.com/turbot/steampipe/pkg/ociinstaller"
@@ -36,7 +37,7 @@ If you need to restore the contents of your public schema, please open an issue
// EnsureDBInstalled makes sure that the embedded postgres database is installed and ready to run
func EnsureDBInstalled(ctx context.Context) (err error) {
utils.LogTime("db_local.EnsureDBInstalled start")
putils.LogTime("db_local.EnsureDBInstalled start")
ensureMux.Lock()
@@ -46,7 +47,7 @@ func EnsureDBInstalled(ctx context.Context) (err error) {
err = helpers.ToError(r)
}
utils.LogTime("db_local.EnsureDBInstalled end")
putils.LogTime("db_local.EnsureDBInstalled end")
ensureMux.Unlock()
close(doneChan)
}()
@@ -141,8 +142,8 @@ func downloadAndInstallDbFiles(ctx context.Context) error {
// IsDBInstalled checks and reports whether the embedded database binaries are available
func IsDBInstalled() bool {
utils.LogTime("db_local.IsInstalled start")
defer utils.LogTime("db_local.IsInstalled end")
putils.LogTime("db_local.IsInstalled start")
defer putils.LogTime("db_local.IsInstalled end")
// check that both postgres binary and initdb binary exist
if _, err := os.Stat(filepaths.GetInitDbBinaryExecutablePath()); os.IsNotExist(err) {
return false
@@ -171,9 +172,9 @@ func IsFDWInstalled() bool {
// prepareDb updates the db binaries and FDW if needed, and inits the database if required
func prepareDb(ctx context.Context) error {
// load the db version info file
utils.LogTime("db_local.LoadDatabaseVersionFile start")
putils.LogTime("db_local.LoadDatabaseVersionFile start")
versionInfo, err := versionfile.LoadDatabaseVersionFile()
utils.LogTime("db_local.LoadDatabaseVersionFile end")
putils.LogTime("db_local.LoadDatabaseVersionFile end")
if err != nil {
return err
}
@@ -230,8 +231,8 @@ func dbNeedsUpdate(versionInfo *versionfile.DatabaseVersionFile) bool {
}
func installFDW(ctx context.Context, firstSetup bool) (string, error) {
utils.LogTime("db_local.installFDW start")
defer utils.LogTime("db_local.installFDW end")
putils.LogTime("db_local.installFDW start")
defer putils.LogTime("db_local.installFDW end")
state, err := GetState()
if err != nil {
@@ -250,20 +251,20 @@ func installFDW(ctx context.Context, firstSetup bool) (string, error) {
}
func needsInit() bool {
utils.LogTime("db_local.needsInit start")
defer utils.LogTime("db_local.needsInit end")
putils.LogTime("db_local.needsInit start")
defer putils.LogTime("db_local.needsInit end")
// test whether pg_hba.conf exists in our target directory
return !filehelpers.FileExists(filepaths.GetPgHbaConfLocation())
}
func runInstall(ctx context.Context, oldDbName *string) error {
utils.LogTime("db_local.runInstall start")
defer utils.LogTime("db_local.runInstall end")
putils.LogTime("db_local.runInstall start")
defer putils.LogTime("db_local.runInstall end")
statushooks.SetStatus(ctx, "Cleaning up…")
err := utils.RemoveDirectoryContents(filepaths.GetDataLocation())
err := putils.RemoveDirectoryContents(filepaths.GetDataLocation())
if err != nil {
log.Printf("[TRACE] %v", err)
return fmt.Errorf("Prepare database install location... FAILED!")
@@ -379,8 +380,8 @@ func isValidDatabaseName(databaseName string) bool {
}
func initDatabase() error {
utils.LogTime("db_local.install.initDatabase start")
defer utils.LogTime("db_local.install.initDatabase end")
putils.LogTime("db_local.install.initDatabase start")
defer putils.LogTime("db_local.install.initDatabase end")
// initdb sometimes fail due to invalid locale settings, to avoid this we update
// the locale settings to use 'C' only for the initdb process to complete, and
@@ -430,8 +431,8 @@ func initDatabase() error {
}
func installDatabaseWithPermissions(ctx context.Context, databaseName string, rawClient *pgx.Conn) error {
utils.LogTime("db_local.install.installDatabaseWithPermissions start")
defer utils.LogTime("db_local.install.installDatabaseWithPermissions end")
putils.LogTime("db_local.install.installDatabaseWithPermissions start")
defer putils.LogTime("db_local.install.installDatabaseWithPermissions end")
log.Println("[TRACE] installing database with name", databaseName)
@@ -503,8 +504,8 @@ func writePgHbaContent(databaseName string, username string) error {
}
func installForeignServer(ctx context.Context, rawClient *pgx.Conn) error {
utils.LogTime("db_local.installForeignServer start")
defer utils.LogTime("db_local.installForeignServer end")
putils.LogTime("db_local.installForeignServer start")
defer putils.LogTime("db_local.installForeignServer end")
statements := []string{
// Install the FDW. The name must match the binary file.
@@ -527,8 +528,8 @@ func installForeignServer(ctx context.Context, rawClient *pgx.Conn) error {
}
func updateDownloadedBinarySignature() error {
utils.LogTime("db_local.updateDownloadedBinarySignature start")
defer utils.LogTime("db_local.updateDownloadedBinarySignature end")
putils.LogTime("db_local.updateDownloadedBinarySignature start")
defer putils.LogTime("db_local.updateDownloadedBinarySignature end")
versionInfo, err := versionfile.LoadDatabaseVersionFile()
if err != nil {

View File

@@ -7,13 +7,13 @@ import (
"strings"
"github.com/jackc/pgx/v5"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe-plugin-sdk/v5/sperr"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/db/db_common"
"github.com/turbot/steampipe/pkg/introspection"
"github.com/turbot/steampipe/pkg/statushooks"
"github.com/turbot/steampipe/pkg/steampipeconfig"
"github.com/turbot/steampipe/pkg/utils"
)
// dropLegacyInternalSchema looks for a schema named 'internal'

View File

@@ -12,10 +12,10 @@ import (
"github.com/turbot/go-kit/helpers"
typeHelpers "github.com/turbot/go-kit/types"
"github.com/turbot/pipe-fittings/hclhelpers"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/db/db_common"
"github.com/turbot/steampipe/pkg/steampipeconfig/modconfig"
"github.com/turbot/steampipe/pkg/utils"
"github.com/zclconf/go-cty/cty"
)

View File

@@ -8,11 +8,11 @@ import (
"github.com/jackc/pgx/v5/pgconn"
"github.com/spf13/viper"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/db/db_client"
"github.com/turbot/steampipe/pkg/db/db_common"
pb "github.com/turbot/steampipe/pkg/pluginmanager_service/grpc/proto"
"github.com/turbot/steampipe/pkg/utils"
)
// LocalDbClient wraps over DbClient

View File

@@ -7,8 +7,8 @@ import (
"github.com/google/uuid"
filehelpers "github.com/turbot/go-kit/files"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/filepaths"
"github.com/turbot/steampipe/pkg/utils"
)
// Passwords :: structure for working with DB passwords

View File

@@ -11,6 +11,7 @@ import (
filehelpers "github.com/turbot/go-kit/files"
"github.com/turbot/go-kit/helpers"
putils "github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/filepaths"
"github.com/turbot/steampipe/pkg/utils"
@@ -135,8 +136,8 @@ func (r *RunningDBInstanceInfo) String() string {
}
func loadRunningInstanceInfo() (*RunningDBInstanceInfo, error) {
utils.LogTime("db.loadRunningInstanceInfo start")
defer utils.LogTime("db.loadRunningInstanceInfo end")
putils.LogTime("db.loadRunningInstanceInfo start")
defer putils.LogTime("db.loadRunningInstanceInfo end")
if !filehelpers.FileExists(filepaths.RunningInfoFilePath()) {
return nil, nil

View File

@@ -8,9 +8,9 @@ import (
"strings"
filehelpers "github.com/turbot/go-kit/files"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/filepaths"
"github.com/turbot/steampipe/pkg/utils"
)
// GetState checks that the database instance is running and returns its details

View File

@@ -16,11 +16,11 @@ import (
"github.com/spf13/viper"
filehelpers "github.com/turbot/go-kit/files"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe-plugin-sdk/v5/sperr"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/db/sslio"
"github.com/turbot/steampipe/pkg/filepaths"
"github.com/turbot/steampipe/pkg/utils"
)
const (

View File

@@ -4,7 +4,6 @@ import (
"bufio"
"context"
"fmt"
error_helpers2 "github.com/turbot/pipe-fittings/error_helpers"
"log"
"os"
"os/exec"
@@ -16,6 +15,8 @@ import (
psutils "github.com/shirou/gopsutil/process"
"github.com/spf13/viper"
"github.com/turbot/go-kit/helpers"
perror_helpers "github.com/turbot/pipe-fittings/error_helpers"
putils "github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe-plugin-sdk/v5/sperr"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/db/db_common"
@@ -28,7 +29,7 @@ import (
// StartResult is a pseudoEnum for outcomes of StartNewInstance
type StartResult struct {
error_helpers2.ErrorAndWarnings
perror_helpers.ErrorAndWarnings
Status StartDbStatus
DbState *RunningDBInstanceInfo
PluginManagerState *pluginmanager.State
@@ -73,8 +74,8 @@ func (slt StartListenType) ToListenAddresses() []string {
}
func StartServices(ctx context.Context, listenAddresses []string, port int, invoker constants.Invoker) *StartResult {
utils.LogTime("db_local.StartServices start")
defer utils.LogTime("db_local.StartServices end")
putils.LogTime("db_local.StartServices start")
defer putils.LogTime("db_local.StartServices end")
// we want the service to always listen on IPv4 loopback
if !utils.ListenAddressesContainsOneOfAddresses(listenAddresses, []string{"127.0.0.1", "*", "localhost"}) {
@@ -215,8 +216,8 @@ func postServiceStart(ctx context.Context, res *StartResult) error {
// StartDB starts the database if not already running
func startDB(ctx context.Context, listenAddresses []string, port int, invoker constants.Invoker) (res *StartResult) {
log.Printf("[TRACE] StartDB invoker %s (listenAddresses=%s, port=%d)", invoker, listenAddresses, port)
utils.LogTime("db.StartDB start")
defer utils.LogTime("db.StartDB end")
putils.LogTime("db.StartDB start")
defer putils.LogTime("db.StartDB end")
var postgresCmd *exec.Cmd
res = &StartResult{}
@@ -243,7 +244,7 @@ func startDB(ctx context.Context, listenAddresses []string, port int, invoker co
// remove the stale info file, ignoring errors - will overwrite anyway
_ = removeRunningInstanceInfo()
if err := utils.EnsureDirectoryPermission(filepaths.GetDataLocation()); err != nil {
if err := putils.EnsureDirectoryPermission(filepaths.GetDataLocation()); err != nil {
return res.SetError(fmt.Errorf("%s does not have the necessary permissions to start the service", filepaths.GetDataLocation()))
}
@@ -259,7 +260,7 @@ func startDB(ctx context.Context, listenAddresses []string, port int, invoker co
}
if err := utils.IsPortBindable(utils.GetFirstListenAddress(listenAddresses), port); err != nil {
return res.SetError(fmt.Errorf("cannot listen on port %d and %s %s. To check if there's any other steampipe services running, use %s", constants.Bold(port), utils.Pluralize("address", len(listenAddresses)), constants.Bold(strings.Join(listenAddresses, ",")), constants.Bold("steampipe service status --all")))
return res.SetError(fmt.Errorf("cannot listen on port %d and %s %s. To check if there's any other steampipe services running, use %s", constants.Bold(port), putils.Pluralize("address", len(listenAddresses)), constants.Bold(strings.Join(listenAddresses, ",")), constants.Bold("steampipe service status --all")))
}
if err := migrateLegacyPasswordFile(); err != nil {
@@ -310,7 +311,7 @@ func startDB(ctx context.Context, listenAddresses []string, port int, invoker co
return res.SetError(err)
}
utils.LogTime("postgresCmd end")
putils.LogTime("postgresCmd end")
res.Status = ServiceStarted
return res
}

View File

@@ -10,6 +10,7 @@ import (
"time"
psutils "github.com/shirou/gopsutil/process"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/constants/runtime"
"github.com/turbot/steampipe/pkg/db/db_common"
@@ -17,7 +18,6 @@ import (
"github.com/turbot/steampipe/pkg/filepaths"
"github.com/turbot/steampipe/pkg/pluginmanager"
"github.com/turbot/steampipe/pkg/statushooks"
"github.com/turbot/steampipe/pkg/utils"
)
// StopStatus is a pseudoEnum for service stop result

View File

@@ -9,7 +9,7 @@ import (
"log"
"os"
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/pipe-fittings/utils"
)
func ParseCertificateInLocation(location string) (*x509.Certificate, error) {

View File

@@ -2,10 +2,11 @@ package display
import (
"fmt"
utils2 "github.com/turbot/pipe-fittings/ociinstaller"
"sort"
"strings"
"github.com/turbot/pipe-fittings/ociinstaller"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/constants"
)
@@ -122,7 +123,7 @@ func PrintInstallReports(reports PluginInstallReports, isUpdateReport bool) {
if (len(installSkipReports)) > 0 {
fmt.Printf(
"\nSkipped the following %s:\n\n%s\n",
utils2.Pluralize("plugin", skipCount),
utils.Pluralize("plugin", skipCount),
strings.Join(installSkipReports, "\n\n"),
)
}
@@ -135,8 +136,8 @@ func PrintInstallReports(reports PluginInstallReports, isUpdateReport bool) {
fmt.Println()
fmt.Printf(
"To install %s which %s not installed, please run %s\n",
utils2.Pluralize("plugin", len(canBeInstalled)),
utils2.Pluralize("is", len(canBeInstalled)),
utils.Pluralize("plugin", len(canBeInstalled)),
utils.Pluralize("is", len(canBeInstalled)),
constants.Bold(fmt.Sprintf(
"steampipe plugin install %s",
strings.Join(pluginList, " "),
@@ -152,8 +153,8 @@ func PrintInstallReports(reports PluginInstallReports, isUpdateReport bool) {
fmt.Println()
fmt.Printf(
"To update %s %s: %s\nTo update all plugins: %s",
utils2.Pluralize("this", len(pluginList)),
utils2.Pluralize("plugin", len(pluginList)),
utils.Pluralize("this", len(pluginList)),
utils.Pluralize("plugin", len(pluginList)),
constants.Bold(fmt.Sprintf("steampipe plugin update %s", strings.Join(pluginList, " "))),
constants.Bold(fmt.Sprintln("steampipe plugin update --all")),
)

View File

@@ -6,10 +6,10 @@ import (
"path"
"strings"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe-plugin-sdk/v5/sperr"
"github.com/turbot/steampipe/pkg/error_helpers"
"github.com/turbot/steampipe/pkg/statushooks"
"github.com/turbot/steampipe/pkg/utils"
"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
)

View File

@@ -4,6 +4,7 @@ import (
"context"
"fmt"
error_helpers2 "github.com/turbot/pipe-fittings/error_helpers"
"github.com/turbot/pipe-fittings/plugin"
"log"
"github.com/jackc/pgx/v5"
@@ -18,7 +19,6 @@ import (
"github.com/turbot/steampipe/pkg/error_helpers"
"github.com/turbot/steampipe/pkg/export"
"github.com/turbot/steampipe/pkg/modinstaller"
"github.com/turbot/steampipe/pkg/plugin"
"github.com/turbot/steampipe/pkg/statushooks"
"github.com/turbot/steampipe/pkg/steampipeconfig/modconfig"
"github.com/turbot/steampipe/pkg/workspace"

View File

@@ -19,6 +19,7 @@ import (
"github.com/jackc/pgx/v5/pgconn"
"github.com/spf13/viper"
"github.com/turbot/go-kit/helpers"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/cmdconfig"
"github.com/turbot/steampipe/pkg/connection_sync"
"github.com/turbot/steampipe/pkg/constants"
@@ -31,7 +32,6 @@ import (
"github.com/turbot/steampipe/pkg/statushooks"
"github.com/turbot/steampipe/pkg/steampipeconfig"
"github.com/turbot/steampipe/pkg/steampipeconfig/modconfig"
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/steampipe/pkg/version"
)

View File

@@ -9,11 +9,11 @@ import (
"github.com/c-bata/go-prompt"
"github.com/turbot/go-kit/helpers"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/db/db_common"
"github.com/turbot/steampipe/pkg/steampipeconfig"
"github.com/turbot/steampipe/pkg/steampipeconfig/modconfig"
"github.com/turbot/steampipe/pkg/utils"
)
func (c *InteractiveClient) initialiseSuggestions(ctx context.Context) error {

View File

@@ -5,9 +5,9 @@ import (
"strings"
"github.com/turbot/go-kit/helpers"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/cmdconfig"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/utils"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)

View File

@@ -4,8 +4,8 @@ import (
"context"
"github.com/turbot/go-kit/helpers"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/error_helpers"
"github.com/turbot/steampipe/pkg/utils"
)
func InstallWorkspaceDependencies(ctx context.Context, opts *InstallOpts) (_ *InstallData, err error) {

View File

@@ -3,6 +3,7 @@ package modinstaller
import (
"context"
"fmt"
"github.com/turbot/pipe-fittings/plugin"
"log"
"os"
"path"
@@ -12,15 +13,14 @@ import (
git "github.com/go-git/go-git/v5"
"github.com/otiai10/copy"
"github.com/spf13/viper"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe-plugin-sdk/v5/sperr"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/error_helpers"
"github.com/turbot/steampipe/pkg/filepaths"
"github.com/turbot/steampipe/pkg/plugin"
"github.com/turbot/steampipe/pkg/steampipeconfig/modconfig"
"github.com/turbot/steampipe/pkg/steampipeconfig/parse"
"github.com/turbot/steampipe/pkg/steampipeconfig/versionmap"
"github.com/turbot/steampipe/pkg/utils"
)
type ModInstaller struct {

View File

@@ -13,7 +13,7 @@ import (
// InstallAssets installs the Steampipe report server assets
func InstallAssets(ctx context.Context, assetsLocation string) error {
tempDir := NewTempDir(assetsLocation)
tempDir := ociinstaller.NewTempDir(assetsLocation)
defer func() {
if err := tempDir.Delete(); err != nil {
log.Printf("[TRACE] Failed to delete temp dir '%s' after installing assets: %s", tempDir, err)
@@ -38,7 +38,7 @@ func InstallAssets(ctx context.Context, assetsLocation string) error {
func installAssetsFiles(image *SteampipeImage, tempdir string, dest string) error {
fileName := image.Assets.ReportUI
sourcePath := filepath.Join(tempdir, fileName)
if err := moveFolderWithinPartition(sourcePath, filepaths.EnsureDashboardAssetsDir()); err != nil {
if err := ociinstaller.MoveFolderWithinPartition(sourcePath, filepaths.EnsureDashboardAssetsDir()); err != nil {
return fmt.Errorf("could not install %s to %s", sourcePath, filepaths.EnsureDashboardAssetsDir())
}
return nil

View File

@@ -3,6 +3,7 @@ package ociinstaller
import (
"context"
"github.com/turbot/pipe-fittings/ociinstaller"
"github.com/turbot/pipe-fittings/utils"
"log"
"path/filepath"
"time"
@@ -13,7 +14,7 @@ import (
// InstallDB :: Install Postgres files fom OCI image
func InstallDB(ctx context.Context, dblocation string) (string, error) {
tempDir := NewTempDir(dblocation)
tempDir := ociinstaller.NewTempDir(dblocation)
defer func() {
if err := tempDir.Delete(); err != nil {
log.Printf("[TRACE] Failed to delete temp dir '%s' after installing db files: %s", tempDir, err)
@@ -40,7 +41,7 @@ func InstallDB(ctx context.Context, dblocation string) (string, error) {
}
func updateVersionFileDB(image *SteampipeImage) error {
timeNow := versionfile.FormatTime(time.Now())
timeNow := utils.FormatTime(time.Now())
v, err := versionfile.LoadDatabaseVersionFile()
if err != nil {
return err
@@ -56,5 +57,5 @@ func updateVersionFileDB(image *SteampipeImage) error {
func installDbFiles(image *SteampipeImage, tempDir string, dest string) error {
source := filepath.Join(tempDir, image.Database.ArchiveDir)
return moveFolderWithinPartition(source, dest)
return ociinstaller.MoveFolderWithinPartition(source, dest)
}

View File

@@ -3,12 +3,13 @@ package ociinstaller
import (
"context"
"fmt"
"github.com/turbot/pipe-fittings/ociinstaller"
"log"
"os"
"path/filepath"
"time"
"github.com/turbot/pipe-fittings/ociinstaller"
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"
@@ -16,7 +17,7 @@ import (
// InstallFdw installs the Steampipe Postgres foreign data wrapper from an OCI image
func InstallFdw(ctx context.Context, dbLocation string) (string, error) {
tempDir := NewTempDir(dbLocation)
tempDir := ociinstaller.NewTempDir(dbLocation)
defer func() {
if err := tempDir.Delete(); err != nil {
log.Printf("[TRACE] Failed to delete temp dir '%s' after installing fdw: %s", tempDir, err)
@@ -44,7 +45,7 @@ func InstallFdw(ctx context.Context, dbLocation string) (string, error) {
}
func updateVersionFileFdw(image *SteampipeImage) error {
timeNow := versionfile.FormatTime(time.Now())
timeNow := putils.FormatTime(time.Now())
v, err := versionfile.LoadDatabaseVersionFile()
if err != nil {
return err
@@ -68,7 +69,7 @@ func installFdwFiles(image *SteampipeImage, tempdir string) error {
// to avoid this, first remove the existing .so file
os.Remove(fdwBinFileDestPath)
// now unzip the fdw file
if _, err := ungzip(fdwBinFileSourcePath, fdwBinDir); err != nil {
if _, err := ociinstaller.Ungzip(fdwBinFileSourcePath, fdwBinDir); err != nil {
return fmt.Errorf("could not unzip %s to %s: %s", fdwBinFileSourcePath, fdwBinDir, err.Error())
}
@@ -77,7 +78,7 @@ func installFdwFiles(image *SteampipeImage, tempdir string) error {
controlFileSourcePath := filepath.Join(tempdir, controlFileName)
controlFileDestPath := filepath.Join(fdwControlDir, image.Fdw.ControlFile)
if err := moveFileWithinPartition(controlFileSourcePath, controlFileDestPath); err != nil {
if err := ociinstaller.MoveFileWithinPartition(controlFileSourcePath, controlFileDestPath); err != nil {
return fmt.Errorf("could not install %s to %s", controlFileSourcePath, fdwControlDir)
}
@@ -85,7 +86,7 @@ func installFdwFiles(image *SteampipeImage, tempdir string) error {
sqlFileName := image.Fdw.SqlFile
sqlFileSourcePath := filepath.Join(tempdir, sqlFileName)
sqlFileDestPath := filepath.Join(fdwSQLDir, sqlFileName)
if err := moveFileWithinPartition(sqlFileSourcePath, sqlFileDestPath); err != nil {
if err := ociinstaller.MoveFileWithinPartition(sqlFileSourcePath, sqlFileDestPath); err != nil {
return fmt.Errorf("could not install %s to %s", sqlFileSourcePath, fdwSQLDir)
}
return nil

View File

@@ -4,8 +4,8 @@ import (
"fmt"
"runtime"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/utils"
)
// Steampipe Media Types

View File

@@ -5,7 +5,7 @@ import (
"bytes"
"context"
"fmt"
putils "github.com/turbot/pipe-fittings/ociinstaller"
"github.com/turbot/pipe-fittings/ociinstaller"
versionfile2 "github.com/turbot/pipe-fittings/ociinstaller/versionfile"
"log"
"os"
@@ -15,9 +15,9 @@ import (
"sync"
"time"
"github.com/turbot/pipe-fittings/utils"
putils "github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/filepaths"
"github.com/turbot/steampipe/pkg/ociinstaller/versionfile"
"github.com/turbot/steampipe/pkg/utils"
)
var versionFileUpdateLock = &sync.Mutex{}
@@ -28,7 +28,7 @@ func InstallPlugin(ctx context.Context, imageRef string, constraint string, sub
for _, opt := range opts {
opt(config)
}
tempDir := NewTempDir(filepaths.EnsurePluginDir())
tempDir := ociinstaller.NewTempDir(filepaths.EnsurePluginDir())
defer func() {
// send a last beacon to signal completion
sub <- struct{}{}
@@ -37,7 +37,7 @@ func InstallPlugin(ctx context.Context, imageRef string, constraint string, sub
}
}()
ref := putils.NewImageRef(imageRef)
ref := ociinstaller.NewImageRef(imageRef)
imageDownloader := NewOciDownloader()
sub <- struct{}{}
@@ -76,7 +76,7 @@ func updatePluginVersionFiles(ctx context.Context, image *SteampipeImage, constr
versionFileUpdateLock.Lock()
defer versionFileUpdateLock.Unlock()
timeNow := versionfile.FormatTime(time.Now())
timeNow := putils.FormatTime(time.Now())
v, err := versionfile2.LoadPluginVersionFile(ctx)
if err != nil {
return err
@@ -135,7 +135,7 @@ func installPluginBinary(image *SteampipeImage, tempDir string, destDir string)
}
// unzip the file into the plugin folder
if _, err := ungzip(sourcePath, destDir); err != nil {
if _, err := ociinstaller.Ungzip(sourcePath, destDir); err != nil {
return fmt.Errorf("could not unzip %s to %s", sourcePath, destDir)
}
return nil
@@ -150,10 +150,10 @@ func installPluginDocs(image *SteampipeImage, tempDir string, destDir string) er
// install the docs
sourcePath := filepath.Join(tempDir, image.Plugin.DocsDir)
destPath := filepath.Join(destDir, "docs")
if fileExists(destPath) {
if ociinstaller.FileExists(destPath) {
os.RemoveAll(destPath)
}
if err := moveFolderWithinPartition(sourcePath, destPath); err != nil {
if err := ociinstaller.MoveFolderWithinPartition(sourcePath, destPath); err != nil {
return fmt.Errorf("could not copy %s to %s", sourcePath, destPath)
}
return nil
@@ -186,7 +186,7 @@ func installPluginConfigFiles(image *SteampipeImage, tempdir string, constraint
}
func copyConfigFileUnlessExists(sourceFile string, destFile string, constraint string) error {
if fileExists(destFile) {
if ociinstaller.FileExists(destFile) {
return nil
}
inputData, err := os.ReadFile(sourceFile)

View File

@@ -1,53 +0,0 @@
package ociinstaller
import (
"fmt"
"os"
"path/filepath"
"strings"
"github.com/google/uuid"
"github.com/turbot/steampipe/pkg/error_helpers"
)
type tempDir struct {
Path string
}
// NewTempDir creates a directory under the given parent directory.
func NewTempDir(parent string) *tempDir {
return &tempDir{
Path: getOrCreateTempDir(parent),
}
}
func getOrCreateTempDir(parent string) string {
cacheDir := filepath.Join(parent, safeDirName(fmt.Sprintf("tmp-%s", generateTempDirName())))
if _, err := os.Stat(cacheDir); os.IsNotExist(err) {
err = os.MkdirAll(cacheDir, 0755)
error_helpers.FailOnErrorWithMessage(err, "could not create cache directory")
}
return cacheDir
}
func (d *tempDir) Delete() error {
return os.RemoveAll(d.Path)
}
func safeDirName(dirName string) string {
newName := strings.ReplaceAll(dirName, "/", "_")
newName = strings.ReplaceAll(newName, ":", "@")
return newName
}
func generateTempDirName() string {
u, err := uuid.NewRandom()
if err != nil {
// Should never happen?
panic(err)
}
s := u.String()
return s[9:23]
}

View File

@@ -2,13 +2,11 @@ package versionfile
import (
"encoding/json"
filehelpers "github.com/turbot/go-kit/files"
versionfile2 "github.com/turbot/pipe-fittings/ociinstaller/versionfile"
"github.com/turbot/steampipe/pkg/filepaths"
"log"
"os"
"time"
filehelpers "github.com/turbot/go-kit/files"
"github.com/turbot/steampipe/pkg/filepaths"
)
const DatabaseStructVersion = 20220411
@@ -77,10 +75,3 @@ func (f *DatabaseVersionFile) write(path string) error {
}
return os.WriteFile(path, versionFileJSON, 0644)
}
// FormatTime :: format time as RFC3339 in UTC
func FormatTime(localTime time.Time) string {
loc, _ := time.LoadLocation("UTC")
utcTime := localTime.In(loc)
return (utcTime.Format(time.RFC3339))
}

View File

@@ -1,87 +0,0 @@
package ociinstaller
import (
"compress/gzip"
"fmt"
"io"
"os"
"path/filepath"
)
func ungzip(sourceFile string, destDir string) (string, error) {
r, err := os.Open(sourceFile)
if err != nil {
return "", err
}
defer r.Close()
uncompressedStream, err := gzip.NewReader(r)
if err != nil {
return "", err
}
destFile := filepath.Join(destDir, uncompressedStream.Name)
outFile, err := os.OpenFile(destFile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm)
if err != nil {
return "", err
}
if _, err := io.Copy(outFile, uncompressedStream); err != nil {
return "", err
}
outFile.Close()
if err := uncompressedStream.Close(); err != nil {
return "", err
}
return destFile, nil
}
func fileExists(filePath string) bool {
if _, err := os.Stat(filePath); os.IsNotExist(err) {
return false
}
return true
}
// moves a file within an fs partition. panics if movement is attempted between partitions
// this is done separately to achieve performance benefits of os.Rename over reading and writing content
func moveFileWithinPartition(sourcePath, destPath string) error {
if err := os.Rename(sourcePath, destPath); err != nil {
return fmt.Errorf("error moving file: %s", err)
}
return nil
}
// moves a folder within an fs partition. panics if movement is attempted between partitions
// this is done separately to achieve performance benefits of os.Rename over reading and writing content
func moveFolderWithinPartition(sourcePath, destPath string) error {
sourceinfo, err := os.Stat(sourcePath)
if err != nil {
return err
}
if err = os.MkdirAll(destPath, sourceinfo.Mode()); err != nil {
return err
}
directory, err := os.Open(sourcePath)
if err != nil {
return fmt.Errorf("couldn't open source dir: %s", err)
}
directory.Close()
defer os.RemoveAll(sourcePath)
return filepath.Walk(sourcePath, func(path string, info os.FileInfo, err error) error {
relPath, _ := filepath.Rel(sourcePath, path)
if relPath == "" {
return nil
}
if info.IsDir() {
return os.MkdirAll(filepath.Join(destPath, relPath), info.Mode())
}
return moveFileWithinPartition(filepath.Join(sourcePath, relPath), filepath.Join(destPath, relPath))
})
}

View File

@@ -1,167 +0,0 @@
package plugin
import (
"context"
"fmt"
ociinstaller2 "github.com/turbot/pipe-fittings/ociinstaller"
versionfile2 "github.com/turbot/pipe-fittings/ociinstaller/versionfile"
"log"
"os"
"path/filepath"
"time"
"github.com/turbot/go-kit/files"
"github.com/turbot/steampipe-plugin-sdk/v5/sperr"
"github.com/turbot/steampipe/pkg/filepaths"
"github.com/turbot/steampipe/pkg/ociinstaller"
"github.com/turbot/steampipe/pkg/statushooks"
"github.com/turbot/steampipe/pkg/steampipeconfig"
"github.com/turbot/steampipe/pkg/steampipeconfig/modconfig"
)
// Remove removes an installed plugin
func Remove(ctx context.Context, image string, pluginConnections map[string][]*modconfig.Connection) (*steampipeconfig.PluginRemoveReport, error) {
statushooks.SetStatus(ctx, fmt.Sprintf("Removing plugin %s", image))
imageRef := ociinstaller2.NewImageRef(image)
fullPluginName := imageRef.DisplayImageRef()
// are any connections using this plugin???
conns := pluginConnections[fullPluginName]
installedTo := filepath.Join(filepaths.EnsurePluginDir(), filepath.FromSlash(fullPluginName))
_, err := os.Stat(installedTo)
if os.IsNotExist(err) {
return nil, fmt.Errorf("plugin '%s' not found", image)
}
// remove from file system
err = os.RemoveAll(installedTo)
if err != nil {
return nil, err
}
// update the version file
v, err := versionfile2.LoadPluginVersionFile(ctx)
if err != nil {
return nil, err
}
delete(v.Plugins, fullPluginName)
err = v.Save()
return &steampipeconfig.PluginRemoveReport{Connections: conns, Image: imageRef}, err
}
// Exists looks up the version file and reports whether a plugin is already installed
func Exists(ctx context.Context, plugin string) (bool, error) {
versionData, err := versionfile2.LoadPluginVersionFile(ctx)
if err != nil {
return false, err
}
imageRef := ociinstaller2.NewImageRef(plugin)
// lookup in the version data
_, found := versionData.Plugins[imageRef.DisplayImageRef()]
return found, nil
}
// Install installs a plugin in the local file system
func Install(ctx context.Context, plugin ResolvedPluginVersion, sub chan struct{}, opts ...ociinstaller.PluginInstallOption) (*ociinstaller.SteampipeImage, 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, opts...)
return image, err
}
// PluginListItem is a struct representing an item in the list of plugins
type PluginListItem struct {
Name string
Version *modconfig.PluginVersionString
Connections []string
}
// List returns all installed plugins
func List(ctx context.Context, pluginConnectionMap map[string][]*modconfig.Connection) ([]PluginListItem, error) {
var items []PluginListItem
// retrieve the plugin version data from steampipe config
pluginVersions := steampipeconfig.GlobalConfig.PluginVersions
pluginBinaries, err := files.ListFilesWithContext(ctx, filepaths.EnsurePluginDir(), &files.ListOptions{
Include: []string{"**/*.plugin"},
Flags: files.AllRecursive,
})
if err != nil {
return nil, err
}
// we have the plugin binary paths
for _, pluginBinary := range pluginBinaries {
parent := filepath.Dir(pluginBinary)
fullPluginName, err := filepath.Rel(filepaths.EnsurePluginDir(), parent)
if err != nil {
return nil, err
}
// for local plugin
item := PluginListItem{
Name: fullPluginName,
Version: modconfig.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 = modconfig.NewPluginVersionString(installation.Version)
if err != nil {
return nil, sperr.WrapWithMessage(err, "could not evaluate plugin version %s", installation.Version)
}
}
if pluginConnectionMap != nil {
// extract only the connection names
var connectionNames []string
for _, connection := range pluginConnectionMap[fullPluginName] {
connectionName := connection.Name
if connection.ImportDisabled() {
connectionName = fmt.Sprintf("%s(disabled)", connectionName)
}
connectionNames = append(connectionNames, connectionName)
}
item.Connections = connectionNames
}
items = append(items, item)
}
}
return items, nil
}
// detectLocalPlugin returns true if the modTime of the `pluginBinary` is after the installation date as recorded in the installation data
// this may happen when a plugin is installed from the registry, but is then compiled from source
func detectLocalPlugin(installation *versionfile2.InstalledVersion, pluginBinary string) bool {
installDate, err := time.Parse(time.RFC3339, installation.InstallDate)
if err != nil {
log.Printf("[WARN] could not parse install date for %s: %s", installation.Name, installation.InstallDate)
return false
}
// truncate to second
// otherwise, comparisons may get skewed because of the
// underlying monotonic clock
installDate = installDate.Truncate(time.Second)
// get the modtime of the plugin binary
stat, err := os.Lstat(pluginBinary)
if err != nil {
log.Printf("[WARN] could not parse install date for %s: %s", installation.Name, installation.InstallDate)
return false
}
modTime := stat.ModTime().
// truncate to second
// otherwise, comparisons may get skewed because of the
// underlying monotonic clock
Truncate(time.Second)
return installDate.Before(modTime)
}

View File

@@ -1,36 +0,0 @@
package plugin
import (
"context"
"log"
"os"
"time"
"github.com/turbot/go-kit/files"
"github.com/turbot/steampipe/pkg/filepaths"
)
func CleanupOldTmpDirs(ctx context.Context) {
const tmpDirAgeThreshold = 24 * time.Hour
tmpDirs, err := files.ListFilesWithContext(ctx, filepaths.EnsurePluginDir(), &files.ListOptions{
Include: []string{"tmp-*"},
Flags: files.DirectoriesRecursive,
})
if err != nil {
log.Printf("[TRACE] Error while globbing for tmp dirs in plugin dir: %s", err)
return
}
for _, tmpDir := range tmpDirs {
stat, err := os.Stat(tmpDir)
if err != nil {
log.Printf("[TRACE] Error while stating tmp dir %s: %s", tmpDir, err)
continue
}
if time.Since(stat.ModTime()) > tmpDirAgeThreshold {
if err := os.RemoveAll(tmpDir); err != nil {
log.Printf("[TRACE] Error while removing old tmp dir %s: %s", tmpDir, err)
}
}
}
}

View File

@@ -1,23 +0,0 @@
package plugin
import (
"context"
"fmt"
"github.com/turbot/pipe-fittings/ociinstaller"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/steampipeconfig/modconfig"
)
// 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) (map[string]*modconfig.PluginVersionString, error) {
installedPlugins := make(map[string]*modconfig.PluginVersionString)
installedPluginsData, _ := List(ctx, nil)
for _, plugin := range installedPluginsData {
org, name, _ := ociinstaller.NewImageRef(plugin.Name).GetOrgNameAndConstraint(constants.SteampipeHubOCIBase)
pluginShortName := fmt.Sprintf("%s/%s", org, name)
installedPlugins[pluginShortName] = plugin.Version
}
return installedPlugins, nil
}

View File

@@ -1,22 +0,0 @@
package plugin
import "fmt"
type ResolvedPluginVersion struct {
PluginName string
Version string
Constraint string
}
func NewResolvedPluginVersion(pluginName string, version string, constraint string) ResolvedPluginVersion {
return ResolvedPluginVersion{
PluginName: pluginName,
Version: version,
Constraint: constraint,
}
}
// GetVersionTag returns the <PluginName>:<Version> (turbot/chaos:0.4.1)
func (r ResolvedPluginVersion) GetVersionTag() string {
return fmt.Sprintf("%s:%s", r.PluginName, r.Version)
}

View File

@@ -1,33 +0,0 @@
package plugin
import (
"runtime"
"github.com/turbot/steampipe/pkg/constants"
)
// UpdateRequired determines if the latest version in a "stream"
// requires the plugin to update.
func UpdateRequired(report VersionCheckReport) bool {
// 1) If there is an updated version ALWAYS update
if report.Plugin.Version != report.CheckResponse.Version {
return true
}
// 2) If we are M1, current installed version is AMD, and ARM is available - update
if isRunningAsMacM1() && report.Plugin.BinaryArchitecture != constants.ArchARM64 {
return true
}
// 3) Otherwise skip
return false
}
// check to see if steampipe is running as a Mac/M1 build
// Mac/M1 can run 'amd64' builds, but that is not a
// problem, since they will be running under 'rosetta'
// TODO: Find a way to determine the underlying architecture, rather than depending on Go runtime
func isRunningAsMacM1() bool {
return runtime.GOOS == constants.OSDarwin && runtime.GOARCH == constants.ArchARM64
}

View File

@@ -1,19 +0,0 @@
package plugin
import "fmt"
type versionCheckPayload interface {
getMapKey() string
}
// the payload that travels to-and-fro between steampipe and the server
type versionCheckCorePayload struct {
Org string `json:"org"`
Name string `json:"name"`
Constraint string `json:"constraint"`
Version string `json:"version"`
}
func (v *versionCheckCorePayload) getMapKey() string {
return fmt.Sprintf("%s/%s/%s", v.Org, v.Name, v.Constraint)
}

View File

@@ -1,233 +0,0 @@
package plugin
import (
"context"
"encoding/json"
"fmt"
utils2 "github.com/turbot/pipe-fittings/ociinstaller"
versionfile2 "github.com/turbot/pipe-fittings/ociinstaller/versionfile"
"github.com/turbot/steampipe/pkg/constants"
"io"
"log"
"net/url"
"strings"
"time"
"github.com/turbot/steampipe/pkg/ociinstaller/versionfile"
"github.com/turbot/steampipe/pkg/steampipeconfig"
)
const (
VersionCheckerSchema = "https"
VersionCheckerHost = "hub.steampipe.io"
VersionCheckerEndpoint = "api/plugin/version"
)
// VersionCheckReport ::
type VersionCheckReport struct {
Plugin *versionfile2.InstalledVersion
CheckResponse versionCheckCorePayload
CheckRequest versionCheckCorePayload
}
func (vr *VersionCheckReport) ShortName() string {
return fmt.Sprintf("%s/%s", vr.CheckResponse.Org, vr.CheckResponse.Name)
}
func (vr *VersionCheckReport) ShortNameWithConstraint() string {
// dont show constraints for latest
if vr.CheckResponse.Constraint != "latest" {
return fmt.Sprintf("%s/%s@%s", vr.CheckResponse.Org, vr.CheckResponse.Name, vr.CheckResponse.Constraint)
}
return fmt.Sprintf("%s/%s", vr.CheckResponse.Org, vr.CheckResponse.Name)
}
// VersionChecker :: wrapper struct over the plugin version check utilities
type VersionChecker struct {
pluginsToCheck []*versionfile2.InstalledVersion
signature string
}
// GetUpdateReport looks up and reports the updated version of selective turbot plugins which are listed in versions.json
func GetUpdateReport(ctx context.Context, installationID string, check []*versionfile2.InstalledVersion) map[string]VersionCheckReport {
versionChecker := new(VersionChecker)
versionChecker.signature = installationID
for _, c := range check {
if strings.HasPrefix(c.Name, ociinstaller.DefaultImageRepoDisplayURL) {
versionChecker.pluginsToCheck = append(versionChecker.pluginsToCheck, c)
}
}
return versionChecker.reportPluginUpdates(ctx)
}
// GetAllUpdateReport looks up and reports the updated version of all turbot plugins which are listed in versions.json
func GetAllUpdateReport(ctx context.Context, installationID string) map[string]VersionCheckReport {
versionChecker := new(VersionChecker)
versionChecker.signature = installationID
versionChecker.pluginsToCheck = []*versionfile2.InstalledVersion{}
// retrieve the plugin version data from steampipe config
pluginVersions := steampipeconfig.GlobalConfig.PluginVersions
for _, p := range pluginVersions {
if strings.HasPrefix(p.Name, ociinstaller.DefaultImageRepoDisplayURL) {
versionChecker.pluginsToCheck = append(versionChecker.pluginsToCheck, p)
}
}
return versionChecker.reportPluginUpdates(ctx)
}
func (v *VersionChecker) reportPluginUpdates(ctx context.Context) map[string]VersionCheckReport {
// retrieve the plugin version data from steampipe config
versionFileData, err := versionfile2.LoadPluginVersionFile(ctx)
if err != nil {
log.Printf("[TRACE] reportPluginUpdates could not load version file: %s", err.Error())
return nil
}
if len(v.pluginsToCheck) == 0 {
// there's no plugin installed. no point continuing
return nil
}
reports := v.getLatestVersionsForPlugins(ctx, v.pluginsToCheck)
// remove elements from `reports` which have empty strings in CheckResponse
// this happens if we have sent a plugin to the API which doesn't exist
// in the registry
for key, value := range reports {
if value.CheckResponse.Name == "" {
// delete this key
delete(reports, key)
}
}
// update the version file
for _, plugin := range v.pluginsToCheck {
versionFileData.Plugins[plugin.Name].LastCheckedDate = versionfile.FormatTime(time.Now())
}
if err = versionFileData.Save(); err != nil {
log.Printf("[WARN] reportPluginUpdates could not save version file: %s", err.Error())
return nil
}
return reports
}
func (v *VersionChecker) getLatestVersionsForPlugins(ctx context.Context, plugins []*versionfile2.InstalledVersion) map[string]VersionCheckReport {
var requestPayload []versionCheckCorePayload
reports := map[string]VersionCheckReport{}
for _, ref := range plugins {
thisPayload := v.getPayloadFromInstalledData(ref)
requestPayload = append(requestPayload, thisPayload)
reports[thisPayload.getMapKey()] = VersionCheckReport{
Plugin: ref,
CheckRequest: thisPayload,
CheckResponse: versionCheckCorePayload{},
}
}
serverResponse, err := v.requestServerForLatest(ctx, requestPayload)
if err != nil {
log.Printf("[TRACE] PluginVersionChecker getLatestVersionsForPlugins returned error: %s", err.Error())
// return a blank map
return map[string]VersionCheckReport{}
}
for _, pluginResponseData := range serverResponse {
r := reports[pluginResponseData.getMapKey()]
r.CheckResponse = pluginResponseData
reports[pluginResponseData.getMapKey()] = r
}
return reports
}
func (v *VersionChecker) getPayloadFromInstalledData(plugin *versionfile2.InstalledVersion) versionCheckCorePayload {
ref := ociinstaller.NewImageRef(plugin.Name)
org, name, constraint := ref.GetOrgNameAndConstraint(constants.SteampipeHubOCIBase)
payload := versionCheckCorePayload{
Org: org,
Name: name,
Constraint: constraint,
Version: plugin.Version,
}
return payload
}
func (v *VersionChecker) getVersionCheckURL() url.URL {
var u url.URL
u.Scheme = VersionCheckerSchema
u.Host = VersionCheckerHost
u.Path = VersionCheckerEndpoint
return u
}
func (v *VersionChecker) requestServerForLatest(ctx context.Context, payload []versionCheckCorePayload) ([]versionCheckCorePayload, error) {
// Set a default timeout of 3 sec for the check request (in milliseconds)
sendRequestTo := v.getVersionCheckURL()
requestBody := utils2.BuildRequestPayload(v.signature, map[string]interface{}{
"plugins": payload,
})
resp, err := utils2.SendRequest(ctx, v.signature, "POST", sendRequestTo, requestBody)
if err != nil {
log.Printf("[TRACE] Could not send request")
return nil, err
}
if resp.StatusCode != 200 {
log.Printf("[TRACE] Unknown response during version check: %d\n", resp.StatusCode)
return nil, fmt.Errorf("requestServerForLatest failed - SendRequest returned %d", resp.StatusCode)
}
bodyBytes, err := io.ReadAll(resp.Body)
if err != nil {
log.Printf("[TRACE] Error reading body stream: %v", err)
return nil, err
}
defer resp.Body.Close()
var responseData []versionCheckCorePayload
err = json.Unmarshal(bodyBytes, &responseData)
if err != nil {
log.Println("[TRACE] Error in unmarshalling plugin update response", err)
return nil, err
}
return responseData, nil
}
func GetLatestPluginVersionByConstraint(ctx context.Context, installationID string, org string, name string, constraint string) (*ResolvedPluginVersion, error) {
vc := VersionChecker{signature: installationID}
payload := []versionCheckCorePayload{
{
Org: org,
Name: name,
Constraint: constraint,
Version: "0.0.0", // This is used by installer, version is required by the API, this makes sense as nothing installed.
},
}
orgAndName := fmt.Sprintf("%s/%s", org, name)
vcr, err := vc.requestServerForLatest(ctx, payload)
if err != nil {
return nil, err
}
if len(vcr) == 0 {
return nil, fmt.Errorf("no version found for %s with constraint %s", orgAndName, constraint)
}
v := vcr[0]
rpv := NewResolvedPluginVersion(orgAndName, v.Version, constraint)
return &rpv, nil
}

View File

@@ -8,9 +8,9 @@ import (
"github.com/hashicorp/go-plugin"
filehelpers "github.com/turbot/go-kit/files"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/filepaths"
pb "github.com/turbot/steampipe/pkg/pluginmanager_service/grpc/proto"
"github.com/turbot/steampipe/pkg/utils"
)
const PluginManagerStructVersion = 20220411

View File

@@ -18,6 +18,7 @@ import (
"github.com/sethvargo/go-retry"
"github.com/spf13/viper"
"github.com/turbot/go-kit/helpers"
"github.com/turbot/pipe-fittings/utils"
sdkgrpc "github.com/turbot/steampipe-plugin-sdk/v5/grpc"
sdkproto "github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto"
sdkshared "github.com/turbot/steampipe-plugin-sdk/v5/grpc/shared"
@@ -32,7 +33,6 @@ import (
pluginshared "github.com/turbot/steampipe/pkg/pluginmanager_service/grpc/shared"
"github.com/turbot/steampipe/pkg/steampipeconfig"
"github.com/turbot/steampipe/pkg/steampipeconfig/modconfig"
"github.com/turbot/steampipe/pkg/utils"
)
// PluginManager is the implementation of grpc.PluginManager

View File

@@ -3,11 +3,10 @@ package pluginmanager_service
import (
"context"
"fmt"
"github.com/turbot/pipe-fittings/ociinstaller"
"github.com/turbot/pipe-fittings/utils"
"log"
"github.com/jackc/pgx/v5"
"github.com/turbot/pipe-fittings/ociinstaller"
sdkgrpc "github.com/turbot/steampipe-plugin-sdk/v5/grpc"
"github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/v5/sperr"

View File

@@ -6,6 +6,7 @@ import (
"time"
"github.com/spf13/viper"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/cmdconfig"
"github.com/turbot/steampipe/pkg/connection_sync"
"github.com/turbot/steampipe/pkg/constants"
@@ -16,7 +17,6 @@ import (
"github.com/turbot/steampipe/pkg/interactive"
"github.com/turbot/steampipe/pkg/query"
"github.com/turbot/steampipe/pkg/steampipeconfig/modconfig"
"github.com/turbot/steampipe/pkg/utils"
)
func RunInteractiveSession(ctx context.Context, initData *query.InitData) error {

View File

@@ -7,12 +7,12 @@ import (
"sync"
"time"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/connection_sync"
"github.com/turbot/steampipe/pkg/dashboard/dashboardevents"
"github.com/turbot/steampipe/pkg/dashboard/dashboardtypes"
"github.com/turbot/steampipe/pkg/db/db_common"
"github.com/turbot/steampipe/pkg/steampipeconfig/modconfig"
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/steampipe/pkg/workspace"
"golang.org/x/exp/maps"
)

View File

@@ -10,10 +10,10 @@ import (
"time"
filehelpers "github.com/turbot/go-kit/files"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/dashboard/dashboardevents"
"github.com/turbot/steampipe/pkg/dashboard/dashboardtypes"
"github.com/turbot/steampipe/pkg/db/db_common"
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/steampipe/pkg/workspace"
)

View File

@@ -8,9 +8,9 @@ import (
"strconv"
"sync"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/dashboard/dashboardtypes"
"github.com/turbot/steampipe/pkg/steampipeconfig/modconfig"
"github.com/turbot/steampipe/pkg/utils"
)
type runtimeDependencyPublisherImpl struct {

View File

@@ -3,9 +3,10 @@ package statushooks
import (
"context"
"fmt"
"github.com/turbot/steampipe/pkg/utils"
"strings"
"sync"
"github.com/turbot/pipe-fittings/utils"
)
// SnapshotProgressReporter is an implementation of SnapshotProgress

View File

@@ -5,9 +5,9 @@ import (
"log"
"strings"
typehelpers "github.com/turbot/go-kit/types"
"github.com/hashicorp/go-plugin"
typehelpers "github.com/turbot/go-kit/types"
"github.com/turbot/pipe-fittings/utils"
sdkgrpc "github.com/turbot/steampipe-plugin-sdk/v5/grpc"
sdkproto "github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto"
sdkplugin "github.com/turbot/steampipe-plugin-sdk/v5/plugin"
@@ -17,7 +17,6 @@ import (
pluginshared "github.com/turbot/steampipe/pkg/pluginmanager_service/grpc/shared"
"github.com/turbot/steampipe/pkg/steampipeconfig/modconfig"
"github.com/turbot/steampipe/pkg/steampipeconfig/options"
"github.com/turbot/steampipe/pkg/utils"
"golang.org/x/exp/maps"
)

View File

@@ -7,11 +7,11 @@ import (
"os"
"time"
"github.com/turbot/pipe-fittings/utils"
sdkplugin "github.com/turbot/steampipe-plugin-sdk/v5/plugin"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/filepaths"
"github.com/turbot/steampipe/pkg/steampipeconfig/modconfig"
"github.com/turbot/steampipe/pkg/utils"
"golang.org/x/exp/maps"
)

View File

@@ -9,9 +9,9 @@ import (
"time"
"github.com/otiai10/copy"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/filepaths"
"github.com/turbot/steampipe/pkg/utils"
)
type getConnectionsToUpdateTest struct {

View File

@@ -10,13 +10,13 @@ import (
"github.com/jackc/pgx/v5/pgxpool"
"github.com/turbot/go-kit/helpers"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe-plugin-sdk/v5/grpc/proto"
"github.com/turbot/steampipe-plugin-sdk/v5/plugin"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/db/db_common"
pluginshared "github.com/turbot/steampipe/pkg/pluginmanager_service/grpc/shared"
"github.com/turbot/steampipe/pkg/steampipeconfig/modconfig"
"github.com/turbot/steampipe/pkg/utils"
"golang.org/x/exp/maps"
)

View File

@@ -5,9 +5,9 @@ import (
"log"
"strings"
"github.com/turbot/pipe-fittings/utils"
sdkversion "github.com/turbot/steampipe-plugin-sdk/v5/version"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/utils"
)
func (u *ConnectionUpdates) validate() {

View File

@@ -6,8 +6,8 @@ import (
"strings"
"github.com/gertd/go-pluralize"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/steampipeconfig/modconfig"
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/terraform-components/tfdiags"
)

View File

@@ -18,6 +18,7 @@ import (
perror_helpers "github.com/turbot/pipe-fittings/error_helpers"
"github.com/turbot/pipe-fittings/hclhelpers"
"github.com/turbot/pipe-fittings/ociinstaller/versionfile"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe-plugin-sdk/v5/sperr"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/db/db_common"
@@ -26,7 +27,6 @@ import (
"github.com/turbot/steampipe/pkg/steampipeconfig/modconfig"
"github.com/turbot/steampipe/pkg/steampipeconfig/options"
"github.com/turbot/steampipe/pkg/steampipeconfig/parse"
"github.com/turbot/steampipe/pkg/utils"
)
var GlobalConfig *SteampipeConfig

View File

@@ -8,7 +8,7 @@ import (
"strings"
"testing"
utils "github.com/turbot/steampipe/pkg/utils"
utils "github.com/turbot/pipe-fittings/utils"
"golang.org/x/exp/maps"
"github.com/turbot/steampipe/pkg/filepaths"

View File

@@ -11,11 +11,11 @@ import (
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgconn"
"github.com/sethvargo/go-retry"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/db/db_common"
"github.com/turbot/steampipe/pkg/filepaths"
"github.com/turbot/steampipe/pkg/statushooks"
"github.com/turbot/steampipe/pkg/utils"
)
// LoadConnectionState populates a ConnectionStateMap from the connection_state table

View File

@@ -9,13 +9,13 @@ import (
"strings"
"github.com/spf13/viper"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe-plugin-sdk/v5/plugin"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/steampipeconfig/inputvars"
"github.com/turbot/steampipe/pkg/steampipeconfig/modconfig"
"github.com/turbot/steampipe/pkg/steampipeconfig/parse"
"github.com/turbot/steampipe/pkg/steampipeconfig/versionmap"
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/terraform-components/tfdiags"
)

View File

@@ -9,7 +9,7 @@ import (
"github.com/turbot/go-kit/types"
typehelpers "github.com/turbot/go-kit/types"
"github.com/turbot/pipe-fittings/hclhelpers"
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/pipe-fittings/utils"
"github.com/zclconf/go-cty/cty"
)

View File

@@ -10,9 +10,9 @@ import (
"github.com/hashicorp/hcl/v2"
"github.com/turbot/go-kit/helpers"
"github.com/turbot/pipe-fittings/hclhelpers"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/steampipeconfig/options"
"github.com/turbot/steampipe/pkg/utils"
"golang.org/x/exp/maps"
)

View File

@@ -8,7 +8,7 @@ import (
"github.com/turbot/go-kit/types"
typehelpers "github.com/turbot/go-kit/types"
"github.com/turbot/pipe-fittings/hclhelpers"
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/pipe-fittings/utils"
"github.com/zclconf/go-cty/cty"
)

View File

@@ -9,8 +9,8 @@ import (
"github.com/stevenle/topsort"
typehelpers "github.com/turbot/go-kit/types"
"github.com/turbot/pipe-fittings/hclhelpers"
"github.com/turbot/pipe-fittings/utils"
"github.com/turbot/steampipe/pkg/constants"
"github.com/turbot/steampipe/pkg/utils"
"github.com/zclconf/go-cty/cty"
)

View File

@@ -6,7 +6,7 @@ import (
"github.com/hashicorp/hcl/v2"
typehelpers "github.com/turbot/go-kit/types"
"github.com/turbot/pipe-fittings/hclhelpers"
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/pipe-fittings/utils"
"github.com/zclconf/go-cty/cty"
)

View File

@@ -5,7 +5,7 @@ import (
"github.com/hashicorp/hcl/v2"
"github.com/turbot/pipe-fittings/hclhelpers"
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/pipe-fittings/utils"
"github.com/zclconf/go-cty/cty"
)

View File

@@ -1,7 +1,7 @@
package modconfig
import (
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/pipe-fittings/utils"
)
type DashboardCategoryFold struct {

View File

@@ -1,7 +1,7 @@
package modconfig
import (
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/pipe-fittings/utils"
)
type DashboardCategoryProperty struct {

View File

@@ -6,7 +6,7 @@ import (
"github.com/hashicorp/hcl/v2"
typehelpers "github.com/turbot/go-kit/types"
"github.com/turbot/pipe-fittings/hclhelpers"
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/pipe-fittings/utils"
"github.com/zclconf/go-cty/cty"
)

View File

@@ -1,7 +1,7 @@
package modconfig
import (
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/pipe-fittings/utils"
)
type DashboardChartAxes struct {

View File

@@ -1,6 +1,6 @@
package modconfig
import "github.com/turbot/steampipe/pkg/utils"
import "github.com/turbot/pipe-fittings/utils"
type DashboardChartLabels struct {
Display *string `cty:"display" hcl:"display" json:"display,omitempty"`

View File

@@ -1,6 +1,6 @@
package modconfig
import "github.com/turbot/steampipe/pkg/utils"
import "github.com/turbot/pipe-fittings/utils"
type DashboardChartLegend struct {
Display *string `cty:"display" hcl:"display" json:"display,omitempty"`

View File

@@ -1,6 +1,6 @@
package modconfig
import "github.com/turbot/steampipe/pkg/utils"
import "github.com/turbot/pipe-fittings/utils"
type DashboardChartSeries struct {
Name string `hcl:"name,label" json:"name"`

View File

@@ -1,6 +1,6 @@
package modconfig
import "github.com/turbot/steampipe/pkg/utils"
import "github.com/turbot/pipe-fittings/utils"
type DashboardChartSeriesPoint struct {
Name string `hcl:"name,label" json:"-"`

View File

@@ -7,7 +7,7 @@ import (
"github.com/stevenle/topsort"
typehelpers "github.com/turbot/go-kit/types"
"github.com/turbot/pipe-fittings/hclhelpers"
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/pipe-fittings/utils"
"github.com/zclconf/go-cty/cty"
)

View File

@@ -6,7 +6,7 @@ import (
"github.com/hashicorp/hcl/v2"
typehelpers "github.com/turbot/go-kit/types"
"github.com/turbot/pipe-fittings/hclhelpers"
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/pipe-fittings/utils"
"github.com/zclconf/go-cty/cty"
)

View File

@@ -6,7 +6,7 @@ import (
"github.com/hashicorp/hcl/v2"
typehelpers "github.com/turbot/go-kit/types"
"github.com/turbot/pipe-fittings/hclhelpers"
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/pipe-fittings/utils"
"github.com/zclconf/go-cty/cty"
)

View File

@@ -6,7 +6,7 @@ import (
"github.com/hashicorp/hcl/v2"
typehelpers "github.com/turbot/go-kit/types"
"github.com/turbot/pipe-fittings/hclhelpers"
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/pipe-fittings/utils"
"github.com/zclconf/go-cty/cty"
)

View File

@@ -6,7 +6,7 @@ import (
"github.com/hashicorp/hcl/v2"
typehelpers "github.com/turbot/go-kit/types"
"github.com/turbot/pipe-fittings/hclhelpers"
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/pipe-fittings/utils"
"github.com/zclconf/go-cty/cty"
)

View File

@@ -6,7 +6,7 @@ import (
"github.com/hashicorp/hcl/v2"
typehelpers "github.com/turbot/go-kit/types"
"github.com/turbot/pipe-fittings/hclhelpers"
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/pipe-fittings/utils"
"github.com/zclconf/go-cty/cty"
)

View File

@@ -1,6 +1,6 @@
package modconfig
import "github.com/turbot/steampipe/pkg/utils"
import "github.com/turbot/pipe-fittings/utils"
// DashboardInputOption is a struct representing dashboard input option
type DashboardInputOption struct {

View File

@@ -5,7 +5,7 @@ import (
"github.com/hashicorp/hcl/v2"
typehelpers "github.com/turbot/go-kit/types"
"github.com/turbot/pipe-fittings/hclhelpers"
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/pipe-fittings/utils"
"github.com/zclconf/go-cty/cty"
)

View File

@@ -1,6 +1,6 @@
package modconfig
import "github.com/turbot/steampipe/pkg/utils"
import "github.com/turbot/pipe-fittings/utils"
type DashboardTableColumn struct {
Name string `hcl:"name,label" json:"name"`

View File

@@ -6,7 +6,7 @@ import (
"github.com/hashicorp/hcl/v2"
typehelpers "github.com/turbot/go-kit/types"
"github.com/turbot/pipe-fittings/hclhelpers"
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/pipe-fittings/utils"
"github.com/zclconf/go-cty/cty"
)

View File

@@ -2,7 +2,7 @@ package modconfig
import (
"github.com/turbot/go-kit/helpers"
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/pipe-fittings/utils"
"golang.org/x/exp/maps"
)

View File

@@ -4,7 +4,7 @@ import (
"fmt"
"strings"
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/pipe-fittings/utils"
)
type MissingVariableError struct {

View File

@@ -3,7 +3,7 @@ package modconfig
import (
"github.com/hashicorp/hcl/v2"
typehelpers "github.com/turbot/go-kit/types"
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/pipe-fittings/utils"
"github.com/zclconf/go-cty/cty"
)

View File

@@ -4,7 +4,7 @@ import (
"fmt"
"github.com/hashicorp/hcl/v2"
"github.com/turbot/steampipe/pkg/utils"
"github.com/turbot/pipe-fittings/utils"
"github.com/zclconf/go-cty/cty"
)

Some files were not shown because too many files have changed in this diff Show More