mirror of
https://github.com/turbot/steampipe.git
synced 2025-12-19 18:12:43 -05:00
compiles but needs testing
This commit is contained in:
@@ -2,12 +2,12 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/turbot/pipe-fittings/constants"
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/turbot/steampipe/pkg/cmdconfig"
|
||||
"github.com/turbot/steampipe/pkg/constants"
|
||||
)
|
||||
|
||||
func generateCompletionScriptsCmd() *cobra.Command {
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"bufio"
|
||||
"context"
|
||||
"fmt"
|
||||
constants2 "github.com/turbot/pipe-fittings/constants"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
@@ -28,7 +29,7 @@ func loginCmd() *cobra.Command {
|
||||
|
||||
cmdconfig.OnCmd(cmd).
|
||||
AddCloudFlags().
|
||||
AddBoolFlag(constants.ArgHelp, false, "Help for dashboard", cmdconfig.FlagOptions.WithShortHand("h"))
|
||||
AddBoolFlag(constants2.ArgHelp, false, "Help for dashboard", cmdconfig.FlagOptions.WithShortHand("h"))
|
||||
|
||||
return cmd
|
||||
}
|
||||
@@ -36,7 +37,7 @@ func loginCmd() *cobra.Command {
|
||||
func runLoginCmd(cmd *cobra.Command, _ []string) {
|
||||
ctx := cmd.Context()
|
||||
|
||||
log.Printf("[TRACE] login, pipes host %s", viper.Get(constants.ArgPipesHost))
|
||||
log.Printf("[TRACE] login, pipes host %s", viper.Get(constants2.ArgPipesHost))
|
||||
log.Printf("[TRACE] opening login web page")
|
||||
// start login flow - this will open a web page prompting user to login, and will give the user a code to enter
|
||||
var id, err = cloud.WebLogin(ctx)
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/turbot/steampipe/pkg/ociinstaller"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -14,10 +13,11 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/turbot/go-kit/helpers"
|
||||
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"
|
||||
"github.com/turbot/pipe-fittings/plugin"
|
||||
pplugin "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"
|
||||
@@ -27,6 +27,8 @@ import (
|
||||
"github.com/turbot/steampipe/pkg/display"
|
||||
"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"
|
||||
)
|
||||
@@ -76,14 +78,14 @@ Examples:
|
||||
PersistentPostRun: func(cmd *cobra.Command, args []string) {
|
||||
utils.LogTime("cmd.plugin.PersistentPostRun start")
|
||||
defer utils.LogTime("cmd.plugin.PersistentPostRun end")
|
||||
plugin.CleanupOldTmpDirs(cmd.Context())
|
||||
pplugin.CleanupOldTmpDirs(cmd.Context())
|
||||
},
|
||||
}
|
||||
cmd.AddCommand(pluginInstallCmd())
|
||||
cmd.AddCommand(pluginListCmd())
|
||||
cmd.AddCommand(pluginUninstallCmd())
|
||||
cmd.AddCommand(pluginUpdateCmd())
|
||||
cmd.Flags().BoolP(constants.ArgHelp, "h", false, "Help for plugin")
|
||||
cmd.Flags().BoolP(pconstants.ArgHelp, "h", false, "Help for plugin")
|
||||
|
||||
return cmd
|
||||
}
|
||||
@@ -122,9 +124,9 @@ Examples:
|
||||
|
||||
cmdconfig.
|
||||
OnCmd(cmd).
|
||||
AddBoolFlag(constants.ArgProgress, true, "Display installation progress").
|
||||
AddBoolFlag(constants.ArgSkipConfig, false, "Skip creating the default config file for plugin").
|
||||
AddBoolFlag(constants.ArgHelp, false, "Help for plugin install", cmdconfig.FlagOptions.WithShortHand("h"))
|
||||
AddBoolFlag(pconstants.ArgProgress, true, "Display installation progress").
|
||||
AddBoolFlag(pconstants.ArgSkipConfig, false, "Skip creating the default config file for plugin").
|
||||
AddBoolFlag(pconstants.ArgHelp, false, "Help for plugin install", cmdconfig.FlagOptions.WithShortHand("h"))
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -156,9 +158,9 @@ Examples:
|
||||
|
||||
cmdconfig.
|
||||
OnCmd(cmd).
|
||||
AddBoolFlag(constants.ArgAll, false, "Update all plugins to its latest available version").
|
||||
AddBoolFlag(constants.ArgProgress, true, "Display installation progress").
|
||||
AddBoolFlag(constants.ArgHelp, false, "Help for plugin update", cmdconfig.FlagOptions.WithShortHand("h"))
|
||||
AddBoolFlag(pconstants.ArgAll, false, "Update all plugins to its latest available version").
|
||||
AddBoolFlag(pconstants.ArgProgress, true, "Display installation progress").
|
||||
AddBoolFlag(pconstants.ArgHelp, false, "Help for plugin update", cmdconfig.FlagOptions.WithShortHand("h"))
|
||||
|
||||
return cmd
|
||||
}
|
||||
@@ -189,8 +191,8 @@ Examples:
|
||||
cmdconfig.
|
||||
OnCmd(cmd).
|
||||
AddBoolFlag("outdated", false, "Check each plugin in the list for updates").
|
||||
AddStringFlag(constants.ArgOutput, "table", "Output format: table or json").
|
||||
AddBoolFlag(constants.ArgHelp, false, "Help for plugin list", cmdconfig.FlagOptions.WithShortHand("h"))
|
||||
AddStringFlag(pconstants.ArgOutput, "table", "Output format: table or json").
|
||||
AddBoolFlag(pconstants.ArgHelp, false, "Help for plugin list", cmdconfig.FlagOptions.WithShortHand("h"))
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -216,7 +218,7 @@ Example:
|
||||
}
|
||||
|
||||
cmdconfig.OnCmd(cmd).
|
||||
AddBoolFlag(constants.ArgHelp, false, "Help for plugin uninstall", cmdconfig.FlagOptions.WithShortHand("h"))
|
||||
AddBoolFlag(pconstants.ArgHelp, false, "Help for plugin uninstall", cmdconfig.FlagOptions.WithShortHand("h"))
|
||||
|
||||
return cmd
|
||||
}
|
||||
@@ -249,7 +251,7 @@ func runPluginInstallCmd(cmd *cobra.Command, args []string) {
|
||||
// - aws@^0.118
|
||||
// - ghcr.io/turbot/steampipe/plugins/turbot/aws:1.0.0
|
||||
plugins := append([]string{}, args...)
|
||||
showProgress := viper.GetBool(constants.ArgProgress)
|
||||
showProgress := viper.GetBool(pconstants.ArgProgress)
|
||||
installReports := make(display.PluginInstallReports, 0, len(plugins))
|
||||
|
||||
if len(plugins) == 0 {
|
||||
@@ -289,14 +291,14 @@ func runPluginInstallCmd(cmd *cobra.Command, args []string) {
|
||||
ref := putils.NewImageRef(pluginName)
|
||||
org, name, constraint := ref.GetOrgNameAndStream()
|
||||
orgAndName := fmt.Sprintf("%s/%s", org, name)
|
||||
var resolved plugin.ResolvedPluginVersion
|
||||
var resolved pplugin.ResolvedPluginVersion
|
||||
if ref.IsFromTurbotHub() {
|
||||
rpv, err := plugin.GetLatestPluginVersionByConstraint(ctx, state.InstallationID, org, name, constraint)
|
||||
rpv, err := pplugin.GetLatestPluginVersionByConstraint(ctx, state.InstallationID, org, name, constraint)
|
||||
if err != nil || rpv == nil {
|
||||
report := &display.PluginInstallReport{
|
||||
Plugin: pluginName,
|
||||
Skipped: true,
|
||||
SkipReason: constants.InstallMessagePluginNotFound,
|
||||
SkipReason: pconstants.InstallMessagePluginNotFound,
|
||||
IsUpdateReport: false,
|
||||
}
|
||||
reportChannel <- report
|
||||
@@ -305,7 +307,7 @@ func runPluginInstallCmd(cmd *cobra.Command, args []string) {
|
||||
}
|
||||
resolved = *rpv
|
||||
} else {
|
||||
resolved = plugin.NewResolvedPluginVersion(orgAndName, constraint, constraint)
|
||||
resolved = pplugin.NewResolvedPluginVersion(orgAndName, constraint, constraint)
|
||||
}
|
||||
|
||||
go doPluginInstall(ctx, bar, pluginName, resolved, installWaitGroup, reportChannel)
|
||||
@@ -332,7 +334,7 @@ func runPluginInstallCmd(cmd *cobra.Command, args []string) {
|
||||
|
||||
// reload the config, since an installation should have created a new config file
|
||||
var cmd = viper.Get(constants.ConfigKeyActiveCommand).(*cobra.Command)
|
||||
config, errorsAndWarnings := steampipeconfig.LoadSteampipeConfig(ctx, viper.GetString(constants.ArgModLocation), cmd.Name())
|
||||
config, errorsAndWarnings := steampipeconfig.LoadSteampipeConfig(ctx, viper.GetString(pconstants.ArgModLocation), cmd.Name())
|
||||
if errorsAndWarnings.GetError() != nil {
|
||||
error_helpers.ShowWarning(fmt.Sprintf("Failed to reload config - install report may be incomplete (%s)", errorsAndWarnings.GetError()))
|
||||
} else {
|
||||
@@ -347,29 +349,29 @@ func runPluginInstallCmd(cmd *cobra.Command, args []string) {
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
func doPluginInstall(ctx context.Context, bar *uiprogress.Bar, pluginName string, resolvedPlugin plugin.ResolvedPluginVersion, wg *sync.WaitGroup, returnChannel chan *display.PluginInstallReport) {
|
||||
func doPluginInstall(ctx context.Context, bar *uiprogress.Bar, pluginName string, resolvedPlugin pplugin.ResolvedPluginVersion, wg *sync.WaitGroup, returnChannel chan *display.PluginInstallReport) {
|
||||
var report *display.PluginInstallReport
|
||||
|
||||
pluginAlreadyInstalled, _ := plugin.Exists(ctx, pluginName)
|
||||
pluginAlreadyInstalled, _ := pplugin.Exists(ctx, pluginName)
|
||||
if pluginAlreadyInstalled {
|
||||
// set the bar to MAX
|
||||
//nolint:golint,errcheck // the error happens if we set this over the max value
|
||||
bar.Set(len(pluginInstallSteps))
|
||||
// let the bar append itself with "Already Installed"
|
||||
bar.AppendFunc(func(b *uiprogress.Bar) string {
|
||||
return helpers.Resize(constants.InstallMessagePluginAlreadyInstalled, 20)
|
||||
return helpers.Resize(pconstants.InstallMessagePluginAlreadyInstalled, 20)
|
||||
})
|
||||
report = &display.PluginInstallReport{
|
||||
Plugin: pluginName,
|
||||
Skipped: true,
|
||||
SkipReason: constants.InstallMessagePluginAlreadyInstalled,
|
||||
SkipReason: pconstants.InstallMessagePluginAlreadyInstalled,
|
||||
IsUpdateReport: false,
|
||||
}
|
||||
} else {
|
||||
// let the bar append itself with the current installation step
|
||||
bar.AppendFunc(func(b *uiprogress.Bar) string {
|
||||
if report != nil && report.SkipReason == constants.InstallMessagePluginNotFound {
|
||||
return helpers.Resize(constants.InstallMessagePluginNotFound, 20)
|
||||
if report != nil && report.SkipReason == pconstants.InstallMessagePluginNotFound {
|
||||
return helpers.Resize(pconstants.InstallMessagePluginNotFound, 20)
|
||||
} else {
|
||||
if b.Current() == 0 {
|
||||
// no install step to display yet
|
||||
@@ -404,7 +406,7 @@ func runPluginUpdateCmd(cmd *cobra.Command, args []string) {
|
||||
// - aws@^0.118
|
||||
// - ghcr.io/turbot/steampipe/plugins/turbot/aws:1.0.0
|
||||
plugins, err := resolveUpdatePluginsFromArgs(args)
|
||||
showProgress := viper.GetBool(constants.ArgProgress)
|
||||
showProgress := viper.GetBool(pconstants.ArgProgress)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println()
|
||||
@@ -416,7 +418,7 @@ func runPluginUpdateCmd(cmd *cobra.Command, args []string) {
|
||||
return
|
||||
}
|
||||
|
||||
if len(plugins) > 0 && !(cmdconfig.Viper().GetBool(constants.ArgAll)) && plugins[0] == constants.ArgAll {
|
||||
if len(plugins) > 0 && !(cmdconfig.Viper().GetBool(pconstants.ArgAll)) && plugins[0] == pconstants.ArgAll {
|
||||
// improve the response to wrong argument "steampipe plugin update all"
|
||||
fmt.Println()
|
||||
exitCode = constants.ExitCodeInsufficientOrWrongInputs
|
||||
@@ -441,7 +443,7 @@ func runPluginUpdateCmd(cmd *cobra.Command, args []string) {
|
||||
// a leading blank line - since we always output multiple lines
|
||||
fmt.Println()
|
||||
|
||||
if cmdconfig.Viper().GetBool(constants.ArgAll) {
|
||||
if cmdconfig.Viper().GetBool(pconstants.ArgAll) {
|
||||
for k, v := range pluginVersions {
|
||||
ref := putils.NewImageRef(k)
|
||||
org, name, constraint := ref.GetOrgNameAndStream()
|
||||
@@ -454,7 +456,7 @@ func runPluginUpdateCmd(cmd *cobra.Command, args []string) {
|
||||
// get the args and retrieve the installed versions
|
||||
for _, p := range plugins {
|
||||
ref := putils.NewImageRef(p)
|
||||
isExists, _ := plugin.Exists(ctx, p)
|
||||
isExists, _ := pplugin.Exists(ctx, p)
|
||||
if isExists {
|
||||
if strings.HasPrefix(ref.DisplayImageRef(), constants.SteampipeHubOCIBase) {
|
||||
runUpdatesFor = append(runUpdatesFor, pluginVersions[ref.DisplayImageRef()])
|
||||
@@ -468,7 +470,7 @@ func runPluginUpdateCmd(cmd *cobra.Command, args []string) {
|
||||
updateResults = append(updateResults, &display.PluginInstallReport{
|
||||
Skipped: true,
|
||||
Plugin: p,
|
||||
SkipReason: constants.InstallMessagePluginNotInstalled,
|
||||
SkipReason: pconstants.InstallMessagePluginNotInstalled,
|
||||
IsUpdateReport: true,
|
||||
})
|
||||
}
|
||||
@@ -488,7 +490,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 := pplugin.GetUpdateReport(timeoutCtx, state.InstallationID, runUpdatesFor)
|
||||
statushooks.Done(ctx)
|
||||
if len(reports) == 0 {
|
||||
// this happens if for some reason the update server could not be contacted,
|
||||
@@ -534,10 +536,10 @@ func runPluginUpdateCmd(cmd *cobra.Command, args []string) {
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
func doPluginUpdate(ctx context.Context, bar *uiprogress.Bar, pvr plugin.PluginVersionCheckReport, wg *sync.WaitGroup, returnChannel chan *display.PluginInstallReport) {
|
||||
func doPluginUpdate(ctx context.Context, bar *uiprogress.Bar, pvr pplugin.PluginVersionCheckReport, wg *sync.WaitGroup, returnChannel chan *display.PluginInstallReport) {
|
||||
var report *display.PluginInstallReport
|
||||
|
||||
if plugin.UpdateRequired(pvr) {
|
||||
if pplugin.UpdateRequired(pvr) {
|
||||
// update required, resolve version and install update
|
||||
bar.AppendFunc(func(b *uiprogress.Bar) string {
|
||||
// set the progress bar to append itself with the step underway
|
||||
@@ -547,20 +549,20 @@ func doPluginUpdate(ctx context.Context, bar *uiprogress.Bar, pvr plugin.PluginV
|
||||
}
|
||||
return helpers.Resize(pluginInstallSteps[b.Current()-1], 20)
|
||||
})
|
||||
rp := plugin.NewResolvedPluginVersion(pvr.ShortName(), pvr.CheckResponse.Version, pvr.CheckResponse.Constraint)
|
||||
rp := pplugin.NewResolvedPluginVersion(pvr.ShortName(), pvr.CheckResponse.Version, pvr.CheckResponse.Constraint)
|
||||
report = installPlugin(ctx, rp, true, bar)
|
||||
} else {
|
||||
// update NOT required, return already installed report
|
||||
bar.AppendFunc(func(b *uiprogress.Bar) string {
|
||||
// set the progress bar to append itself with "Already Installed"
|
||||
return helpers.Resize(constants.InstallMessagePluginLatestAlreadyInstalled, 30)
|
||||
return helpers.Resize(pconstants.InstallMessagePluginLatestAlreadyInstalled, 30)
|
||||
})
|
||||
// set the progress bar to the maximum
|
||||
bar.Set(len(pluginInstallSteps))
|
||||
report = &display.PluginInstallReport{
|
||||
Plugin: fmt.Sprintf("%s@%s", pvr.CheckResponse.Name, pvr.CheckResponse.Constraint),
|
||||
Skipped: true,
|
||||
SkipReason: constants.InstallMessagePluginLatestAlreadyInstalled,
|
||||
SkipReason: pconstants.InstallMessagePluginLatestAlreadyInstalled,
|
||||
IsUpdateReport: true,
|
||||
}
|
||||
}
|
||||
@@ -577,7 +579,7 @@ func createProgressBar(plugin string, parentProgressBars *uiprogress.Progress) *
|
||||
return bar
|
||||
}
|
||||
|
||||
func installPlugin(ctx context.Context, resolvedPlugin plugin.ResolvedPluginVersion, isUpdate bool, bar *uiprogress.Bar) *display.PluginInstallReport {
|
||||
func installPlugin(ctx context.Context, resolvedPlugin pplugin.ResolvedPluginVersion, isUpdate bool, bar *uiprogress.Bar) *display.PluginInstallReport {
|
||||
// start a channel for progress publications from plugin.Install
|
||||
progress := make(chan struct{}, 5)
|
||||
defer func() {
|
||||
@@ -593,14 +595,14 @@ func installPlugin(ctx context.Context, resolvedPlugin plugin.ResolvedPluginVers
|
||||
}
|
||||
}()
|
||||
|
||||
image, err := plugin.Install(ctx, resolvedPlugin, progress, constants.BaseImageRef, ociinstaller.SteampipeMediaTypeProvider{}, putils.WithSkipConfig(viper.GetBool(constants.ArgSkipConfig)))
|
||||
image, err := plugin.Install(ctx, resolvedPlugin, progress, constants.BaseImageRef, ociinstaller.SteampipeMediaTypeProvider{}, putils.WithSkipConfig(viper.GetBool(pconstants.ArgSkipConfig)))
|
||||
if err != nil {
|
||||
msg := ""
|
||||
// used to build data for the plugin install report to be used for display purposes
|
||||
_, name, constraint := putils.NewImageRef(resolvedPlugin.GetVersionTag()).GetOrgNameAndStream()
|
||||
if isPluginNotFoundErr(err) {
|
||||
exitCode = constants.ExitCodePluginNotFound
|
||||
msg = constants.InstallMessagePluginNotFound
|
||||
msg = pconstants.InstallMessagePluginNotFound
|
||||
} else {
|
||||
msg = err.Error()
|
||||
}
|
||||
@@ -643,7 +645,7 @@ func resolveUpdatePluginsFromArgs(args []string) ([]string, error) {
|
||||
return nil, fmt.Errorf("you need to provide at least one plugin to update or use the %s flag", constants.Bold("--all"))
|
||||
}
|
||||
|
||||
if len(plugins) > 0 && cmdconfig.Viper().GetBool(constants.ArgAll) {
|
||||
if len(plugins) > 0 && cmdconfig.Viper().GetBool(pconstants.ArgAll) {
|
||||
// we can't allow update and install at the same time
|
||||
return nil, fmt.Errorf("%s cannot be used when updating specific plugins", constants.Bold("`--all`"))
|
||||
}
|
||||
@@ -655,7 +657,7 @@ func runPluginListCmd(cmd *cobra.Command, _ []string) {
|
||||
// setup a cancel context and start cancel handler
|
||||
ctx, cancel := context.WithCancel(cmd.Context())
|
||||
contexthelpers.StartCancelHandler(cancel)
|
||||
outputFormat := viper.GetString(constants.ArgOutput)
|
||||
outputFormat := viper.GetString(pconstants.ArgOutput)
|
||||
|
||||
utils.LogTime("runPluginListCmd list")
|
||||
defer func() {
|
||||
@@ -716,7 +718,7 @@ func showPluginListAsTable(pluginList []plugin.PluginListItem, failedPluginMap,
|
||||
for _, conn := range item {
|
||||
conns = append(conns, conn.GetName())
|
||||
}
|
||||
missingRows = append(missingRows, []string{p, strings.Join(conns, ","), constants.ConnectionErrorPluginFailedToStart})
|
||||
missingRows = append(missingRows, []string{p, strings.Join(conns, ","), pconstants.ConnectionErrorPluginFailedToStart})
|
||||
conns = []string{}
|
||||
}
|
||||
|
||||
@@ -725,7 +727,7 @@ func showPluginListAsTable(pluginList []plugin.PluginListItem, failedPluginMap,
|
||||
for _, conn := range item {
|
||||
conns = append(conns, conn.GetName())
|
||||
}
|
||||
missingRows = append(missingRows, []string{p, strings.Join(conns, ","), constants.InstallMessagePluginNotInstalled})
|
||||
missingRows = append(missingRows, []string{p, strings.Join(conns, ","), pconstants.InstallMessagePluginNotInstalled})
|
||||
conns = []string{}
|
||||
}
|
||||
|
||||
@@ -761,7 +763,7 @@ func showPluginListAsJSON(pluginList []plugin.PluginListItem, failedPluginMap, m
|
||||
failed := failedPlugin{
|
||||
Name: p,
|
||||
Connections: connections,
|
||||
Reason: constants.ConnectionErrorPluginFailedToStart,
|
||||
Reason: pconstants.ConnectionErrorPluginFailedToStart,
|
||||
}
|
||||
output.Failed = append(output.Failed, failed)
|
||||
}
|
||||
@@ -774,7 +776,7 @@ func showPluginListAsJSON(pluginList []plugin.PluginListItem, failedPluginMap, m
|
||||
missing := failedPlugin{
|
||||
Name: p,
|
||||
Connections: connections,
|
||||
Reason: constants.InstallMessagePluginNotInstalled,
|
||||
Reason: pconstants.InstallMessagePluginNotInstalled,
|
||||
}
|
||||
output.Failed = append(output.Failed, missing)
|
||||
}
|
||||
@@ -898,9 +900,9 @@ func getPluginConnectionMap(ctx context.Context) (pluginConnectionMap, failedPlu
|
||||
continue
|
||||
}
|
||||
|
||||
if state.State == constants.ConnectionStateError && state.Error() == constants.ConnectionErrorPluginFailedToStart {
|
||||
if state.State == constants.ConnectionStateError && state.Error() == pconstants.ConnectionErrorPluginFailedToStart {
|
||||
failedPluginMap[state.Plugin] = append(failedPluginMap[state.Plugin], connection)
|
||||
} else if state.State == constants.ConnectionStateError && state.Error() == constants.ConnectionErrorPluginNotInstalled {
|
||||
} else if state.State == constants.ConnectionStateError && state.Error() == pconstants.ConnectionErrorPluginNotInstalled {
|
||||
missingPluginMap[state.Plugin] = append(missingPluginMap[state.Plugin], connection)
|
||||
}
|
||||
|
||||
|
||||
57
cmd/query.go
57
cmd/query.go
@@ -4,6 +4,7 @@ import (
|
||||
"bufio"
|
||||
"context"
|
||||
"fmt"
|
||||
constants2 "github.com/turbot/pipe-fittings/constants"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
@@ -59,34 +60,34 @@ Examples:
|
||||
AddCloudFlags().
|
||||
AddWorkspaceDatabaseFlag().
|
||||
AddModLocationFlag().
|
||||
AddBoolFlag(constants.ArgHelp, false, "Help for query", cmdconfig.FlagOptions.WithShortHand("h")).
|
||||
AddBoolFlag(constants.ArgHeader, true, "Include column headers csv and table output").
|
||||
AddStringFlag(constants.ArgSeparator, ",", "Separator string for csv output").
|
||||
AddVarFlag(enumflag.New(&queryOutputMode, constants.ArgOutput, constants.QueryOutputModeIds, enumflag.EnumCaseInsensitive),
|
||||
constants.ArgOutput,
|
||||
AddBoolFlag(constants2.ArgHelp, false, "Help for query", cmdconfig.FlagOptions.WithShortHand("h")).
|
||||
AddBoolFlag(constants2.ArgHeader, true, "Include column headers csv and table output").
|
||||
AddStringFlag(constants2.ArgSeparator, ",", "Separator string for csv output").
|
||||
AddVarFlag(enumflag.New(&queryOutputMode, constants2.ArgOutput, constants.QueryOutputModeIds, enumflag.EnumCaseInsensitive),
|
||||
constants2.ArgOutput,
|
||||
fmt.Sprintf("Output format; one of: %s", strings.Join(constants.FlagValues(constants.QueryOutputModeIds), ", "))).
|
||||
AddVarFlag(enumflag.New(&queryTimingMode, constants.ArgTiming, constants.QueryTimingModeIds, enumflag.EnumCaseInsensitive),
|
||||
constants.ArgTiming,
|
||||
AddVarFlag(enumflag.New(&queryTimingMode, constants2.ArgTiming, constants.QueryTimingModeIds, enumflag.EnumCaseInsensitive),
|
||||
constants2.ArgTiming,
|
||||
fmt.Sprintf("Display query timing; one of: %s", strings.Join(constants.FlagValues(constants.QueryTimingModeIds), ", ")),
|
||||
cmdconfig.FlagOptions.NoOptDefVal(constants.ArgOn)).
|
||||
cmdconfig.FlagOptions.NoOptDefVal(constants2.ArgOn)).
|
||||
// TODO #breakingchange
|
||||
//AddBoolFlag(constants.ArgWatch, true, "Watch SQL files in the current workspace (works only in interactive mode)").
|
||||
AddStringSliceFlag(constants.ArgSearchPath, nil, "Set a custom search_path for the steampipe user for a query session (comma-separated)").
|
||||
AddStringSliceFlag(constants.ArgSearchPathPrefix, nil, "Set a prefix to the current search path for a query session (comma-separated)").
|
||||
AddStringSliceFlag(constants.ArgVarFile, nil, "Specify a file containing variable values").
|
||||
AddStringSliceFlag(constants2.ArgSearchPath, nil, "Set a custom search_path for the steampipe user for a query session (comma-separated)").
|
||||
AddStringSliceFlag(constants2.ArgSearchPathPrefix, nil, "Set a prefix to the current search path for a query session (comma-separated)").
|
||||
AddStringSliceFlag(constants2.ArgVarFile, nil, "Specify a file containing variable values").
|
||||
// NOTE: use StringArrayFlag for ArgVariable, not StringSliceFlag
|
||||
// Cobra will interpret values passed to a StringSliceFlag as CSV,
|
||||
// where args passed to StringArrayFlag are not parsed and used raw
|
||||
AddStringArrayFlag(constants.ArgVariable, nil, "Specify the value of a variable").
|
||||
AddBoolFlag(constants.ArgInput, true, "Enable interactive prompts").
|
||||
AddBoolFlag(constants.ArgSnapshot, false, "Create snapshot in Turbot Pipes with the default (workspace) visibility").
|
||||
AddBoolFlag(constants.ArgShare, false, "Create snapshot in Turbot Pipes with 'anyone_with_link' visibility").
|
||||
AddStringArrayFlag(constants.ArgSnapshotTag, nil, "Specify tags to set on the snapshot").
|
||||
AddStringFlag(constants.ArgSnapshotTitle, "", "The title to give a snapshot").
|
||||
AddIntFlag(constants.ArgDatabaseQueryTimeout, 0, "The query timeout").
|
||||
AddStringSliceFlag(constants.ArgExport, nil, "Export output to file, supported format: sps (snapshot)").
|
||||
AddStringFlag(constants.ArgSnapshotLocation, "", "The location to write snapshots - either a local file path or a Turbot Pipes workspace").
|
||||
AddBoolFlag(constants.ArgProgress, true, "Display snapshot upload status")
|
||||
AddStringArrayFlag(constants2.ArgVariable, nil, "Specify the value of a variable").
|
||||
AddBoolFlag(constants2.ArgInput, true, "Enable interactive prompts").
|
||||
AddBoolFlag(constants2.ArgSnapshot, false, "Create snapshot in Turbot Pipes with the default (workspace) visibility").
|
||||
AddBoolFlag(constants2.ArgShare, false, "Create snapshot in Turbot Pipes with 'anyone_with_link' visibility").
|
||||
AddStringArrayFlag(constants2.ArgSnapshotTag, nil, "Specify tags to set on the snapshot").
|
||||
AddStringFlag(constants2.ArgSnapshotTitle, "", "The title to give a snapshot").
|
||||
AddIntFlag(constants2.ArgDatabaseQueryTimeout, 0, "The query timeout").
|
||||
AddStringSliceFlag(constants2.ArgExport, nil, "Export output to file, supported format: sps (snapshot)").
|
||||
AddStringFlag(constants2.ArgSnapshotLocation, "", "The location to write snapshots - either a local file path or a Turbot Pipes workspace").
|
||||
AddBoolFlag(constants2.ArgProgress, true, "Display snapshot upload status")
|
||||
|
||||
cmd.AddCommand(getListSubCmd(listSubCmdOptions{parentCmd: cmd}))
|
||||
|
||||
@@ -166,11 +167,11 @@ func runQueryCmd(cmd *cobra.Command, args []string) {
|
||||
|
||||
func validateQueryArgs(ctx context.Context, args []string) error {
|
||||
interactiveMode := len(args) == 0
|
||||
if interactiveMode && (viper.IsSet(constants.ArgSnapshot) || viper.IsSet(constants.ArgShare)) {
|
||||
if interactiveMode && (viper.IsSet(constants2.ArgSnapshot) || viper.IsSet(constants2.ArgShare)) {
|
||||
exitCode = constants.ExitCodeInsufficientOrWrongInputs
|
||||
return sperr.New("cannot share snapshots in interactive mode")
|
||||
}
|
||||
if interactiveMode && len(viper.GetStringSlice(constants.ArgExport)) > 0 {
|
||||
if interactiveMode && len(viper.GetStringSlice(constants2.ArgExport)) > 0 {
|
||||
exitCode = constants.ExitCodeInsufficientOrWrongInputs
|
||||
return sperr.New("cannot export query results in interactive mode")
|
||||
}
|
||||
@@ -182,7 +183,7 @@ func validateQueryArgs(ctx context.Context, args []string) error {
|
||||
}
|
||||
|
||||
validOutputFormats := []string{constants.OutputFormatLine, constants.OutputFormatCSV, constants.OutputFormatTable, constants.OutputFormatJSON, constants.OutputFormatSnapshot, constants.OutputFormatSnapshotShort, constants.OutputFormatNone}
|
||||
output := viper.GetString(constants.ArgOutput)
|
||||
output := viper.GetString(constants2.ArgOutput)
|
||||
if !helpers.StringSliceContains(validOutputFormats, output) {
|
||||
exitCode = constants.ExitCodeInsufficientOrWrongInputs
|
||||
return sperr.New("invalid output format: '%s', must be one of [%s]", output, strings.Join(validOutputFormats, ", "))
|
||||
@@ -342,15 +343,15 @@ func executeSnapshotQuery(initData *query.InitData, ctx context.Context) int {
|
||||
func snapshotRequired() bool {
|
||||
SnapshotFormatNames := []string{constants.OutputFormatSnapshot, constants.OutputFormatSnapshotShort}
|
||||
// if a snapshot exporter is specified return true
|
||||
for _, e := range viper.GetStringSlice(constants.ArgExport) {
|
||||
for _, e := range viper.GetStringSlice(constants2.ArgExport) {
|
||||
if helpers.StringSliceContains(SnapshotFormatNames, e) || path.Ext(e) == constants.SnapshotExtension {
|
||||
return true
|
||||
}
|
||||
}
|
||||
// if share/snapshot args are set or output is snapshot, return true
|
||||
return viper.IsSet(constants.ArgShare) ||
|
||||
viper.IsSet(constants.ArgSnapshot) ||
|
||||
helpers.StringSliceContains(SnapshotFormatNames, viper.GetString(constants.ArgOutput))
|
||||
return viper.IsSet(constants2.ArgShare) ||
|
||||
viper.IsSet(constants2.ArgSnapshot) ||
|
||||
helpers.StringSliceContains(SnapshotFormatNames, viper.GetString(constants2.ArgOutput))
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package cmd
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/turbot/pipe-fittings/constants"
|
||||
"os"
|
||||
|
||||
"github.com/mattn/go-isatty"
|
||||
@@ -11,7 +12,6 @@ import (
|
||||
filehelpers "github.com/turbot/go-kit/files"
|
||||
"github.com/turbot/pipe-fittings/app_specific"
|
||||
"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/version"
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
constants2 "github.com/turbot/pipe-fittings/constants"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
@@ -42,7 +43,7 @@ connection from any Postgres compatible database client.`,
|
||||
cmd.AddCommand(serviceStatusCmd())
|
||||
cmd.AddCommand(serviceStopCmd())
|
||||
cmd.AddCommand(serviceRestartCmd())
|
||||
cmd.Flags().BoolP(constants.ArgHelp, "h", false, "Help for service")
|
||||
cmd.Flags().BoolP(constants2.ArgHelp, "h", false, "Help for service")
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -62,17 +63,17 @@ connection from any Postgres compatible database client.`,
|
||||
cmdconfig.
|
||||
OnCmd(cmd).
|
||||
AddModLocationFlag().
|
||||
AddBoolFlag(constants.ArgHelp, false, "Help for service start", cmdconfig.FlagOptions.WithShortHand("h")).
|
||||
AddIntFlag(constants.ArgDatabasePort, constants.DatabaseDefaultPort, "Database service port").
|
||||
AddStringFlag(constants.ArgDatabaseListenAddresses, string(db_local.ListenTypeNetwork), "Accept connections from: `local` (an alias for `localhost` only), `network` (an alias for `*`), or a comma separated list of hosts and/or IP addresses").
|
||||
AddStringFlag(constants.ArgServicePassword, "", "Set the database password for this session").
|
||||
AddBoolFlag(constants2.ArgHelp, false, "Help for service start", cmdconfig.FlagOptions.WithShortHand("h")).
|
||||
AddIntFlag(constants2.ArgDatabasePort, constants.DatabaseDefaultPort, "Database service port").
|
||||
AddStringFlag(constants2.ArgDatabaseListenAddresses, string(db_local.ListenTypeNetwork), "Accept connections from: `local` (an alias for `localhost` only), `network` (an alias for `*`), or a comma separated list of hosts and/or IP addresses").
|
||||
AddStringFlag(constants2.ArgServicePassword, "", "Set the database password for this session").
|
||||
// default is false and hides the database user password from service start prompt
|
||||
AddBoolFlag(constants.ArgServiceShowPassword, false, "View database password for connecting from another machine").
|
||||
AddBoolFlag(constants2.ArgServiceShowPassword, false, "View database password for connecting from another machine").
|
||||
// foreground enables the service to run in the foreground - till exit
|
||||
AddBoolFlag(constants.ArgForeground, false, "Run the service in the foreground").
|
||||
AddBoolFlag(constants2.ArgForeground, false, "Run the service in the foreground").
|
||||
|
||||
// hidden flags for internal use
|
||||
AddStringFlag(constants.ArgInvoker, string(constants.InvokerService), "Invoked by \"service\" or \"query\"", cmdconfig.FlagOptions.Hidden())
|
||||
AddStringFlag(constants2.ArgInvoker, string(constants.InvokerService), "Invoked by \"service\" or \"query\"", cmdconfig.FlagOptions.Hidden())
|
||||
|
||||
return cmd
|
||||
}
|
||||
@@ -90,10 +91,10 @@ Report current status of the Steampipe database service.`,
|
||||
}
|
||||
|
||||
cmdconfig.OnCmd(cmd).
|
||||
AddBoolFlag(constants.ArgHelp, false, "Help for service status", cmdconfig.FlagOptions.WithShortHand("h")).
|
||||
AddBoolFlag(constants2.ArgHelp, false, "Help for service status", cmdconfig.FlagOptions.WithShortHand("h")).
|
||||
// default is false and hides the database user password from service start prompt
|
||||
AddBoolFlag(constants.ArgServiceShowPassword, false, "View database password for connecting from another machine").
|
||||
AddBoolFlag(constants.ArgAll, false, "Bypasses the INSTALL_DIR and reports status of all running steampipe services")
|
||||
AddBoolFlag(constants2.ArgServiceShowPassword, false, "View database password for connecting from another machine").
|
||||
AddBoolFlag(constants2.ArgAll, false, "Bypasses the INSTALL_DIR and reports status of all running steampipe services")
|
||||
|
||||
return cmd
|
||||
}
|
||||
@@ -110,8 +111,8 @@ func serviceStopCmd() *cobra.Command {
|
||||
|
||||
cmdconfig.
|
||||
OnCmd(cmd).
|
||||
AddBoolFlag(constants.ArgHelp, false, "Help for service stop", cmdconfig.FlagOptions.WithShortHand("h")).
|
||||
AddBoolFlag(constants.ArgForce, false, "Forces all services to shutdown, releasing all open connections and ports")
|
||||
AddBoolFlag(constants2.ArgHelp, false, "Help for service stop", cmdconfig.FlagOptions.WithShortHand("h")).
|
||||
AddBoolFlag(constants2.ArgForce, false, "Forces all services to shutdown, releasing all open connections and ports")
|
||||
|
||||
return cmd
|
||||
}
|
||||
@@ -128,8 +129,8 @@ func serviceRestartCmd() *cobra.Command {
|
||||
|
||||
cmdconfig.
|
||||
OnCmd(cmd).
|
||||
AddBoolFlag(constants.ArgHelp, false, "Help for service restart", cmdconfig.FlagOptions.WithShortHand("h")).
|
||||
AddBoolFlag(constants.ArgForce, false, "Forces the service to restart, releasing all open connections and ports")
|
||||
AddBoolFlag(constants2.ArgHelp, false, "Help for service restart", cmdconfig.FlagOptions.WithShortHand("h")).
|
||||
AddBoolFlag(constants2.ArgForce, false, "Forces the service to restart, releasing all open connections and ports")
|
||||
|
||||
return cmd
|
||||
}
|
||||
@@ -153,15 +154,15 @@ func runServiceStartCmd(cmd *cobra.Command, _ []string) {
|
||||
ctx, cancel := signal.NotifyContext(ctx, os.Interrupt, os.Kill)
|
||||
defer cancel()
|
||||
|
||||
listenAddresses := db_local.StartListenType(viper.GetString(constants.ArgDatabaseListenAddresses)).ToListenAddresses()
|
||||
listenAddresses := db_local.StartListenType(viper.GetString(constants2.ArgDatabaseListenAddresses)).ToListenAddresses()
|
||||
|
||||
port := viper.GetInt(constants.ArgDatabasePort)
|
||||
port := viper.GetInt(constants2.ArgDatabasePort)
|
||||
if port < 1 || port > 65535 {
|
||||
exitCode = constants.ExitCodeInsufficientOrWrongInputs
|
||||
panic("Invalid port - must be within range (1:65535)")
|
||||
}
|
||||
|
||||
invoker := constants.Invoker(cmdconfig.Viper().GetString(constants.ArgInvoker))
|
||||
invoker := constants.Invoker(cmdconfig.Viper().GetString(constants2.ArgInvoker))
|
||||
if invoker.IsValid() != nil {
|
||||
exitCode = constants.ExitCodeInsufficientOrWrongInputs
|
||||
error_helpers.FailOnError(invoker.IsValid())
|
||||
@@ -172,7 +173,7 @@ func runServiceStartCmd(cmd *cobra.Command, _ []string) {
|
||||
|
||||
printStatus(ctx, startResult.DbState, startResult.PluginManagerState, alreadyRunning)
|
||||
|
||||
if viper.GetBool(constants.ArgForeground) {
|
||||
if viper.GetBool(constants2.ArgForeground) {
|
||||
runServiceInForeground(ctx)
|
||||
}
|
||||
}
|
||||
@@ -338,7 +339,7 @@ func restartService(ctx context.Context) (_ *db_local.StartResult) {
|
||||
}
|
||||
|
||||
// stop db
|
||||
stopStatus, err := db_local.StopServices(ctx, viper.GetBool(constants.ArgForce), constants.InvokerService)
|
||||
stopStatus, err := db_local.StopServices(ctx, viper.GetBool(constants2.ArgForce), constants.InvokerService)
|
||||
if err != nil {
|
||||
exitCode = constants.ExitCodeServiceStopFailure
|
||||
error_helpers.FailOnErrorWithMessage(err, "could not stop current instance")
|
||||
@@ -365,7 +366,7 @@ to force a restart.
|
||||
}
|
||||
|
||||
// set the password in 'viper' so that it can be used by 'service start'
|
||||
viper.Set(constants.ArgServicePassword, currentDbState.Password)
|
||||
viper.Set(constants2.ArgServicePassword, currentDbState.Password)
|
||||
|
||||
// start db
|
||||
dbStartResult := startServiceAndRefreshConnections(ctx, currentDbState.ResolvedListenAddresses, currentDbState.Port, currentDbState.Invoker)
|
||||
@@ -393,7 +394,7 @@ func runServiceStatusCmd(cmd *cobra.Command, _ []string) {
|
||||
return
|
||||
}
|
||||
|
||||
if viper.GetBool(constants.ArgAll) {
|
||||
if viper.GetBool(constants2.ArgAll) {
|
||||
showAllStatus(ctx)
|
||||
} else {
|
||||
dbState, dbStateErr := db_local.GetState()
|
||||
@@ -443,7 +444,7 @@ func runServiceStopCmd(cmd *cobra.Command, _ []string) {
|
||||
}
|
||||
}()
|
||||
|
||||
force := cmdconfig.Viper().GetBool(constants.ArgForce)
|
||||
force := cmdconfig.Viper().GetBool(constants2.ArgForce)
|
||||
if force {
|
||||
status, dbStopError = db_local.StopServices(ctx, force, constants.InvokerService)
|
||||
dbStopError = error_helpers.CombineErrors(dbStopError)
|
||||
@@ -588,7 +589,7 @@ Managing the Steampipe service:
|
||||
|
||||
var connectionStr string
|
||||
var password string
|
||||
if viper.GetBool(constants.ArgServiceShowPassword) {
|
||||
if viper.GetBool(constants2.ArgServiceShowPassword) {
|
||||
connectionStr = fmt.Sprintf(
|
||||
"postgres://%v:%v@%v:%v/%v",
|
||||
dbState.User,
|
||||
|
||||
@@ -2,11 +2,11 @@ package cloud
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/turbot/pipe-fittings/constants"
|
||||
"net/url"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
steampipecloud "github.com/turbot/steampipe-cloud-sdk-go"
|
||||
"github.com/turbot/steampipe/pkg/constants"
|
||||
)
|
||||
|
||||
func newSteampipeCloudClient(token string) *steampipecloud.APIClient {
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
constants2 "github.com/turbot/pipe-fittings/constants"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
@@ -23,7 +24,7 @@ var UnconfirmedError = "Not confirmed"
|
||||
// WebLogin POSTs to ${envBaseUrl}/api/latest/login/token to retrieve a login is
|
||||
// it then opens the login webpage and returns th eid
|
||||
func WebLogin(ctx context.Context) (string, error) {
|
||||
client := newSteampipeCloudClient(viper.GetString(constants.ArgPipesToken))
|
||||
client := newSteampipeCloudClient(viper.GetString(constants2.ArgPipesToken))
|
||||
|
||||
tempTokenReq, _, err := client.Auth.LoginTokenCreate(ctx).Execute()
|
||||
if err != nil {
|
||||
@@ -64,7 +65,7 @@ func GetLoginToken(ctx context.Context, id, code string) (string, error) {
|
||||
|
||||
// SaveToken writes the token to ~/.steampipe/internal/{cloud-host}.tptt
|
||||
func SaveToken(token string) error {
|
||||
tokenPath := tokenFilePath(viper.GetString(constants.ArgPipesHost))
|
||||
tokenPath := tokenFilePath(viper.GetString(constants2.ArgPipesHost))
|
||||
return sperr.Wrap(os.WriteFile(tokenPath, []byte(token), 0600))
|
||||
}
|
||||
|
||||
@@ -72,7 +73,7 @@ func LoadToken() (string, error) {
|
||||
if err := migrateDefaultTokenFile(); err != nil {
|
||||
log.Println("[TRACE] ERROR during migrating token file", err)
|
||||
}
|
||||
tokenPath := tokenFilePath(viper.GetString(constants.ArgPipesHost))
|
||||
tokenPath := tokenFilePath(viper.GetString(constants2.ArgPipesHost))
|
||||
if !filehelpers.FileExists(tokenPath) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
@@ -112,10 +112,10 @@ func (c *CmdBuilder) AddBoolFlag(name string, defaultValue bool, desc string, op
|
||||
// AddCloudFlags is helper function to add the cloud flags to a command
|
||||
func (c *CmdBuilder) AddCloudFlags() *CmdBuilder {
|
||||
return c.
|
||||
AddStringFlag(constants.ArgPipesHost, constants.DefaultPipesHost, "Turbot Pipes host").
|
||||
AddStringFlag(constants.ArgPipesToken, "", "Turbot Pipes authentication token").
|
||||
AddStringFlag(constants.ArgCloudHost, constants.DefaultPipesHost, "Turbot Pipes host", FlagOptions.Deprecated(constants.ArgPipesHost)).
|
||||
AddStringFlag(constants.ArgCloudToken, "", "Turbot Pipes authentication token", FlagOptions.Deprecated(constants.ArgPipesToken))
|
||||
AddStringFlag(pconstants.ArgPipesHost, constants.DefaultPipesHost, "Turbot Pipes host").
|
||||
AddStringFlag(pconstants.ArgPipesToken, "", "Turbot Pipes authentication token").
|
||||
AddStringFlag(pconstants.ArgCloudHost, constants.DefaultPipesHost, "Turbot Pipes host", FlagOptions.Deprecated(pconstants.ArgPipesHost)).
|
||||
AddStringFlag(pconstants.ArgCloudToken, "", "Turbot Pipes authentication token", FlagOptions.Deprecated(pconstants.ArgPipesToken))
|
||||
}
|
||||
|
||||
// AddWorkspaceDatabaseFlag is helper function to add the workspace-databse flag to a command
|
||||
@@ -129,7 +129,7 @@ func (c *CmdBuilder) AddModLocationFlag() *CmdBuilder {
|
||||
cwd, err := os.Getwd()
|
||||
error_helpers.FailOnError(err)
|
||||
return c.
|
||||
AddStringFlag(constants.ArgModLocation, cwd, "Path to the workspace working directory")
|
||||
AddStringFlag(pconstants.ArgModLocation, cwd, "Path to the workspace working directory")
|
||||
}
|
||||
|
||||
// AddStringSliceFlag is a helper function to add a flag that accepts an array of strings
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
constants2 "github.com/turbot/pipe-fittings/constants"
|
||||
"github.com/turbot/pipe-fittings/parse"
|
||||
"github.com/turbot/pipe-fittings/workspace_profile"
|
||||
"io"
|
||||
@@ -92,7 +93,7 @@ func preRunHook(cmd *cobra.Command, args []string) {
|
||||
|
||||
// if the log level was set in the general config
|
||||
if logLevelNeedsReset() {
|
||||
logLevel := viper.GetString(constants.ArgLogLevel)
|
||||
logLevel := viper.GetString(constants2.ArgLogLevel)
|
||||
// set my environment to the desired log level
|
||||
// so that this gets inherited by any other process
|
||||
// started by this process (postgres/plugin-manager)
|
||||
@@ -123,7 +124,7 @@ func preRunHook(cmd *cobra.Command, args []string) {
|
||||
}
|
||||
|
||||
func setMemoryLimit() {
|
||||
maxMemoryBytes := viper.GetInt64(constants.ArgMemoryMaxMb) * 1024 * 1024
|
||||
maxMemoryBytes := viper.GetInt64(constants2.ArgMemoryMaxMb) * 1024 * 1024
|
||||
if maxMemoryBytes > 0 {
|
||||
// set the max memory
|
||||
debug.SetMemoryLimit(maxMemoryBytes)
|
||||
@@ -156,7 +157,7 @@ func runScheduledTasks(ctx context.Context, cmd *cobra.Command, args []string, e
|
||||
// pass the config value in rather than runRasks querying viper directly - to avoid concurrent map access issues
|
||||
// (we can use the update-check viper config here, since initGlobalConfig has already set it up
|
||||
// with values from the config files and ENV settings - update-check cannot be set from the command line)
|
||||
task.WithUpdateCheck(viper.GetBool(constants.ArgUpdateCheck)),
|
||||
task.WithUpdateCheck(viper.GetBool(constants2.ArgUpdateCheck)),
|
||||
// show deprecation warnings
|
||||
task.WithPreHook(func(_ context.Context) {
|
||||
displayDeprecationWarnings(ew)
|
||||
@@ -219,7 +220,7 @@ func initGlobalConfig() perror_helpers.ErrorAndWarnings {
|
||||
ensureInstallDir()
|
||||
|
||||
// load the connection config and HCL options
|
||||
config, loadConfigErrorsAndWarnings := steampipeconfig.LoadSteampipeConfig(ctx, viper.GetString(constants.ArgModLocation), cmd.Name())
|
||||
config, loadConfigErrorsAndWarnings := steampipeconfig.LoadSteampipeConfig(ctx, viper.GetString(constants2.ArgModLocation), cmd.Name())
|
||||
if loadConfigErrorsAndWarnings.Error != nil {
|
||||
return loadConfigErrorsAndWarnings
|
||||
}
|
||||
@@ -270,19 +271,19 @@ func initGlobalConfig() perror_helpers.ErrorAndWarnings {
|
||||
func handleDeprecations() perror_helpers.ErrorAndWarnings {
|
||||
var ew = perror_helpers.ErrorAndWarnings{}
|
||||
// if deprecated cloud-token or cloud-host is set, show a warning and copy the value to the new arg
|
||||
if viper.IsSet(constants.ArgCloudToken) {
|
||||
if viper.IsSet(constants.ArgPipesToken) {
|
||||
ew.Error = sperr.New("Only one of flags --%s and --%s may be set", constants.ArgCloudToken, constants.ArgPipesToken)
|
||||
if viper.IsSet(constants2.ArgCloudToken) {
|
||||
if viper.IsSet(constants2.ArgPipesToken) {
|
||||
ew.Error = sperr.New("Only one of flags --%s and --%s may be set", constants2.ArgCloudToken, constants2.ArgPipesToken)
|
||||
return ew
|
||||
}
|
||||
viper.Set(constants.ArgPipesToken, viper.GetString(constants.ArgCloudToken))
|
||||
viper.Set(constants2.ArgPipesToken, viper.GetString(constants2.ArgCloudToken))
|
||||
}
|
||||
if viper.IsSet(constants.ArgCloudHost) {
|
||||
if viper.IsSet(constants.ArgPipesHost) {
|
||||
ew.Error = sperr.New("Only one of flags --%s and --%s may be set", constants.ArgCloudHost, constants.ArgPipesHost)
|
||||
if viper.IsSet(constants2.ArgCloudHost) {
|
||||
if viper.IsSet(constants2.ArgPipesHost) {
|
||||
ew.Error = sperr.New("Only one of flags --%s and --%s may be set", constants2.ArgCloudHost, constants2.ArgPipesHost)
|
||||
return ew
|
||||
}
|
||||
viper.Set(constants.ArgPipesHost, viper.GetString(constants.ArgCloudHost))
|
||||
viper.Set(constants2.ArgPipesHost, viper.GetString(constants2.ArgCloudHost))
|
||||
}
|
||||
|
||||
// is deprecated STEAMPIPE_CLOUD_TOKEN env var set?
|
||||
@@ -320,40 +321,40 @@ func setCloudTokenDefault(loader *parse.WorkspaceProfileLoader[*workspace_profil
|
||||
return err
|
||||
}
|
||||
if savedToken != "" {
|
||||
viper.SetDefault(constants.ArgPipesToken, savedToken)
|
||||
viper.SetDefault(constants2.ArgPipesToken, savedToken)
|
||||
}
|
||||
// 2) default profile pipes token
|
||||
if loader.DefaultProfile.PipesToken != nil {
|
||||
viper.SetDefault(constants.ArgPipesToken, *loader.DefaultProfile.PipesToken)
|
||||
viper.SetDefault(constants2.ArgPipesToken, *loader.DefaultProfile.PipesToken)
|
||||
}
|
||||
// deprecated - cloud token
|
||||
if loader.DefaultProfile.CloudToken != nil {
|
||||
viper.SetDefault(constants.ArgPipesToken, *loader.DefaultProfile.CloudToken)
|
||||
viper.SetDefault(constants2.ArgPipesToken, *loader.DefaultProfile.CloudToken)
|
||||
}
|
||||
// 3) env var (STEAMIPE_CLOUD_TOKEN )
|
||||
SetDefaultFromEnv(constants.EnvPipesToken, constants.ArgPipesToken, String)
|
||||
SetDefaultFromEnv(constants.EnvPipesToken, constants2.ArgPipesToken, String)
|
||||
// deprecated env var
|
||||
SetDefaultFromEnv(constants.EnvCloudToken, constants.ArgPipesToken, String)
|
||||
SetDefaultFromEnv(constants.EnvCloudToken, constants2.ArgPipesToken, String)
|
||||
|
||||
// 4) explicit workspace profile
|
||||
if p := loader.ConfiguredProfile; p != nil && p.PipesToken != nil {
|
||||
viper.SetDefault(constants.ArgPipesToken, *p.PipesToken)
|
||||
viper.SetDefault(constants2.ArgPipesToken, *p.PipesToken)
|
||||
}
|
||||
// deprecated - cloud token
|
||||
if p := loader.ConfiguredProfile; p != nil && p.CloudToken != nil {
|
||||
viper.SetDefault(constants.ArgPipesToken, *p.CloudToken)
|
||||
viper.SetDefault(constants2.ArgPipesToken, *p.CloudToken)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getWorkspaceProfileLoader(ctx context.Context) (*parse.WorkspaceProfileLoader[*workspace_profile.SteampipeWorkspaceProfile], error) {
|
||||
// set viper default for workspace profile, using EnvWorkspaceProfile env var
|
||||
SetDefaultFromEnv(constants.EnvWorkspaceProfile, constants.ArgWorkspaceProfile, String)
|
||||
SetDefaultFromEnv(constants.EnvWorkspaceProfile, constants2.ArgWorkspaceProfile, String)
|
||||
// set viper default for install dir, using EnvInstallDir env var
|
||||
SetDefaultFromEnv(constants.EnvInstallDir, constants.ArgInstallDir, String)
|
||||
SetDefaultFromEnv(constants.EnvInstallDir, constants2.ArgInstallDir, String)
|
||||
|
||||
// resolve the workspace profile dir
|
||||
installDir, err := filehelpers.Tildefy(viper.GetString(constants.ArgInstallDir))
|
||||
installDir, err := filehelpers.Tildefy(viper.GetString(constants2.ArgInstallDir))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -376,7 +377,7 @@ func getWorkspaceProfileLoader(ctx context.Context) (*parse.WorkspaceProfileLoad
|
||||
// (currently validates telemetry)
|
||||
func validateConfig() perror_helpers.ErrorAndWarnings {
|
||||
var res = perror_helpers.ErrorAndWarnings{}
|
||||
telemetry := viper.GetString(constants.ArgTelemetry)
|
||||
telemetry := viper.GetString(constants2.ArgTelemetry)
|
||||
if !helpers.StringSliceContains(constants.TelemetryLevels, telemetry) {
|
||||
res.Error = sperr.New(`invalid value of 'telemetry' (%s), must be one of: %s`, telemetry, strings.Join(constants.TelemetryLevels, ", "))
|
||||
return res
|
||||
@@ -441,8 +442,8 @@ func createLogger(logBuffer *bytes.Buffer, cmd *cobra.Command) {
|
||||
}
|
||||
|
||||
func ensureInstallDir() {
|
||||
pipesInstallDir := viper.GetString(constants.ArgPipesInstallDir)
|
||||
installDir := viper.GetString(constants.ArgInstallDir)
|
||||
pipesInstallDir := viper.GetString(constants2.ArgPipesInstallDir)
|
||||
installDir := viper.GetString(constants2.ArgInstallDir)
|
||||
|
||||
log.Printf("[TRACE] ensureInstallDir %s", installDir)
|
||||
if _, err := os.Stat(installDir); os.IsNotExist(err) {
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
filehelpers "github.com/turbot/go-kit/files"
|
||||
pconstants "github.com/turbot/pipe-fittings/constants"
|
||||
"github.com/turbot/steampipe/pkg/cloud"
|
||||
"github.com/turbot/steampipe/pkg/constants"
|
||||
"github.com/turbot/steampipe/pkg/error_helpers"
|
||||
"github.com/turbot/steampipe/pkg/steampipeconfig"
|
||||
"strings"
|
||||
@@ -15,8 +14,8 @@ import (
|
||||
|
||||
func ValidateSnapshotArgs(ctx context.Context) error {
|
||||
// only 1 of 'share' and 'snapshot' may be set
|
||||
share := viper.GetBool(constants.ArgShare)
|
||||
snapshot := viper.GetBool(constants.ArgSnapshot)
|
||||
share := viper.GetBool(pconstants.ArgShare)
|
||||
snapshot := viper.GetBool(pconstants.ArgSnapshot)
|
||||
if share && snapshot {
|
||||
return fmt.Errorf("only 1 of 'share' and 'snapshot' may be set")
|
||||
}
|
||||
@@ -26,7 +25,7 @@ func ValidateSnapshotArgs(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
token := viper.GetString(constants.ArgPipesToken)
|
||||
token := viper.GetString(pconstants.ArgPipesToken)
|
||||
|
||||
// determine whether snapshot location is a cloud workspace or a file location
|
||||
// if a file location, check it exists
|
||||
@@ -36,7 +35,7 @@ func ValidateSnapshotArgs(ctx context.Context) error {
|
||||
|
||||
// if workspace-database or snapshot-location are a cloud workspace handle, cloud token must be set
|
||||
requireCloudToken := steampipeconfig.IsCloudWorkspaceIdentifier(viper.GetString(pconstants.ArgWorkspaceDatabase)) ||
|
||||
steampipeconfig.IsCloudWorkspaceIdentifier(viper.GetString(constants.ArgSnapshotLocation))
|
||||
steampipeconfig.IsCloudWorkspaceIdentifier(viper.GetString(pconstants.ArgSnapshotLocation))
|
||||
|
||||
// verify cloud token and workspace has been set
|
||||
if requireCloudToken && token == "" {
|
||||
@@ -44,7 +43,7 @@ func ValidateSnapshotArgs(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// should never happen as there is a default set
|
||||
if viper.GetString(constants.ArgPipesHost) == "" {
|
||||
if viper.GetString(pconstants.ArgPipesHost) == "" {
|
||||
return fmt.Errorf("to share snapshots, cloud host must be set")
|
||||
}
|
||||
|
||||
@@ -52,7 +51,7 @@ func ValidateSnapshotArgs(ctx context.Context) error {
|
||||
}
|
||||
|
||||
func validateSnapshotLocation(ctx context.Context, cloudToken string) error {
|
||||
snapshotLocation := viper.GetString(constants.ArgSnapshotLocation)
|
||||
snapshotLocation := viper.GetString(pconstants.ArgSnapshotLocation)
|
||||
|
||||
// if snapshot location is not set, set to the users default
|
||||
if snapshotLocation == "" {
|
||||
@@ -72,7 +71,7 @@ func validateSnapshotLocation(ctx context.Context, cloudToken string) error {
|
||||
}
|
||||
|
||||
// write back to viper
|
||||
viper.Set(constants.ArgSnapshotLocation, snapshotLocation)
|
||||
viper.Set(pconstants.ArgSnapshotLocation, snapshotLocation)
|
||||
|
||||
if !filehelpers.DirectoryExists(snapshotLocation) {
|
||||
return fmt.Errorf("snapshot location %s does not exist", snapshotLocation)
|
||||
@@ -87,15 +86,15 @@ func setSnapshotLocationFromDefaultWorkspace(ctx context.Context, cloudToken str
|
||||
return err
|
||||
}
|
||||
|
||||
viper.Set(constants.ArgSnapshotLocation, workspaceHandle)
|
||||
viper.Set(pconstants.ArgSnapshotLocation, workspaceHandle)
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateSnapshotTags() error {
|
||||
tags := viper.GetStringSlice(constants.ArgSnapshotTag)
|
||||
tags := viper.GetStringSlice(pconstants.ArgSnapshotTag)
|
||||
for _, tagStr := range tags {
|
||||
if len(strings.Split(tagStr, "=")) != 2 {
|
||||
return fmt.Errorf("snapshot tags must be specified '--%s key=value'", constants.ArgSnapshotTag)
|
||||
return fmt.Errorf("snapshot tags must be specified '--%s key=value'", pconstants.ArgSnapshotTag)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -48,11 +48,11 @@ func bootstrapViper(loader *parse.WorkspaceProfileLoader[*workspace_profile.Stea
|
||||
if loader.ConfiguredProfile != nil {
|
||||
if loader.ConfiguredProfile.ModLocation != nil {
|
||||
log.Printf("[TRACE] setting mod location from configured profile '%s' to '%s'", loader.ConfiguredProfile.Name(), *loader.ConfiguredProfile.ModLocation)
|
||||
viper.SetDefault(constants.ArgModLocation, *loader.ConfiguredProfile.ModLocation)
|
||||
viper.SetDefault(pconstants.ArgModLocation, *loader.ConfiguredProfile.ModLocation)
|
||||
}
|
||||
if loader.ConfiguredProfile.InstallDir != nil {
|
||||
log.Printf("[TRACE] setting install dir from configured profile '%s' to '%s'", loader.ConfiguredProfile.Name(), *loader.ConfiguredProfile.InstallDir)
|
||||
viper.SetDefault(constants.ArgInstallDir, *loader.ConfiguredProfile.InstallDir)
|
||||
viper.SetDefault(pconstants.ArgInstallDir, *loader.ConfiguredProfile.InstallDir)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,8 +63,8 @@ func bootstrapViper(loader *parse.WorkspaceProfileLoader[*workspace_profile.Stea
|
||||
// tildefyPaths cleans all path config values and replaces '~' with the home directory
|
||||
func tildefyPaths() error {
|
||||
pathArgs := []string{
|
||||
constants.ArgModLocation,
|
||||
constants.ArgInstallDir,
|
||||
pconstants.ArgModLocation,
|
||||
pconstants.ArgInstallDir,
|
||||
}
|
||||
var err error
|
||||
for _, argName := range pathArgs {
|
||||
@@ -104,25 +104,25 @@ func setBaseDefaults() error {
|
||||
}
|
||||
defaults := map[string]interface{}{
|
||||
// global general options
|
||||
constants.ArgTelemetry: constants.TelemetryInfo,
|
||||
constants.ArgUpdateCheck: true,
|
||||
constants.ArgPipesInstallDir: pipesInstallDir,
|
||||
pconstants.ArgTelemetry: constants.TelemetryInfo,
|
||||
pconstants.ArgUpdateCheck: true,
|
||||
pconstants.ArgPipesInstallDir: pipesInstallDir,
|
||||
|
||||
// workspace profile
|
||||
constants.ArgAutoComplete: true,
|
||||
pconstants.ArgAutoComplete: true,
|
||||
|
||||
// from global database options
|
||||
constants.ArgDatabasePort: constants.DatabaseDefaultPort,
|
||||
constants.ArgDatabaseStartTimeout: constants.DBStartTimeout.Seconds(),
|
||||
constants.ArgServiceCacheEnabled: true,
|
||||
constants.ArgCacheMaxTtl: 300,
|
||||
pconstants.ArgDatabasePort: constants.DatabaseDefaultPort,
|
||||
pconstants.ArgDatabaseStartTimeout: constants.DBStartTimeout.Seconds(),
|
||||
pconstants.ArgServiceCacheEnabled: true,
|
||||
pconstants.ArgCacheMaxTtl: 300,
|
||||
|
||||
// dashboard
|
||||
constants.ArgDashboardStartTimeout: constants.DashboardStartTimeout.Seconds(),
|
||||
pconstants.ArgDashboardStartTimeout: constants.DashboardStartTimeout.Seconds(),
|
||||
|
||||
// memory
|
||||
constants.ArgMemoryMaxMbPlugin: 1024,
|
||||
constants.ArgMemoryMaxMb: 1024,
|
||||
pconstants.ArgMemoryMaxMbPlugin: 1024,
|
||||
pconstants.ArgMemoryMaxMb: 1024,
|
||||
}
|
||||
|
||||
for k, v := range defaults {
|
||||
@@ -139,9 +139,9 @@ type envMapping struct {
|
||||
// set default values of INSTALL_DIR and ModLocation from env vars
|
||||
func setDirectoryDefaultsFromEnv() {
|
||||
envMappings := map[string]envMapping{
|
||||
constants.EnvInstallDir: {[]string{constants.ArgInstallDir}, String},
|
||||
constants.EnvWorkspaceChDir: {[]string{constants.ArgModLocation}, String},
|
||||
constants.EnvModLocation: {[]string{constants.ArgModLocation}, String},
|
||||
constants.EnvInstallDir: {[]string{pconstants.ArgInstallDir}, String},
|
||||
constants.EnvWorkspaceChDir: {[]string{pconstants.ArgModLocation}, String},
|
||||
constants.EnvModLocation: {[]string{pconstants.ArgModLocation}, String},
|
||||
}
|
||||
|
||||
for envVar, mapping := range envMappings {
|
||||
@@ -156,37 +156,37 @@ func setDefaultsFromEnv() {
|
||||
|
||||
// a map of known environment variables to map to viper keys
|
||||
envMappings := map[string]envMapping{
|
||||
constants.EnvInstallDir: {[]string{constants.ArgInstallDir}, String},
|
||||
constants.EnvWorkspaceChDir: {[]string{constants.ArgModLocation}, String},
|
||||
constants.EnvModLocation: {[]string{constants.ArgModLocation}, String},
|
||||
constants.EnvInstallDir: {[]string{pconstants.ArgInstallDir}, String},
|
||||
constants.EnvWorkspaceChDir: {[]string{pconstants.ArgModLocation}, String},
|
||||
constants.EnvModLocation: {[]string{pconstants.ArgModLocation}, String},
|
||||
// TODO #breakingchange
|
||||
//constants.EnvIntrospection: {[]string{constants.ArgIntrospection}, String},
|
||||
constants.EnvTelemetry: {[]string{constants.ArgTelemetry}, String},
|
||||
constants.EnvUpdateCheck: {[]string{constants.ArgUpdateCheck}, Bool},
|
||||
constants.EnvTelemetry: {[]string{pconstants.ArgTelemetry}, String},
|
||||
constants.EnvUpdateCheck: {[]string{pconstants.ArgUpdateCheck}, Bool},
|
||||
// deprecated
|
||||
constants.EnvCloudHost: {[]string{constants.ArgPipesHost}, String},
|
||||
constants.EnvCloudToken: {[]string{constants.ArgPipesToken}, String},
|
||||
constants.EnvPipesHost: {[]string{constants.ArgPipesHost}, String},
|
||||
constants.EnvPipesToken: {[]string{constants.ArgPipesToken}, String},
|
||||
constants.EnvSnapshotLocation: {[]string{constants.ArgSnapshotLocation}, String},
|
||||
constants.EnvCloudHost: {[]string{pconstants.ArgPipesHost}, String},
|
||||
constants.EnvCloudToken: {[]string{pconstants.ArgPipesToken}, String},
|
||||
constants.EnvPipesHost: {[]string{pconstants.ArgPipesHost}, String},
|
||||
constants.EnvPipesToken: {[]string{pconstants.ArgPipesToken}, String},
|
||||
constants.EnvSnapshotLocation: {[]string{pconstants.ArgSnapshotLocation}, String},
|
||||
constants.EnvWorkspaceDatabase: {[]string{pconstants.ArgWorkspaceDatabase}, String},
|
||||
constants.EnvServicePassword: {[]string{constants.ArgServicePassword}, String},
|
||||
constants.EnvDisplayWidth: {[]string{constants.ArgDisplayWidth}, Int},
|
||||
constants.EnvMaxParallel: {[]string{constants.ArgMaxParallel}, Int},
|
||||
constants.EnvQueryTimeout: {[]string{constants.ArgDatabaseQueryTimeout}, Int},
|
||||
constants.EnvDatabaseStartTimeout: {[]string{constants.ArgDatabaseStartTimeout}, Int},
|
||||
constants.EnvDatabaseSSLPassword: {[]string{constants.ArgDatabaseSSLPassword}, String},
|
||||
constants.EnvDashboardStartTimeout: {[]string{constants.ArgDashboardStartTimeout}, Int},
|
||||
constants.EnvCacheTTL: {[]string{constants.ArgCacheTtl}, Int},
|
||||
constants.EnvCacheMaxTTL: {[]string{constants.ArgCacheMaxTtl}, Int},
|
||||
constants.EnvMemoryMaxMb: {[]string{constants.ArgMemoryMaxMb}, Int},
|
||||
constants.EnvMemoryMaxMbPlugin: {[]string{constants.ArgMemoryMaxMbPlugin}, Int},
|
||||
constants.EnvServicePassword: {[]string{pconstants.ArgServicePassword}, String},
|
||||
constants.EnvDisplayWidth: {[]string{pconstants.ArgDisplayWidth}, Int},
|
||||
constants.EnvMaxParallel: {[]string{pconstants.ArgMaxParallel}, Int},
|
||||
constants.EnvQueryTimeout: {[]string{pconstants.ArgDatabaseQueryTimeout}, Int},
|
||||
constants.EnvDatabaseStartTimeout: {[]string{pconstants.ArgDatabaseStartTimeout}, Int},
|
||||
constants.EnvDatabaseSSLPassword: {[]string{pconstants.ArgDatabaseSSLPassword}, String},
|
||||
constants.EnvDashboardStartTimeout: {[]string{pconstants.ArgDashboardStartTimeout}, Int},
|
||||
constants.EnvCacheTTL: {[]string{pconstants.ArgCacheTtl}, Int},
|
||||
constants.EnvCacheMaxTTL: {[]string{pconstants.ArgCacheMaxTtl}, Int},
|
||||
constants.EnvMemoryMaxMb: {[]string{pconstants.ArgMemoryMaxMb}, Int},
|
||||
constants.EnvMemoryMaxMbPlugin: {[]string{pconstants.ArgMemoryMaxMbPlugin}, Int},
|
||||
constants.EnvPluginStartTimeout: {[]string{constants.ArgPluginStartTimeout}, Int},
|
||||
|
||||
// we need this value to go into different locations
|
||||
constants.EnvCacheEnabled: {[]string{
|
||||
constants.ArgClientCacheEnabled,
|
||||
constants.ArgServiceCacheEnabled,
|
||||
pconstants.ArgClientCacheEnabled,
|
||||
pconstants.ArgServiceCacheEnabled,
|
||||
}, Bool},
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package connection
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
constants2 "github.com/turbot/pipe-fittings/constants"
|
||||
error_helpers2 "github.com/turbot/pipe-fittings/error_helpers"
|
||||
"log"
|
||||
"os"
|
||||
@@ -649,7 +650,7 @@ func (s *refreshConnectionState) executeUpdateQuery(ctx context.Context, sql, co
|
||||
// set connection comments
|
||||
|
||||
func (s *refreshConnectionState) UpdateCommentsInParallel(ctx context.Context, updates []*steampipeconfig.ConnectionState, plugins map[string]*steampipeconfig.ConnectionPlugin) (errors []error) {
|
||||
if !viper.GetBool(constants.ArgSchemaComments) {
|
||||
if !viper.GetBool(constants2.ArgSchemaComments) {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -1,73 +1,6 @@
|
||||
package constants
|
||||
|
||||
// Argument name constants
|
||||
const (
|
||||
ArgHelp = "help"
|
||||
ArgVersion = "version"
|
||||
ArgForce = "force"
|
||||
ArgAll = "all"
|
||||
ArgTiming = "timing"
|
||||
ArgOn = "on"
|
||||
ArgOff = "off"
|
||||
ArgVerbose = "verbose"
|
||||
ArgClear = "clear"
|
||||
ArgDatabaseListenAddresses = "database-listen"
|
||||
ArgDatabasePort = "database-port"
|
||||
ArgDatabaseQueryTimeout = "query-timeout"
|
||||
ArgServicePassword = "database-password"
|
||||
ArgServiceShowPassword = "show-password"
|
||||
ArgDashboard = "dashboard"
|
||||
ArgDashboardListen = "dashboard-listen"
|
||||
ArgDashboardPort = "dashboard-port"
|
||||
ArgDashboardStartTimeout = "dashboard-start-timeout"
|
||||
ArgSkipConfig = "skip-config"
|
||||
ArgForeground = "foreground"
|
||||
ArgInvoker = "invoker"
|
||||
ArgUpdateCheck = "update-check"
|
||||
ArgTelemetry = "telemetry"
|
||||
ArgInstallDir = "install-dir"
|
||||
ArgPipesInstallDir = "pipes-install-dir"
|
||||
ArgSchemaComments = "schema-comments"
|
||||
ArgCloudHost = "cloud-host"
|
||||
ArgCloudToken = "cloud-token"
|
||||
ArgPipesHost = "pipes-host"
|
||||
ArgPipesToken = "pipes-token"
|
||||
ArgSearchPath = "search-path"
|
||||
ArgSearchPathPrefix = "search-path-prefix"
|
||||
//ArgWatch = "watch"
|
||||
ArgProgress = "progress"
|
||||
ArgExport = "export"
|
||||
ArgMaxParallel = "max-parallel"
|
||||
ArgLogLevel = "log-level"
|
||||
ArgDryRun = "dry-run"
|
||||
ArgWhere = "where"
|
||||
ArgTag = "tag"
|
||||
ArgVariable = "var"
|
||||
ArgVarFile = "var-file"
|
||||
ArgDisplayWidth = "display-width"
|
||||
ArgPrune = "prune"
|
||||
ArgServiceMode = "service-mode"
|
||||
ArgBrowser = "browser"
|
||||
ArgInput = "input"
|
||||
ArgDashboardInput = "dashboard-input"
|
||||
ArgMaxCacheSizeMb = "max-cache-size-mb"
|
||||
ArgCacheTtl = "cache-ttl"
|
||||
ArgClientCacheEnabled = "client-cache-enabled"
|
||||
ArgServiceCacheEnabled = "service-cache-enabled"
|
||||
ArgCacheMaxTtl = "cache-max-ttl"
|
||||
ArgShare = "share"
|
||||
ArgSnapshot = "snapshot"
|
||||
ArgSnapshotTag = "snapshot-tag"
|
||||
ArgWorkspaceProfile = "workspace"
|
||||
ArgModLocation = "mod-location"
|
||||
ArgSnapshotLocation = "snapshot-location"
|
||||
ArgSnapshotTitle = "snapshot-title"
|
||||
ArgDatabaseStartTimeout = "database-start-timeout"
|
||||
ArgDatabaseSSLPassword = "database-ssl-password"
|
||||
ArgMemoryMaxMb = "memory-max-mb"
|
||||
ArgMemoryMaxMbPlugin = "memory-max-mb-plugin"
|
||||
)
|
||||
|
||||
//
|
||||
// metaquery mode arguments
|
||||
|
||||
var ArgOutput = ArgFromMetaquery(CmdOutput)
|
||||
@@ -75,20 +8,3 @@ var ArgSeparator = ArgFromMetaquery(CmdSeparator)
|
||||
var ArgHeader = ArgFromMetaquery(CmdHeaders)
|
||||
var ArgMultiLine = ArgFromMetaquery(CmdMulti)
|
||||
var ArgAutoComplete = ArgFromMetaquery(CmdAutoComplete)
|
||||
|
||||
// BoolToOnOff converts a boolean value onto the string "on" or "off"
|
||||
func BoolToOnOff(val bool) string {
|
||||
if val {
|
||||
return ArgOn
|
||||
}
|
||||
return ArgOff
|
||||
}
|
||||
|
||||
// BoolToEnableDisable converts a boolean value onto the string "enable" or "disable"
|
||||
func BoolToEnableDisable(val bool) string {
|
||||
if val {
|
||||
return "enable"
|
||||
}
|
||||
return "disable"
|
||||
|
||||
}
|
||||
|
||||
3
pkg/constants/oci.go
Normal file
3
pkg/constants/oci.go
Normal file
@@ -0,0 +1,3 @@
|
||||
package constants
|
||||
|
||||
const SteampipeHubOCIBase = "hub.steampipe.io/"
|
||||
@@ -1,12 +0,0 @@
|
||||
package constants
|
||||
|
||||
const (
|
||||
InstallMessagePluginAlreadyInstalled = "Already installed"
|
||||
InstallMessagePluginLatestAlreadyInstalled = "Latest already installed"
|
||||
InstallMessagePluginNotInstalled = "Not installed"
|
||||
InstallMessagePluginNotFound = "Not found"
|
||||
ConnectionErrorPluginFailedToStart = "plugin failed to start"
|
||||
ConnectionErrorPluginNotInstalled = "plugin not installed"
|
||||
|
||||
SteampipeHubOCIBase = "hub.steampipe.io/"
|
||||
)
|
||||
@@ -3,6 +3,7 @@ package db_client
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
constants2 "github.com/turbot/pipe-fittings/constants"
|
||||
"log"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -137,13 +138,13 @@ func (c *DbClient) shouldFetchTiming() bool {
|
||||
return false
|
||||
}
|
||||
// only fetch timing if timing flag is set, or output is JSON
|
||||
return (viper.GetString(constants.ArgTiming) != constants.ArgOff) ||
|
||||
(viper.GetString(constants.ArgOutput) == constants.OutputFormatJSON)
|
||||
return (viper.GetString(constants2.ArgTiming) != constants2.ArgOff) ||
|
||||
(viper.GetString(constants2.ArgOutput) == constants.OutputFormatJSON)
|
||||
|
||||
}
|
||||
func (c *DbClient) shouldFetchVerboseTiming() bool {
|
||||
return (viper.GetString(constants.ArgTiming) == constants.ArgVerbose) ||
|
||||
(viper.GetString(constants.ArgOutput) == constants.OutputFormatJSON)
|
||||
return (viper.GetString(constants2.ArgTiming) == constants2.ArgVerbose) ||
|
||||
(viper.GetString(constants2.ArgOutput) == constants.OutputFormatJSON)
|
||||
}
|
||||
|
||||
// ServerSettings returns the settings of the steampipe service that this DbClient is connected to
|
||||
|
||||
@@ -2,6 +2,7 @@ package db_client
|
||||
|
||||
import (
|
||||
"context"
|
||||
constants2 "github.com/turbot/pipe-fittings/constants"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
@@ -80,7 +81,7 @@ func (c *DbClient) establishConnectionPool(ctx context.Context, overrides client
|
||||
ctx,
|
||||
dbPool,
|
||||
db_common.WithRetryInterval(constants.DBConnectionRetryBackoff),
|
||||
db_common.WithTimeout(time.Duration(viper.GetInt(constants.ArgDatabaseStartTimeout))*time.Second),
|
||||
db_common.WithTimeout(time.Duration(viper.GetInt(constants2.ArgDatabaseStartTimeout))*time.Second),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
constants2 "github.com/turbot/pipe-fittings/constants"
|
||||
"log"
|
||||
"net/netip"
|
||||
"strings"
|
||||
@@ -162,7 +163,7 @@ func (c *DbClient) ExecuteInSession(ctx context.Context, session *db_common.Data
|
||||
}
|
||||
|
||||
func (c *DbClient) getExecuteContext(ctx context.Context) context.Context {
|
||||
queryTimeout := time.Duration(viper.GetInt(constants.ArgDatabaseQueryTimeout)) * time.Second
|
||||
queryTimeout := time.Duration(viper.GetInt(constants2.ArgDatabaseQueryTimeout)) * time.Second
|
||||
// if timeout is zero, do not set a timeout
|
||||
if queryTimeout == 0 {
|
||||
return ctx
|
||||
@@ -398,7 +399,7 @@ func populateRow(columnValues []interface{}, cols []*queryresult.ColumnDef) ([]i
|
||||
}
|
||||
|
||||
func isStreamingOutput() bool {
|
||||
outputFormat := viper.GetString(constants.ArgOutput)
|
||||
outputFormat := viper.GetString(constants2.ArgOutput)
|
||||
|
||||
return helpers.StringSliceContains([]string{constants.OutputFormatCSV, constants.OutputFormatLine}, outputFormat)
|
||||
}
|
||||
|
||||
@@ -3,13 +3,13 @@ package db_client
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/turbot/pipe-fittings/constants"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/turbot/go-kit/helpers"
|
||||
"github.com/turbot/steampipe/pkg/constants"
|
||||
"github.com/turbot/steampipe/pkg/db/db_common"
|
||||
)
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@ package db_client
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/turbot/pipe-fittings/constants"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/turbot/steampipe/pkg/constants"
|
||||
"github.com/turbot/steampipe/pkg/db/db_common"
|
||||
)
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@ package db_common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/turbot/pipe-fittings/constants"
|
||||
"github.com/turbot/pipe-fittings/error_helpers"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"github.com/turbot/steampipe/pkg/constants"
|
||||
)
|
||||
|
||||
func ValidateClientCacheSettings(c Client) error_helpers.ErrorAndWarnings {
|
||||
|
||||
@@ -3,6 +3,7 @@ package db_common
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
constants2 "github.com/turbot/pipe-fittings/constants"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"github.com/turbot/steampipe/pkg/constants"
|
||||
@@ -43,7 +44,7 @@ func (r *InitResult) DisplayMessages() {
|
||||
}
|
||||
}
|
||||
// do not display message in json or csv output mode
|
||||
output := viper.Get(constants.ArgOutput)
|
||||
output := viper.Get(constants2.ArgOutput)
|
||||
if output == constants.OutputFormatJSON || output == constants.OutputFormatCSV {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -2,13 +2,14 @@ package db_common
|
||||
|
||||
import (
|
||||
"github.com/spf13/viper"
|
||||
constants2 "github.com/turbot/pipe-fittings/constants"
|
||||
"github.com/turbot/steampipe/pkg/constants"
|
||||
)
|
||||
|
||||
func MaxDbConnections() int {
|
||||
maxParallel := constants.DefaultMaxConnections
|
||||
if viper.IsSet(constants.ArgMaxParallel) {
|
||||
maxParallel = viper.GetInt(constants.ArgMaxParallel)
|
||||
if viper.IsSet(constants2.ArgMaxParallel) {
|
||||
maxParallel = viper.GetInt(constants2.ArgMaxParallel)
|
||||
}
|
||||
return maxParallel
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package db_local
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
constants2 "github.com/turbot/pipe-fittings/constants"
|
||||
"log"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -155,7 +156,7 @@ func CreateConnectionPool(ctx context.Context, opts *CreateDbOptions, maxConnect
|
||||
ctx,
|
||||
dbPool,
|
||||
db_common.WithRetryInterval(constants.DBConnectionRetryBackoff),
|
||||
db_common.WithTimeout(time.Duration(viper.GetInt(constants.ArgDatabaseStartTimeout))*time.Second),
|
||||
db_common.WithTimeout(time.Duration(viper.GetInt(constants2.ArgDatabaseStartTimeout))*time.Second),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -177,7 +178,7 @@ func createMaintenanceClient(ctx context.Context, port int) (*pgx.Conn, error) {
|
||||
|
||||
connStr := fmt.Sprintf("host=127.0.0.1 port=%d user=%s dbname=postgres sslmode=disable application_name=%s", port, constants.DatabaseSuperUser, runtime.ServiceConnectionAppName)
|
||||
|
||||
timeoutCtx, cancel := context.WithTimeout(ctx, time.Duration(viper.GetInt(constants.ArgDatabaseStartTimeout))*time.Second)
|
||||
timeoutCtx, cancel := context.WithTimeout(ctx, time.Duration(viper.GetInt(constants2.ArgDatabaseStartTimeout))*time.Second)
|
||||
defer cancel()
|
||||
|
||||
statushooks.SetStatus(ctx, "Waiting for connection")
|
||||
@@ -185,7 +186,7 @@ func createMaintenanceClient(ctx context.Context, port int) (*pgx.Conn, error) {
|
||||
timeoutCtx,
|
||||
connStr,
|
||||
db_common.WithRetryInterval(constants.DBConnectionRetryBackoff),
|
||||
db_common.WithTimeout(time.Duration(viper.GetInt(constants.ArgDatabaseStartTimeout))*time.Second),
|
||||
db_common.WithTimeout(time.Duration(viper.GetInt(constants2.ArgDatabaseStartTimeout))*time.Second),
|
||||
)
|
||||
if err != nil {
|
||||
log.Println("[TRACE] could not connect to service")
|
||||
@@ -197,7 +198,7 @@ func createMaintenanceClient(ctx context.Context, port int) (*pgx.Conn, error) {
|
||||
timeoutCtx,
|
||||
conn,
|
||||
db_common.WithRetryInterval(constants.DBConnectionRetryBackoff),
|
||||
db_common.WithTimeout(viper.GetDuration(constants.ArgDatabaseStartTimeout)*time.Second),
|
||||
db_common.WithTimeout(viper.GetDuration(constants2.ArgDatabaseStartTimeout)*time.Second),
|
||||
)
|
||||
if err != nil {
|
||||
conn.Close(ctx)
|
||||
|
||||
@@ -3,6 +3,7 @@ package db_local
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
constants2 "github.com/turbot/pipe-fittings/constants"
|
||||
"github.com/turbot/pipe-fittings/error_helpers"
|
||||
"log"
|
||||
|
||||
@@ -31,7 +32,7 @@ func GetLocalClient(ctx context.Context, invoker constants.Invoker, opts ...db_c
|
||||
defer log.Printf("[INFO] GetLocalClient complete")
|
||||
|
||||
listenAddresses := StartListenType(ListenTypeLocal).ToListenAddresses()
|
||||
port := viper.GetInt(constants.ArgDatabasePort)
|
||||
port := viper.GetInt(constants2.ArgDatabasePort)
|
||||
log.Println(fmt.Sprintf("[TRACE] GetLocalClient - listenAddresses=%s, port=%d", listenAddresses, port))
|
||||
// start db if necessary
|
||||
if err := EnsureDBInstalled(ctx); err != nil {
|
||||
|
||||
@@ -2,6 +2,7 @@ package db_local
|
||||
|
||||
import (
|
||||
"context"
|
||||
constants2 "github.com/turbot/pipe-fittings/constants"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
@@ -22,9 +23,9 @@ func setupServerSettingsTable(ctx context.Context, conn *pgx.Conn) error {
|
||||
StartTime: time.Now(),
|
||||
SteampipeVersion: version.VersionString,
|
||||
FdwVersion: constants.FdwVersion,
|
||||
CacheMaxTtl: viper.GetInt(constants.ArgCacheMaxTtl),
|
||||
CacheMaxSizeMb: viper.GetInt(constants.ArgMaxCacheSizeMb),
|
||||
CacheEnabled: viper.GetBool(constants.ArgServiceCacheEnabled),
|
||||
CacheMaxTtl: viper.GetInt(constants2.ArgCacheMaxTtl),
|
||||
CacheMaxSizeMb: viper.GetInt(constants2.ArgMaxCacheSizeMb),
|
||||
CacheEnabled: viper.GetBool(constants2.ArgServiceCacheEnabled),
|
||||
}
|
||||
|
||||
queries := []db_common.QueryWithArgs{
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"crypto/x509/pkix"
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"github.com/turbot/pipe-fittings/constants"
|
||||
"log"
|
||||
"math/big"
|
||||
"os"
|
||||
@@ -18,7 +19,6 @@ import (
|
||||
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"
|
||||
)
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"bufio"
|
||||
"context"
|
||||
"fmt"
|
||||
constants2 "github.com/turbot/pipe-fittings/constants"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
@@ -367,8 +368,8 @@ func resolvePassword() (string, error) {
|
||||
// if a password was set through the `STEAMPIPE_DATABASE_PASSWORD` environment variable
|
||||
// or through the `--database-password` cmdline flag, then use that for this session
|
||||
// instead of the default one
|
||||
if viper.IsSet(constants.ArgServicePassword) {
|
||||
password = viper.GetString(constants.ArgServicePassword)
|
||||
if viper.IsSet(constants2.ArgServicePassword) {
|
||||
password = viper.GetString(constants2.ArgServicePassword)
|
||||
}
|
||||
return password, nil
|
||||
}
|
||||
@@ -461,7 +462,7 @@ func createCmd(ctx context.Context, port int, listenAddresses []string) *exec.Cm
|
||||
// Data Directory
|
||||
"-D", filepaths.GetDataLocation())
|
||||
|
||||
if sslpassword := viper.GetString(constants.ArgDatabaseSSLPassword); sslpassword != "" {
|
||||
if sslpassword := viper.GetString(constants2.ArgDatabaseSSLPassword); sslpassword != "" {
|
||||
postgresCmd.Args = append(
|
||||
postgresCmd.Args,
|
||||
"-c", fmt.Sprintf("ssl_passphrase_command_supports_reload=%s", "true"),
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"encoding/csv"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
constants2 "github.com/turbot/pipe-fittings/constants"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
@@ -40,7 +41,7 @@ func ShowOutput(ctx context.Context, result *queryresult.Result, opts ...Display
|
||||
|
||||
var timingResult *queryresult.TimingResult
|
||||
|
||||
outputFormat := cmdconfig.Viper().GetString(constants.ArgOutput)
|
||||
outputFormat := cmdconfig.Viper().GetString(constants2.ArgOutput)
|
||||
switch outputFormat {
|
||||
case constants.OutputFormatJSON:
|
||||
rowErrors, timingResult = displayJSON(ctx, result)
|
||||
@@ -53,7 +54,7 @@ func ShowOutput(ctx context.Context, result *queryresult.Result, opts ...Display
|
||||
}
|
||||
|
||||
// show timing
|
||||
if config.timing != constants.ArgOff && timingResult != nil {
|
||||
if config.timing != constants2.ArgOff && timingResult != nil {
|
||||
str := buildTimingString(timingResult)
|
||||
if viper.GetBool(constants.ConfigKeyInteractive) {
|
||||
fmt.Println(str)
|
||||
@@ -105,8 +106,8 @@ func ShowWrappedTable(headers []string, rows [][]string, opts *ShowWrappedTableO
|
||||
func GetMaxCols() int {
|
||||
colsAvailable, _, _ := gows.GetWinSize()
|
||||
// check if STEAMPIPE_DISPLAY_WIDTH env variable is set
|
||||
if viper.IsSet(constants.ArgDisplayWidth) {
|
||||
colsAvailable = viper.GetInt(constants.ArgDisplayWidth)
|
||||
if viper.IsSet(constants2.ArgDisplayWidth) {
|
||||
colsAvailable = viper.GetInt(constants2.ArgDisplayWidth)
|
||||
}
|
||||
return colsAvailable
|
||||
}
|
||||
@@ -119,7 +120,7 @@ func getColumnSettings(headers []string, rows [][]string, opts *ShowWrappedTable
|
||||
sumOfAllCols := 0
|
||||
|
||||
// account for the spaces around the value of a column and separators
|
||||
spaceAccounting := ((len(headers) * 3) + 1)
|
||||
spaceAccounting := (len(headers) * 3) + 1
|
||||
|
||||
for idx, colName := range headers {
|
||||
headerRow[idx] = colName
|
||||
@@ -160,8 +161,8 @@ func getColumnSettings(headers []string, rows [][]string, opts *ShowWrappedTable
|
||||
// get the max cols width
|
||||
maxCols := GetMaxCols()
|
||||
if sumOfAllCols > maxCols {
|
||||
colConfigs[len(colConfigs)-1].WidthMax = (maxCols - sumOfRest - spaceAccounting)
|
||||
colConfigs[len(colConfigs)-1].WidthMin = (maxCols - sumOfRest - spaceAccounting)
|
||||
colConfigs[len(colConfigs)-1].WidthMax = maxCols - sumOfRest - spaceAccounting
|
||||
colConfigs[len(colConfigs)-1].WidthMin = maxCols - sumOfRest - spaceAccounting
|
||||
if opts.Truncate {
|
||||
colConfigs[len(colConfigs)-1].WidthMaxEnforcer = helpers.TruncateString
|
||||
}
|
||||
@@ -251,7 +252,7 @@ func displayJSON(ctx context.Context, result *queryresult.Result) (int, *queryre
|
||||
func displayCSV(ctx context.Context, result *queryresult.Result) (int, *queryresult.TimingResult) {
|
||||
rowErrors := 0
|
||||
csvWriter := csv.NewWriter(os.Stdout)
|
||||
csvWriter.Comma = []rune(cmdconfig.Viper().GetString(constants.ArgSeparator))[0]
|
||||
csvWriter.Comma = []rune(cmdconfig.Viper().GetString(constants2.ArgSeparator))[0]
|
||||
|
||||
if cmdconfig.Viper().GetBool(constants.ArgHeader) {
|
||||
_ = csvWriter.Write(columnNames(result.Cols))
|
||||
@@ -379,7 +380,7 @@ func displayTable(ctx context.Context, result *queryresult.Result) (int, *queryr
|
||||
}
|
||||
|
||||
t.SetColumnConfigs(colConfigs)
|
||||
if viper.GetBool(constants.ArgHeader) {
|
||||
if viper.GetBool(constants2.ArgHeader) {
|
||||
t.AppendHeader(headers)
|
||||
}
|
||||
|
||||
@@ -424,9 +425,9 @@ func displayTable(ctx context.Context, result *queryresult.Result) (int, *queryr
|
||||
}
|
||||
|
||||
func getTiming(result *queryresult.Result, count int) *queryresult.TimingResult {
|
||||
timingConfig := viper.GetString(constants.ArgTiming)
|
||||
timingConfig := viper.GetString(constants2.ArgTiming)
|
||||
|
||||
if timingConfig == constants.ArgOff || timingConfig == "false" {
|
||||
if timingConfig == constants2.ArgOff || timingConfig == "false" {
|
||||
return nil
|
||||
}
|
||||
// now we have iterated the rows, get the timing
|
||||
@@ -434,7 +435,7 @@ func getTiming(result *queryresult.Result, count int) *queryresult.TimingResult
|
||||
// set rows returned
|
||||
timingResult.RowsReturned = int64(count)
|
||||
|
||||
if timingConfig != constants.ArgVerbose {
|
||||
if timingConfig != constants2.ArgVerbose {
|
||||
timingResult.Scans = nil
|
||||
}
|
||||
return timingResult
|
||||
@@ -478,7 +479,7 @@ func buildTimingString(timingResult *queryresult.TimingResult) string {
|
||||
sb.WriteString(p.Sprintf(" Connections: %d.", timingResult.ConnectionCount))
|
||||
}
|
||||
|
||||
if viper.GetString(constants.ArgTiming) == constants.ArgVerbose && len(timingResult.Scans) > 0 {
|
||||
if viper.GetString(constants2.ArgTiming) == constants2.ArgVerbose && len(timingResult.Scans) > 0 {
|
||||
if err := getVerboseTimingString(&sb, p, timingResult); err != nil {
|
||||
log.Printf("[WARN] Error getting verbose timing: %v", err)
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package display
|
||||
|
||||
import (
|
||||
"github.com/turbot/pipe-fittings/constants"
|
||||
"github.com/turbot/steampipe/pkg/cmdconfig"
|
||||
"github.com/turbot/steampipe/pkg/constants"
|
||||
)
|
||||
|
||||
type displayConfiguration struct {
|
||||
|
||||
@@ -2,6 +2,7 @@ package display
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
constants2 "github.com/turbot/pipe-fittings/constants"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
@@ -81,11 +82,11 @@ func PrintInstallReports(reports PluginInstallReports, isUpdateReport bool) {
|
||||
report.IsUpdateReport = isUpdateReport
|
||||
if !report.Skipped {
|
||||
installedOrUpdated = append(installedOrUpdated, report)
|
||||
} else if report.SkipReason == constants.InstallMessagePluginNotInstalled {
|
||||
} else if report.SkipReason == constants2.InstallMessagePluginNotInstalled {
|
||||
canBeInstalled = append(canBeInstalled, report)
|
||||
} else if report.SkipReason == constants.InstallMessagePluginAlreadyInstalled {
|
||||
} else if report.SkipReason == constants2.InstallMessagePluginAlreadyInstalled {
|
||||
canBeUpdated = append(canBeUpdated, report)
|
||||
} else if report.SkipReason == constants.InstallMessagePluginNotFound {
|
||||
} else if report.SkipReason == constants2.InstallMessagePluginNotFound {
|
||||
notFound = append(notFound, report)
|
||||
}
|
||||
}
|
||||
@@ -111,7 +112,7 @@ func PrintInstallReports(reports PluginInstallReports, isUpdateReport bool) {
|
||||
installSkipReports := []string{}
|
||||
for _, report := range reports {
|
||||
showReport := true
|
||||
if report.SkipReason == constants.InstallMessagePluginAlreadyInstalled || report.SkipReason == constants.InstallMessagePluginLatestAlreadyInstalled {
|
||||
if report.SkipReason == constants2.InstallMessagePluginAlreadyInstalled || report.SkipReason == constants2.InstallMessagePluginLatestAlreadyInstalled {
|
||||
showReport = false
|
||||
}
|
||||
if report.Skipped && showReport {
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
constants2 "github.com/turbot/pipe-fittings/constants"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
@@ -97,7 +98,7 @@ func HandleCancelError(err error) error {
|
||||
|
||||
func HandleQueryTimeoutError(err error) error {
|
||||
if errors.Is(err, context.DeadlineExceeded) {
|
||||
err = fmt.Errorf("query timeout exceeded (%ds)", viper.GetInt(constants.ArgDatabaseQueryTimeout))
|
||||
err = fmt.Errorf("query timeout exceeded (%ds)", viper.GetInt(constants2.ArgDatabaseQueryTimeout))
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -398,7 +398,7 @@ func (c *InteractiveClient) executeQuery(ctx context.Context, queryCtx context.C
|
||||
if err != nil {
|
||||
error_helpers.ShowError(ctx, error_helpers.HandleCancelError(err))
|
||||
// if timing flag is enabled, show the time taken for the query to fail
|
||||
if cmdconfig.Viper().GetString(constants.ArgTiming) != constants.ArgOff {
|
||||
if cmdconfig.Viper().GetString(pconstants.ArgTiming) != pconstants.ArgOff {
|
||||
display.DisplayErrorTiming(t)
|
||||
}
|
||||
} else {
|
||||
@@ -558,7 +558,7 @@ func (c *InteractiveClient) restartInteractiveSession() {
|
||||
}
|
||||
|
||||
func (c *InteractiveClient) shouldExecute(line string) bool {
|
||||
if !cmdconfig.Viper().GetBool(constants.ArgMultiLine) {
|
||||
if !cmdconfig.Viper().GetBool(pconstants.ArgMultiLine) {
|
||||
// NOT multiline mode
|
||||
return true
|
||||
}
|
||||
@@ -575,7 +575,7 @@ func (c *InteractiveClient) shouldExecute(line string) bool {
|
||||
}
|
||||
|
||||
func (c *InteractiveClient) queryCompleter(d prompt.Document) []prompt.Suggest {
|
||||
if !cmdconfig.Viper().GetBool(constants.ArgAutoComplete) {
|
||||
if !cmdconfig.Viper().GetBool(pconstants.ArgAutoComplete) {
|
||||
return nil
|
||||
}
|
||||
if !c.isInitialised() {
|
||||
@@ -720,7 +720,7 @@ func (c *InteractiveClient) handlePostgresNotification(ctx context.Context, noti
|
||||
|
||||
func (c *InteractiveClient) handleErrorsAndWarningsNotification(ctx context.Context, notification *steampipeconfig.ErrorsAndWarningsNotification) {
|
||||
log.Printf("[TRACE] handleErrorsAndWarningsNotification")
|
||||
output := viper.Get(constants.ArgOutput)
|
||||
output := viper.Get(pconstants.ArgOutput)
|
||||
if output == constants.OutputFormatJSON || output == constants.OutputFormatCSV {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package metaquery
|
||||
|
||||
import (
|
||||
constants2 "github.com/turbot/pipe-fittings/constants"
|
||||
"github.com/turbot/steampipe/pkg/constants"
|
||||
)
|
||||
|
||||
@@ -48,7 +49,7 @@ func init() {
|
||||
},
|
||||
constants.CmdSeparator: {
|
||||
title: constants.CmdSeparator,
|
||||
handler: setViperConfigFromArg(constants.ArgSeparator),
|
||||
handler: setViperConfigFromArg(constants2.ArgSeparator),
|
||||
validator: exactlyNArgs(1),
|
||||
description: "Set csv output separator",
|
||||
},
|
||||
@@ -58,8 +59,8 @@ func init() {
|
||||
validator: booleanValidator(constants.CmdHeaders, validatorFromArgsOf(constants.CmdHeaders)),
|
||||
description: "Enable or disable column headers",
|
||||
args: []metaQueryArg{
|
||||
{value: constants.ArgOn, description: "Turn on headers in output"},
|
||||
{value: constants.ArgOff, description: "Turn off headers in output"},
|
||||
{value: constants2.ArgOn, description: "Turn on headers in output"},
|
||||
{value: constants2.ArgOff, description: "Turn off headers in output"},
|
||||
},
|
||||
completer: completerFromArgsOf(constants.CmdHeaders),
|
||||
},
|
||||
@@ -69,8 +70,8 @@ func init() {
|
||||
validator: booleanValidator(constants.CmdMulti, validatorFromArgsOf(constants.CmdMulti)),
|
||||
description: "Enable or disable multiline mode",
|
||||
args: []metaQueryArg{
|
||||
{value: constants.ArgOn, description: "Turn on multiline mode"},
|
||||
{value: constants.ArgOff, description: "Turn off multiline mode"},
|
||||
{value: constants2.ArgOn, description: "Turn on multiline mode"},
|
||||
{value: constants2.ArgOff, description: "Turn off multiline mode"},
|
||||
},
|
||||
completer: completerFromArgsOf(constants.CmdMulti),
|
||||
},
|
||||
@@ -80,15 +81,15 @@ func init() {
|
||||
validator: validatorFromArgsOf(constants.CmdTiming),
|
||||
description: "Enable or disable query execution timing",
|
||||
args: []metaQueryArg{
|
||||
{value: constants.ArgOff, description: "Turn off query timer"},
|
||||
{value: constants.ArgOn, description: "Display time elapsed after every query"},
|
||||
{value: constants.ArgVerbose, description: "Display time elapsed and details of each scan"},
|
||||
{value: constants2.ArgOff, description: "Turn off query timer"},
|
||||
{value: constants2.ArgOn, description: "Display time elapsed after every query"},
|
||||
{value: constants2.ArgVerbose, description: "Display time elapsed and details of each scan"},
|
||||
},
|
||||
completer: completerFromArgsOf(constants.CmdTiming),
|
||||
},
|
||||
constants.CmdOutput: {
|
||||
title: constants.CmdOutput,
|
||||
handler: setViperConfigFromArg(constants.ArgOutput),
|
||||
handler: setViperConfigFromArg(constants2.ArgOutput),
|
||||
validator: composeValidator(exactlyNArgs(1), validatorFromArgsOf(constants.CmdOutput)),
|
||||
description: "Set output format: csv, json, table or line",
|
||||
args: []metaQueryArg{
|
||||
@@ -105,9 +106,9 @@ func init() {
|
||||
validator: validatorFromArgsOf(constants.CmdCache),
|
||||
description: "Enable, disable or clear the query cache",
|
||||
args: []metaQueryArg{
|
||||
{value: constants.ArgOn, description: "Turn on caching"},
|
||||
{value: constants.ArgOff, description: "Turn off caching"},
|
||||
{value: constants.ArgClear, description: "Clear the cache"},
|
||||
{value: constants2.ArgOn, description: "Turn on caching"},
|
||||
{value: constants2.ArgOff, description: "Turn off caching"},
|
||||
{value: constants2.ArgClear, description: "Clear the cache"},
|
||||
},
|
||||
completer: completerFromArgsOf(constants.CmdCache),
|
||||
},
|
||||
@@ -157,8 +158,8 @@ func init() {
|
||||
validator: booleanValidator(constants.CmdAutoComplete, validatorFromArgsOf(constants.CmdAutoComplete)),
|
||||
description: "Enable or disable auto-completion",
|
||||
args: []metaQueryArg{
|
||||
{value: constants.ArgOn, description: "Turn on auto-completion"},
|
||||
{value: constants.ArgOff, description: "Turn off auto-completion"},
|
||||
{value: constants2.ArgOn, description: "Turn on auto-completion"},
|
||||
{value: constants2.ArgOff, description: "Turn off auto-completion"},
|
||||
},
|
||||
completer: completerFromArgsOf(constants.CmdAutoComplete),
|
||||
},
|
||||
|
||||
@@ -3,6 +3,7 @@ package metaquery
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
constants2 "github.com/turbot/pipe-fittings/constants"
|
||||
"math"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -37,17 +38,17 @@ func cacheControl(ctx context.Context, input *HandlerInput) error {
|
||||
conn := sessionResult.Session.Connection.Conn()
|
||||
command := strings.ToLower(input.args()[0])
|
||||
switch command {
|
||||
case constants.ArgOn:
|
||||
case constants2.ArgOn:
|
||||
serverSettings := input.Client.ServerSettings()
|
||||
if serverSettings != nil && !serverSettings.CacheEnabled {
|
||||
fmt.Println("Caching is disabled on the server.")
|
||||
}
|
||||
viper.Set(constants.ArgClientCacheEnabled, true)
|
||||
viper.Set(constants2.ArgClientCacheEnabled, true)
|
||||
return db_common.SetCacheEnabled(ctx, true, conn)
|
||||
case constants.ArgOff:
|
||||
viper.Set(constants.ArgClientCacheEnabled, false)
|
||||
case constants2.ArgOff:
|
||||
viper.Set(constants2.ArgClientCacheEnabled, false)
|
||||
return db_common.SetCacheEnabled(ctx, false, conn)
|
||||
case constants.ArgClear:
|
||||
case constants2.ArgClear:
|
||||
return db_common.CacheClear(ctx, conn)
|
||||
}
|
||||
|
||||
@@ -77,7 +78,7 @@ func cacheTTL(ctx context.Context, input *HandlerInput) error {
|
||||
// we need to do this in a closure, otherwise the ctx will be evaluated immediately
|
||||
// and not in call-time
|
||||
sessionResult.Session.Close(false)
|
||||
viper.Set(constants.ArgCacheTtl, seconds)
|
||||
viper.Set(constants2.ArgCacheTtl, seconds)
|
||||
}()
|
||||
return db_common.SetCacheTtl(ctx, time.Duration(seconds)*time.Second, sessionResult.Session.Connection.Conn())
|
||||
}
|
||||
@@ -91,7 +92,7 @@ func showCache(_ context.Context, input *HandlerInput) error {
|
||||
currentStatusString := "off"
|
||||
action := "on"
|
||||
|
||||
if !viper.IsSet(constants.ArgClientCacheEnabled) || viper.GetBool(constants.ArgClientCacheEnabled) {
|
||||
if !viper.IsSet(constants2.ArgClientCacheEnabled) || viper.GetBool(constants2.ArgClientCacheEnabled) {
|
||||
currentStatusString = "on"
|
||||
action = "off"
|
||||
}
|
||||
@@ -110,8 +111,8 @@ func showCache(_ context.Context, input *HandlerInput) error {
|
||||
}
|
||||
|
||||
func showCacheTtl(ctx context.Context, input *HandlerInput) error {
|
||||
if viper.IsSet(constants.ArgCacheTtl) {
|
||||
ttl := getEffectiveCacheTtl(input.Client.ServerSettings(), viper.GetInt(constants.ArgCacheTtl))
|
||||
if viper.IsSet(constants2.ArgCacheTtl) {
|
||||
ttl := getEffectiveCacheTtl(input.Client.ServerSettings(), viper.GetInt(constants2.ArgCacheTtl))
|
||||
fmt.Println("Cache TTL is", ttl, "seconds.")
|
||||
} else if input.Client.ServerSettings() != nil {
|
||||
serverTtl := input.Client.ServerSettings().CacheMaxTtl
|
||||
|
||||
@@ -2,6 +2,7 @@ package metaquery
|
||||
|
||||
import (
|
||||
"context"
|
||||
constants2 "github.com/turbot/pipe-fittings/constants"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
@@ -31,7 +32,7 @@ func setOrGetSearchPath(ctx context.Context, input *HandlerInput) error {
|
||||
s = strings.TrimSpace(s)
|
||||
paths = append(paths, s)
|
||||
}
|
||||
viper.Set(constants.ArgSearchPath, paths)
|
||||
viper.Set(constants2.ArgSearchPath, paths)
|
||||
|
||||
// now that the viper is set, call back into the client (exposed via QueryExecutor) which
|
||||
// already knows how to setup the search_paths with the viper values
|
||||
@@ -48,7 +49,7 @@ func setSearchPathPrefix(ctx context.Context, input *HandlerInput) error {
|
||||
s = strings.TrimSpace(s)
|
||||
paths = append(paths, s)
|
||||
}
|
||||
viper.Set(constants.ArgSearchPathPrefix, paths)
|
||||
viper.Set(constants2.ArgSearchPathPrefix, paths)
|
||||
|
||||
// now that the viper is set, call back into the client (exposed via QueryExecutor) which
|
||||
// already knows how to setup the search_paths with the viper values
|
||||
|
||||
@@ -3,6 +3,7 @@ package metaquery
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
constants2 "github.com/turbot/pipe-fittings/constants"
|
||||
"strings"
|
||||
|
||||
typeHelpers "github.com/turbot/go-kit/types"
|
||||
@@ -27,14 +28,14 @@ func Handle(ctx context.Context, input *HandlerInput) error {
|
||||
// .header
|
||||
// set the ArgHeader viper key with the boolean value evaluated from arg[0]
|
||||
func setHeader(_ context.Context, input *HandlerInput) error {
|
||||
cmdconfig.Viper().Set(constants.ArgHeader, typeHelpers.StringToBool(input.args()[0]))
|
||||
cmdconfig.Viper().Set(constants2.ArgHeader, typeHelpers.StringToBool(input.args()[0]))
|
||||
return nil
|
||||
}
|
||||
|
||||
// .multi
|
||||
// set the ArgMulti viper key with the boolean value evaluated from arg[0]
|
||||
func setMultiLine(_ context.Context, input *HandlerInput) error {
|
||||
cmdconfig.Viper().Set(constants.ArgMultiLine, typeHelpers.StringToBool(input.args()[0]))
|
||||
cmdconfig.Viper().Set(constants2.ArgMultiLine, typeHelpers.StringToBool(input.args()[0]))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -46,12 +47,12 @@ func setTiming(ctx context.Context, input *HandlerInput) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
cmdconfig.Viper().Set(constants.ArgTiming, input.args()[0])
|
||||
cmdconfig.Viper().Set(constants2.ArgTiming, input.args()[0])
|
||||
return nil
|
||||
}
|
||||
|
||||
func showTimingFlag() {
|
||||
timing := cmdconfig.Viper().GetString(constants.ArgTiming)
|
||||
timing := cmdconfig.Viper().GetString(constants2.ArgTiming)
|
||||
|
||||
fmt.Printf(`Timing is %s. Available options are: %s`,
|
||||
constants.Bold(timing),
|
||||
@@ -85,6 +86,6 @@ func clearScreen(_ context.Context, input *HandlerInput) error {
|
||||
|
||||
// .autocomplete
|
||||
func setAutoComplete(_ context.Context, input *HandlerInput) error {
|
||||
cmdconfig.Viper().Set(constants.ArgAutoComplete, typeHelpers.StringToBool(input.args()[0]))
|
||||
cmdconfig.Viper().Set(constants2.ArgAutoComplete, typeHelpers.StringToBool(input.args()[0]))
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package metaquery
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
constants2 "github.com/turbot/pipe-fittings/constants"
|
||||
"strings"
|
||||
|
||||
"github.com/turbot/go-kit/helpers"
|
||||
@@ -61,11 +62,11 @@ func booleanValidator(metaquery string, validators ...validator) validator {
|
||||
newStatus := !currentStatus
|
||||
|
||||
// convert current and new status to on/off
|
||||
currentStatusString := constants.BoolToOnOff(currentStatus)
|
||||
newStatusString := constants.BoolToOnOff(newStatus)
|
||||
currentStatusString := constants2.BoolToOnOff(currentStatus)
|
||||
newStatusString := constants2.BoolToOnOff(newStatus)
|
||||
|
||||
// what is the action to get to the new status
|
||||
actionString := constants.BoolToEnableDisable(newStatus)
|
||||
actionString := constants2.BoolToEnableDisable(newStatus)
|
||||
|
||||
return ValidationResult{
|
||||
Message: fmt.Sprintf(`%s mode is %s. You can %s it with: %s.`,
|
||||
|
||||
@@ -11,42 +11,12 @@ import (
|
||||
|
||||
// Steampipe Media Types
|
||||
const (
|
||||
//MediaTypeConfig = "application/vnd.turbot.steampipe.config.v1+json"
|
||||
|
||||
//deprecate this....
|
||||
//MediaTypePluginConfig = "application/vnd.turbot.steampipe.plugin.config.v1+json"
|
||||
|
||||
//MediaTypePluginDarwinAmd64Layer = "application/vnd.turbot.steampipe.plugin.darwin-amd64.layer.v1+gzip"
|
||||
//MediaTypePluginLinuxAmd64Layer = "application/vnd.turbot.steampipe.plugin.linux-amd64.layer.v1+gzip"
|
||||
//MediaTypePluginWindowsAmd64Layer = "application/vnd.turbot.steampipe.plugin.windows-amd64.layer.v1+gzip"
|
||||
//MediaTypePluginDarwinArm64Layer = "application/vnd.turbot.steampipe.plugin.darwin-arm64.layer.v1+gzip"
|
||||
//MediaTypePluginLinuxArm64Layer = "application/vnd.turbot.steampipe.plugin.linux-arm64.layer.v1+gzip"
|
||||
//MediaTypePluginWindowsArm64Layer = "application/vnd.turbot.steampipe.plugin.windows-arm64.layer.v1+gzip"
|
||||
//MediaTypePluginLicenseLayer = "application/vnd.turbot.steampipe.plugin.license.layer.v1+text"
|
||||
//MediaTypePluginDocsLayer = "application/vnd.turbot.steampipe.plugin.docs.layer.v1+tar"
|
||||
//MediaTypePluginSpcLayer = "application/vnd.turbot.steampipe.plugin.spc.layer.v1+tar"
|
||||
|
||||
//MediaTypeDbDarwinAmd64Layer = "application/vnd.turbot.steampipe.db.darwin-amd64.layer.v1+tar"
|
||||
//MediaTypeDbLinuxAmd64Layer = "application/vnd.turbot.steampipe.db.linux-amd64.layer.v1+tar"
|
||||
//MediaTypeDbWindowsAmd64Layer = "application/vnd.turbot.steampipe.db.windows-amd64.layer.v1+tar"
|
||||
//MediaTypeDbDarwinArm64Layer = "application/vnd.turbot.steampipe.db.darwin-arm64.layer.v1+tar"
|
||||
//MediaTypeDbLinuxArm64Layer = "application/vnd.turbot.steampipe.db.linux-arm64.layer.v1+tar"
|
||||
//MediaTypeDbWindowsArm64Layer = "application/vnd.turbot.steampipe.db.windows-arm64.layer.v1+tar"
|
||||
MediaTypeDbDocLayer = "application/vnd.turbot.steampipe.db.doc.layer.v1+text"
|
||||
MediaTypeDbLicenseLayer = "application/vnd.turbot.steampipe.db.license.layer.v1+text"
|
||||
|
||||
//MediaTypeFdwDarwinAmd64Layer = "application/vnd.turbot.steampipe.fdw.darwin-amd64.layer.v1+gzip"
|
||||
//MediaTypeFdwLinuxAmd64Layer = "application/vnd.turbot.steampipe.fdw.linux-amd64.layer.v1+gzip"
|
||||
//MediaTypeFdwWindowsAmd64Layer = "application/vnd.turbot.steampipe.fdw.windows-amd64.layer.v1+gzip"
|
||||
//MediaTypeFdwDarwinArm64Layer = "application/vnd.turbot.steampipe.fdw.darwin-arm64.layer.v1+gzip"
|
||||
//MediaTypeFdwLinuxArm64Layer = "application/vnd.turbot.steampipe.fdw.linux-arm64.layer.v1+gzip"
|
||||
//MediaTypeFdwWindowsArm64Layer = "application/vnd.turbot.steampipe.fdw.windows-arm64.layer.v1+gzip"
|
||||
MediaTypeFdwDocLayer = "application/vnd.turbot.steampipe.fdw.doc.layer.v1+text"
|
||||
MediaTypeFdwLicenseLayer = "application/vnd.turbot.steampipe.fdw.license.layer.v1+text"
|
||||
|
||||
MediaTypeFdwControlLayer = "application/vnd.turbot.steampipe.fdw.control.layer.v1+text"
|
||||
MediaTypeFdwSqlLayer = "application/vnd.turbot.steampipe.fdw.sql.layer.v1+text"
|
||||
|
||||
MediaTypeDbDocLayer = "application/vnd.turbot.steampipe.db.doc.layer.v1+text"
|
||||
MediaTypeDbLicenseLayer = "application/vnd.turbot.steampipe.db.license.layer.v1+text"
|
||||
MediaTypeFdwDocLayer = "application/vnd.turbot.steampipe.fdw.doc.layer.v1+text"
|
||||
MediaTypeFdwLicenseLayer = "application/vnd.turbot.steampipe.fdw.license.layer.v1+text"
|
||||
MediaTypeFdwControlLayer = "application/vnd.turbot.steampipe.fdw.control.layer.v1+text"
|
||||
MediaTypeFdwSqlLayer = "application/vnd.turbot.steampipe.fdw.sql.layer.v1+text"
|
||||
MediaTypeAssetReportLayer = "application/vnd.turbot.steampipe.assets.report.layer.v1+tar"
|
||||
)
|
||||
|
||||
|
||||
146
pkg/plugin/actions.go
Normal file
146
pkg/plugin/actions.go
Normal file
@@ -0,0 +1,146 @@
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
plugin2 "github.com/turbot/pipe-fittings/plugin"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"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/statushooks"
|
||||
"github.com/turbot/steampipe-plugin-sdk/v5/sperr"
|
||||
)
|
||||
|
||||
// Remove removes an installed plugin
|
||||
func Remove(ctx context.Context, image string, pluginConnections map[string][]PluginConnection) (*PluginRemoveReport, error) {
|
||||
statushooks.SetStatus(ctx, fmt.Sprintf("Removing plugin %s", image))
|
||||
|
||||
imageRef := ociinstaller.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 := versionfile.LoadPluginVersionFile(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
delete(v.Plugins, fullPluginName)
|
||||
err = v.Save()
|
||||
|
||||
return &PluginRemoveReport{Connections: conns, Image: imageRef}, err
|
||||
}
|
||||
|
||||
// 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) {
|
||||
// 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
|
||||
}
|
||||
|
||||
// PluginListItem is a struct representing an item in the list of plugins
|
||||
type PluginListItem struct {
|
||||
Name string
|
||||
Version *plugin2.PluginVersionString
|
||||
Connections []string
|
||||
}
|
||||
|
||||
// List returns all installed plugins
|
||||
func List(ctx context.Context, pluginConnectionMap map[string][]PluginConnection, pluginVersions map[string]*versionfile.InstalledVersion) ([]PluginListItem, error) {
|
||||
var items []PluginListItem
|
||||
|
||||
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: plugin2.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)
|
||||
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.GetDisplayName()
|
||||
|
||||
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 *versionfile.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)
|
||||
}
|
||||
22
pkg/plugin/installed.go
Normal file
22
pkg/plugin/installed.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/turbot/pipe-fittings/ociinstaller"
|
||||
"github.com/turbot/pipe-fittings/ociinstaller/versionfile"
|
||||
plugin2 "github.com/turbot/pipe-fittings/plugin"
|
||||
)
|
||||
|
||||
// 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)
|
||||
installedPluginsData, _ := List(ctx, nil, pluginVersions)
|
||||
for _, plugin := range installedPluginsData {
|
||||
org, name, _ := ociinstaller.NewImageRef(plugin.Name).GetOrgNameAndStream()
|
||||
pluginShortName := fmt.Sprintf("%s/%s", org, name)
|
||||
installedPlugins[pluginShortName] = plugin.Version
|
||||
}
|
||||
return installedPlugins, nil
|
||||
}
|
||||
9
pkg/plugin/plugin_connection.go
Normal file
9
pkg/plugin/plugin_connection.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package plugin
|
||||
|
||||
import pplugin "github.com/turbot/pipe-fittings/plugin"
|
||||
|
||||
type PluginConnection interface {
|
||||
GetDeclRange() pplugin.Range
|
||||
GetName() string
|
||||
GetDisplayName() string
|
||||
}
|
||||
72
pkg/plugin/plugin_remove.go
Normal file
72
pkg/plugin/plugin_remove.go
Normal file
@@ -0,0 +1,72 @@
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/turbot/pipe-fittings/constants"
|
||||
"github.com/turbot/pipe-fittings/ociinstaller"
|
||||
"github.com/turbot/pipe-fittings/utils"
|
||||
)
|
||||
|
||||
type PluginRemoveReport struct {
|
||||
Image *ociinstaller.ImageRef
|
||||
ShortName string
|
||||
Connections []PluginConnection
|
||||
}
|
||||
|
||||
type PluginRemoveReports []PluginRemoveReport
|
||||
|
||||
func (r PluginRemoveReports) Print() {
|
||||
length := len(r)
|
||||
var staleConnections []PluginConnection
|
||||
if length > 0 {
|
||||
fmt.Printf("\nUninstalled %s:\n", utils.Pluralize("plugin", length)) //nolint:forbidigo // acceptable
|
||||
for _, report := range r {
|
||||
org, name, _ := report.Image.GetOrgNameAndStream()
|
||||
fmt.Printf("* %s/%s\n", org, name) //nolint:forbidigo // acceptable
|
||||
staleConnections = append(staleConnections, report.Connections...)
|
||||
|
||||
// sort the connections by line number while we are at it!
|
||||
sort.SliceStable(report.Connections, func(i, j int) bool {
|
||||
left := report.Connections[i]
|
||||
right := report.Connections[j]
|
||||
return left.GetDeclRange().Start.Line < right.GetDeclRange().Start.Line
|
||||
})
|
||||
}
|
||||
fmt.Println() //nolint:forbidigo // acceptable
|
||||
staleLength := len(staleConnections)
|
||||
uniqueFiles := map[string]bool{}
|
||||
// get the unique files
|
||||
if staleLength > 0 {
|
||||
for _, report := range r {
|
||||
for _, conn := range report.Connections {
|
||||
uniqueFiles[conn.GetDeclRange().Filename] = true
|
||||
}
|
||||
}
|
||||
|
||||
str := append([]string{}, fmt.Sprintf(
|
||||
"Please remove %s %s to continue using steampipe:",
|
||||
utils.Pluralize("this", len(uniqueFiles)),
|
||||
utils.Pluralize("connection", len(uniqueFiles)),
|
||||
))
|
||||
|
||||
str = append(str, "")
|
||||
|
||||
for file := range uniqueFiles {
|
||||
str = append(str, fmt.Sprintf(" * %s", constants.Bold(file)))
|
||||
for _, report := range r {
|
||||
for _, conn := range report.Connections {
|
||||
if conn.GetDeclRange().Filename == file {
|
||||
str = append(str, fmt.Sprintf(" '%s' (line %2d)", conn.GetName(), conn.GetDeclRange().Start.Line))
|
||||
}
|
||||
}
|
||||
}
|
||||
str = append(str, "")
|
||||
}
|
||||
|
||||
fmt.Println(strings.Join(str, "\n")) //nolint:forbidigo // acceptable
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package pluginmanager
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/turbot/pipe-fittings/constants"
|
||||
"io"
|
||||
"log"
|
||||
"os/exec"
|
||||
@@ -12,7 +13,6 @@ import (
|
||||
"github.com/turbot/pipe-fittings/app_specific"
|
||||
"github.com/turbot/steampipe-plugin-sdk/v5/logging"
|
||||
"github.com/turbot/steampipe-plugin-sdk/v5/sperr"
|
||||
"github.com/turbot/steampipe/pkg/constants"
|
||||
"github.com/turbot/steampipe/pkg/pluginmanager_service/grpc"
|
||||
pb "github.com/turbot/steampipe/pkg/pluginmanager_service/grpc/proto"
|
||||
pluginshared "github.com/turbot/steampipe/pkg/pluginmanager_service/grpc/shared"
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
"github.com/sethvargo/go-retry"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/turbot/go-kit/helpers"
|
||||
pconstants "github.com/turbot/pipe-fittings/constants"
|
||||
"github.com/turbot/pipe-fittings/filepaths"
|
||||
"github.com/turbot/pipe-fittings/plugin"
|
||||
"github.com/turbot/pipe-fittings/utils"
|
||||
@@ -523,8 +524,8 @@ func (m *PluginManager) startPluginProcess(pluginInstance string, connectionConf
|
||||
func (m *PluginManager) setPluginMaxMemory(pluginConfig *plugin.Plugin, cmd *exec.Cmd) {
|
||||
maxMemoryBytes := pluginConfig.GetMaxMemoryBytes()
|
||||
if maxMemoryBytes == 0 {
|
||||
if viper.IsSet(constants.ArgMemoryMaxMbPlugin) {
|
||||
maxMemoryBytes = viper.GetInt64(constants.ArgMemoryMaxMbPlugin) * 1024 * 1024
|
||||
if viper.IsSet(pconstants.ArgMemoryMaxMbPlugin) {
|
||||
maxMemoryBytes = viper.GetInt64(pconstants.ArgMemoryMaxMbPlugin) * 1024 * 1024
|
||||
}
|
||||
}
|
||||
if maxMemoryBytes != 0 {
|
||||
@@ -758,9 +759,9 @@ func (m *PluginManager) setAllConnectionConfigs(connectionConfigs []*sdkproto.Co
|
||||
|
||||
func (m *PluginManager) setCacheOptions(pluginClient *sdkgrpc.PluginClient) error {
|
||||
req := &sdkproto.SetCacheOptionsRequest{
|
||||
Enabled: viper.GetBool(constants.ArgServiceCacheEnabled),
|
||||
Ttl: viper.GetInt64(constants.ArgCacheMaxTtl),
|
||||
MaxSizeMb: viper.GetInt64(constants.ArgMaxCacheSizeMb),
|
||||
Enabled: viper.GetBool(pconstants.ArgServiceCacheEnabled),
|
||||
Ttl: viper.GetInt64(pconstants.ArgCacheMaxTtl),
|
||||
MaxSizeMb: viper.GetInt64(pconstants.ArgMaxCacheSizeMb),
|
||||
}
|
||||
_, err := pluginClient.SetCacheOptions(req)
|
||||
return err
|
||||
@@ -771,7 +772,7 @@ func (m *PluginManager) setRateLimiters(pluginInstance string, pluginClient *sdk
|
||||
var defs []*sdkproto.RateLimiterDefinition
|
||||
|
||||
for _, l := range m.userLimiters[pluginInstance] {
|
||||
defs = append(defs, l.AsProto())
|
||||
defs = append(defs, sdkproto.RateLimiterAsProto(l))
|
||||
}
|
||||
|
||||
req := &sdkproto.SetRateLimitersRequest{Definitions: defs}
|
||||
|
||||
@@ -3,6 +3,7 @@ package pluginmanager_service
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/turbot/pipe-fittings/error_helpers"
|
||||
|
||||
"log"
|
||||
|
||||
@@ -306,7 +307,7 @@ func (m *PluginManager) LoadPluginRateLimiters(pluginConnectionMap map[string]st
|
||||
|
||||
limitersForPlugin := make(connection.LimiterMap)
|
||||
for _, l := range rateLimiterResp.Definitions {
|
||||
r, err := plugin.RateLimiterFromProto(l, reattach.Plugin, pluginInstance)
|
||||
r, err := proto.RateLimiterFromProto(l, reattach.Plugin, pluginInstance)
|
||||
if err != nil {
|
||||
errors = append(errors, sperr.WrapWithMessage(err, "failed to create rate limiter %s from plugin definition", err))
|
||||
continue
|
||||
@@ -323,5 +324,9 @@ func (m *PluginManager) LoadPluginRateLimiters(pluginConnectionMap map[string]st
|
||||
res[reattach.Plugin] = limitersForPlugin
|
||||
}
|
||||
|
||||
if len(errors) > 0 {
|
||||
return nil, error_helpers.CombineErrors(errors...)
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package query
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
constants2 "github.com/turbot/pipe-fittings/constants"
|
||||
"github.com/turbot/steampipe/pkg/error_helpers"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -84,18 +85,18 @@ func (i *InitData) init(ctx context.Context, args []string) {
|
||||
}()
|
||||
|
||||
// validate export args
|
||||
if len(viper.GetStringSlice(constants.ArgExport)) > 0 {
|
||||
if len(viper.GetStringSlice(constants2.ArgExport)) > 0 {
|
||||
i.RegisterExporters(queryExporters()...)
|
||||
|
||||
// validate required export formats
|
||||
if err := i.ExportManager.ValidateExportFormat(viper.GetStringSlice(constants.ArgExport)); err != nil {
|
||||
if err := i.ExportManager.ValidateExportFormat(viper.GetStringSlice(constants2.ArgExport)); err != nil {
|
||||
i.Result.Error = err
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// set max DB connections to 1
|
||||
viper.Set(constants.ArgMaxParallel, 1)
|
||||
viper.Set(constants2.ArgMaxParallel, 1)
|
||||
|
||||
statushooks.SetStatus(ctx, "Resolving arguments")
|
||||
|
||||
|
||||
@@ -3,13 +3,13 @@ package queryexecute
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/turbot/pipe-fittings/constants"
|
||||
"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"
|
||||
"github.com/turbot/steampipe/pkg/contexthelpers"
|
||||
"github.com/turbot/steampipe/pkg/db/db_common"
|
||||
"github.com/turbot/steampipe/pkg/display"
|
||||
|
||||
@@ -2,6 +2,7 @@ package steampipeconfig
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
constants2 "github.com/turbot/pipe-fittings/constants"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
@@ -194,7 +195,7 @@ func handleGetFailures(getResponse *proto.GetResponse, res *RefreshConnectionRes
|
||||
for _, c := range connectionsToCreate {
|
||||
if c.Plugin == failedPluginInstance {
|
||||
|
||||
res.AddFailedConnection(c.Name, constants.ConnectionErrorPluginFailedToStart)
|
||||
res.AddFailedConnection(c.Name, constants2.ConnectionErrorPluginFailedToStart)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package steampipeconfig
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
constants2 "github.com/turbot/pipe-fittings/constants"
|
||||
"github.com/turbot/pipe-fittings/error_helpers"
|
||||
"log"
|
||||
"os"
|
||||
@@ -43,7 +44,7 @@ func GetRequiredConnectionStateMap(connectionMap map[string]*modconfig.Connectio
|
||||
requiredState[connection.Name] = newErrorConnectionState(connection)
|
||||
// if error is a missing plugin, add to missingPluginMap
|
||||
// this will be used to build missing plugin warnings
|
||||
if connection.Error.Error() == constants.ConnectionErrorPluginNotInstalled {
|
||||
if connection.Error.Error() == constants2.ConnectionErrorPluginNotInstalled {
|
||||
missingPluginMap[connection.PluginAlias] = append(missingPluginMap[connection.PluginAlias], *connection)
|
||||
} else {
|
||||
// otherwise add error to result as warning, so we display it
|
||||
|
||||
@@ -4,8 +4,6 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/turbot/pipe-fittings/options"
|
||||
"github.com/turbot/pipe-fittings/workspace_profile"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -21,8 +19,10 @@ import (
|
||||
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/workspace_profile"
|
||||
"github.com/turbot/steampipe-plugin-sdk/v5/sperr"
|
||||
"github.com/turbot/steampipe/pkg/constants"
|
||||
"github.com/turbot/steampipe/pkg/db/db_common"
|
||||
|
||||
@@ -2,6 +2,7 @@ package steampipeconfig
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/turbot/pipe-fittings/constants"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
@@ -17,7 +18,6 @@ import (
|
||||
"github.com/turbot/pipe-fittings/plugin"
|
||||
"github.com/turbot/pipe-fittings/workspace_profile"
|
||||
"github.com/turbot/steampipe-plugin-sdk/v5/sperr"
|
||||
"github.com/turbot/steampipe/pkg/constants"
|
||||
"github.com/turbot/steampipe/pkg/steampipeconfig/modconfig"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user