diff --git a/cmd/plugin.go b/cmd/plugin.go index a9464a6296..62bb2d03f4 100644 --- a/cmd/plugin.go +++ b/cmd/plugin.go @@ -636,9 +636,10 @@ func getPluginList(ctx context.Context) (pluginList []plugin.PluginListItem, fai return nil, nil, nil, res } - // TODO do we really need to look at installed plugins - can't we just use the plugin connection map // get a list of the installed plugins by inspecting the install location // pass pluginConnectionMap so we can populate the connections for each plugin + // we need to look at installed plugins - we can't just use the plugin connection map + // because the plugin connection map only contains entries for plugins which have connections pluginList, err := plugin.List(pluginConnectionMap) if err != nil { res.Error = err diff --git a/cmd/root.go b/cmd/root.go index 48aae63920..f4561238e6 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -420,7 +420,7 @@ func Execute() int { // create the root context - add a status renderer func createRootContext() context.Context { - var statusRenderer statushooks.StatusHooks = statushooks.NullHooks + statusRenderer := statushooks.NullHooks // if the client is a TTY, inject a status spinner if isatty.IsTerminal(os.Stdout.Fd()) { statusRenderer = statushooks.NewStatusSpinnerHook() diff --git a/pkg/statushooks/null_hooks.go b/pkg/statushooks/null_hooks.go index 50282365be..27a3e13c38 100644 --- a/pkg/statushooks/null_hooks.go +++ b/pkg/statushooks/null_hooks.go @@ -1,6 +1,6 @@ package statushooks -var NullHooks = &NullStatusHook{} +var NullHooks StatusHooks = &NullStatusHook{} type NullStatusHook struct{} diff --git a/pkg/steampipeconfig/connection_state_map.go b/pkg/steampipeconfig/connection_state_map.go index 25a5e409fe..bfa280e5c7 100644 --- a/pkg/steampipeconfig/connection_state_map.go +++ b/pkg/steampipeconfig/connection_state_map.go @@ -115,6 +115,7 @@ func (m ConnectionStateMap) Loaded(connections ...string) bool { // ignore if we have no state loaded for this conneciton name continue } + log.Println("[TRACE] Checking state for", connectionName) if !connectionState.Loaded() { return false } diff --git a/pkg/steampipeconfig/modconfig/connection.go b/pkg/steampipeconfig/modconfig/connection.go index 82ac205fec..976946e7d3 100644 --- a/pkg/steampipeconfig/modconfig/connection.go +++ b/pkg/steampipeconfig/modconfig/connection.go @@ -9,6 +9,7 @@ import ( "github.com/hashicorp/hcl/v2" "github.com/turbot/go-kit/helpers" + "github.com/turbot/steampipe/pkg/constants" "github.com/turbot/steampipe/pkg/steampipeconfig/options" "github.com/turbot/steampipe/pkg/utils" "golang.org/x/exp/maps" @@ -115,7 +116,7 @@ func NewConnection(block *hcl.Block) *Connection { } func (c *Connection) ImportDisabled() bool { - return c.ImportSchema == "disabled" + return c.ImportSchema == constants.ConnectionStateDisabled } func (c *Connection) Equals(other *Connection) bool { diff --git a/tests/acceptance/run.sh b/tests/acceptance/run.sh index 28401f635e..de9dcf43ca 100755 --- a/tests/acceptance/run.sh +++ b/tests/acceptance/run.sh @@ -31,7 +31,6 @@ export BLANK_DIMENSION_VALUE_TEST_MOD=$MY_PATH/test_data/mod_with_blank_dimensio export STEAMPIPE_CONNECTION_WATCHER=false export STEAMPIPE_INTROSPECTION=info export DEFAULT_WORKSPACE_PROFILE_LOCATION=$MY_PATH/test_data/source_files/workspace_profile_default -export STEAMPIPE_SYNC_REFRESH=true # from GH action env variables export SPIPETOOLS_PG_CONN_STRING=$SPIPETOOLS_PG_CONN_STRING export SPIPETOOLS_TOKEN=$SPIPETOOLS_TOKEN diff --git a/tests/acceptance/test_data/source_files/chaos_conn_import_disabled.spc b/tests/acceptance/test_data/source_files/chaos_conn_import_disabled.spc new file mode 100644 index 0000000000..eb8c39d8db --- /dev/null +++ b/tests/acceptance/test_data/source_files/chaos_conn_import_disabled.spc @@ -0,0 +1,8 @@ +connection "chaos01" { + plugin = "chaos" +} + +connection "chaos02" { + plugin = "chaos" + import_schema = "disabled" +} diff --git a/tests/acceptance/test_files/dynamic_aggregators.bats b/tests/acceptance/test_files/dynamic_aggregators.bats index 6ae4db2335..7d8cba8633 100644 --- a/tests/acceptance/test_files/dynamic_aggregators.bats +++ b/tests/acceptance/test_files/dynamic_aggregators.bats @@ -92,3 +92,7 @@ load "$LIB_BATS_SUPPORT/load.bash" rm -f $STEAMPIPE_INSTALL_DIR/config/dynamic_aggregator_col_type_mismatch_4.spc assert_equal "$output" "$(cat $TEST_DATA_DIR/dynamic_aggregators_col_type_mismatch_4.json)" } + +function setup_file() { + export STEAMPIPE_SYNC_REFRESH=true +} diff --git a/tests/acceptance/test_files/dynamic_schema.bats b/tests/acceptance/test_files/dynamic_schema.bats index 0e579893c2..9eca73667c 100644 --- a/tests/acceptance/test_files/dynamic_schema.bats +++ b/tests/acceptance/test_files/dynamic_schema.bats @@ -92,4 +92,8 @@ function teardown() { # remove the files created as part of these tests rm -f $STEAMPIPE_INSTALL_DIR/config/csv*.spc rm -f output.* -} \ No newline at end of file +} + +function setup_file() { + export STEAMPIPE_SYNC_REFRESH=true +} diff --git a/tests/acceptance/test_files/service_and_plugin.bats b/tests/acceptance/test_files/service_and_plugin.bats index d908a9b8af..277ae99425 100644 --- a/tests/acceptance/test_files/service_and_plugin.bats +++ b/tests/acceptance/test_files/service_and_plugin.bats @@ -262,6 +262,14 @@ load "$LIB_BATS_SUPPORT/load.bash" assert_success } +@test "steampipe plugin list works with disabled connections" { + rm -f $STEAMPIPE_INSTALL_DIR/config/* + cp $SRC_DATA_DIR/chaos_conn_import_disabled.spc $STEAMPIPE_INSTALL_DIR/config/chaos_conn_import_disabled.spc + run steampipe plugin list 2>&3 1>&3 + rm -f $STEAMPIPE_INSTALL_DIR/config/chaos_conn_import_disabled.spc + assert_success +} + ## connection config @test "steampipe aggregator connection wildcard check" { @@ -322,12 +330,14 @@ load "$LIB_BATS_SUPPORT/load.bash" @test "steampipe should return an error for duplicate connection name" { cp $SRC_DATA_DIR/chaos.json $STEAMPIPE_INSTALL_DIR/config/chaos2.json - + cp $SRC_DATA_DIR/chaos.json $STEAMPIPE_INSTALL_DIR/config/chaos3.json + # this should fail because of duplicate connection name run steampipe query "select time_col from chaos.chaos_cache_check" # remove the config file rm -f $STEAMPIPE_INSTALL_DIR/config/chaos2.json + rm -f $STEAMPIPE_INSTALL_DIR/config/chaos3.json assert_output --partial 'duplicate connection name' } @@ -463,3 +473,8 @@ load "$LIB_BATS_SUPPORT/load.bash" run steampipe plugin uninstall steampipe rm -f $STEAMPIPE_INSTALL_DIR/config/steampipe.spc } + +function setup_file() { + export BATS_TEST_TIMEOUT=60 + echo "# setup_file()">&3 +}