github.com/turbot/steampipe@v1.7.0-rc.0.0.20240517123944-7cef272d4458/pkg/db/db_local/server_settings.go (about) 1 package db_local 2 3 import ( 4 "context" 5 "log" 6 "time" 7 8 "github.com/jackc/pgx/v5" 9 "github.com/spf13/viper" 10 "github.com/turbot/steampipe/pkg/constants" 11 "github.com/turbot/steampipe/pkg/db/db_common" 12 "github.com/turbot/steampipe/pkg/serversettings" 13 "github.com/turbot/steampipe/pkg/version" 14 ) 15 16 // setupServerSettingsTable creates a new read-only table with information in the current 17 // settings the service has been started with. 18 // 19 // The table also includes the CLI and FDW versions for reference 20 func setupServerSettingsTable(ctx context.Context, conn *pgx.Conn) error { 21 settings := db_common.ServerSettings{ 22 StartTime: time.Now(), 23 SteampipeVersion: version.VersionString, 24 FdwVersion: constants.FdwVersion, 25 CacheMaxTtl: viper.GetInt(constants.ArgCacheMaxTtl), 26 CacheMaxSizeMb: viper.GetInt(constants.ArgMaxCacheSizeMb), 27 CacheEnabled: viper.GetBool(constants.ArgServiceCacheEnabled), 28 } 29 30 queries := []db_common.QueryWithArgs{ 31 serversettings.DropServerSettingsTable(ctx), 32 serversettings.CreateServerSettingsTable(ctx), 33 serversettings.GrantsOnServerSettingsTable(ctx), 34 serversettings.GetPopulateServerSettingsSql(ctx, settings), 35 } 36 37 log.Println("[TRACE] saved server settings:", settings) 38 39 _, err := ExecuteSqlWithArgsInTransaction(ctx, conn, queries...) 40 return err 41 }