mirror of
https://github.com/turbot/steampipe.git
synced 2026-03-02 11:02:13 -05:00
All boolean properties in options files should be of type bool, rather than truthy strings. Remove unused argument background #313
This commit is contained in:
@@ -52,7 +52,6 @@ connection from any Postgres compatible database client.`,
|
||||
|
||||
cmdconfig.
|
||||
OnCmd(cmd).
|
||||
AddBoolFlag(constants.ArgBackground, "", true, "Run service in the background").
|
||||
// for now default port to -1 so we fall back to the default of the deprecated arg
|
||||
AddIntFlag(constants.ArgPort, "", constants.DatabaseDefaultPort, "Database service port.").
|
||||
AddIntFlag(constants.ArgPortDeprecated, "", constants.DatabaseDefaultPort, "Database service port.", cmdconfig.FlagOptions.Deprecated(constants.ArgPort)).
|
||||
|
||||
@@ -12,7 +12,6 @@ const (
|
||||
ArgTimer = "timing"
|
||||
ArgOn = "on"
|
||||
ArgOff = "off"
|
||||
ArgBackground = "background"
|
||||
ArgPortDeprecated = "db-port"
|
||||
ArgPort = "database-port"
|
||||
ArgListenAddressDeprecated = "listen"
|
||||
|
||||
@@ -2,22 +2,25 @@ package constants
|
||||
|
||||
const DefaultSPCContent = `
|
||||
# options "connection" {
|
||||
# cache = "on" # on, off
|
||||
# cache = true # true, false
|
||||
# cache_ttl = 300 # int = time in seconds
|
||||
# }
|
||||
|
||||
# options "database" {
|
||||
# port = 9193
|
||||
# listen = "local"
|
||||
# }
|
||||
|
||||
# options "terminal" {
|
||||
# header = "off" # on, off
|
||||
# multi = "off" # on, off
|
||||
# multi = false # true, false
|
||||
# output = "table" # json, csv, table, line
|
||||
# header = false # true, false
|
||||
# separator = "," # any single char
|
||||
# timing = "off" # on, off
|
||||
# timing = false # true, false
|
||||
# }
|
||||
|
||||
# options "general" {
|
||||
# update_check = "on" # on, off
|
||||
# update_check = true # true, false
|
||||
# }
|
||||
|
||||
`
|
||||
|
||||
@@ -1,21 +1,9 @@
|
||||
package options
|
||||
|
||||
import "github.com/turbot/go-kit/types"
|
||||
|
||||
// options.Connection
|
||||
type Connection struct {
|
||||
// string containing a bool - supports true/false/off/on etc
|
||||
CacheBoolString *string `hcl:"cache"`
|
||||
CacheTTL *int `hcl:"cache_ttl"`
|
||||
|
||||
// fields which we populate by converting the parsed values
|
||||
Cache *bool
|
||||
}
|
||||
|
||||
// Populate :: convert strings representing bool values into bool pointers
|
||||
func (c *Connection) Populate() {
|
||||
// convert CacheBoolString to a bool ptr
|
||||
c.Cache = types.ToBoolPtr(c.CacheBoolString)
|
||||
Cache *bool `hcl:"cache"`
|
||||
CacheTTL *int `hcl:"cache_ttl"`
|
||||
}
|
||||
|
||||
func (c *Connection) ConfigMap() map[string]interface{} {
|
||||
|
||||
@@ -8,9 +8,6 @@ type Database struct {
|
||||
Listen *string `hcl:"listen"`
|
||||
}
|
||||
|
||||
// Populate :: nothing to do
|
||||
func (d Database) Populate() {}
|
||||
|
||||
// ConfigMap :: create a config map to pass to viper
|
||||
func (c *Database) ConfigMap() map[string]interface{} {
|
||||
// only add keys which are non null
|
||||
|
||||
@@ -8,9 +8,6 @@ type General struct {
|
||||
UpdateCheck *string `hcl:"update_check"`
|
||||
}
|
||||
|
||||
// Populate :: nothing to do
|
||||
func (d General) Populate() {}
|
||||
|
||||
// ConfigMap :: create a config map to pass to viper
|
||||
func (c General) ConfigMap() map[string]interface{} {
|
||||
// only add keys which are non null
|
||||
|
||||
@@ -9,9 +9,6 @@ const (
|
||||
)
|
||||
|
||||
type Options interface {
|
||||
// once we have parsed the hcl, we may need to convert the parsed values
|
||||
// - for example we accept true/false/on/off for bool values - convert these to bool
|
||||
Populate()
|
||||
// map of config keys to values - used to populate viper
|
||||
ConfigMap() map[string]interface{}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package options
|
||||
|
||||
import (
|
||||
"github.com/turbot/go-kit/types"
|
||||
"github.com/turbot/steampipe/constants"
|
||||
)
|
||||
|
||||
@@ -9,22 +8,9 @@ import (
|
||||
type Terminal struct {
|
||||
Output *string `hcl:"output"`
|
||||
Separator *string `hcl:"separator"`
|
||||
// strings containing a bool - supports true/false/off/on etc
|
||||
HeaderBoolString *string `hcl:"header"`
|
||||
MultiBoolString *string `hcl:"multi"`
|
||||
TimingBoolString *string `hcl:"timing"`
|
||||
|
||||
// fields which we populate by converting the parsed values
|
||||
Header *bool
|
||||
Multi *bool
|
||||
Timing *bool
|
||||
}
|
||||
|
||||
// Populate :: convert strings representing bool values into bool pointers
|
||||
func (c *Terminal) Populate() {
|
||||
c.Header = types.ToBoolPtr(c.HeaderBoolString)
|
||||
c.Multi = types.ToBoolPtr(c.MultiBoolString)
|
||||
c.Timing = types.ToBoolPtr(c.TimingBoolString)
|
||||
Header *bool `hcl:"header"`
|
||||
Multi *bool `hcl:"multi"`
|
||||
Timing *bool `hcl:"timing"`
|
||||
}
|
||||
|
||||
// ConfigMap :: create a config map to pass to viper
|
||||
|
||||
@@ -129,8 +129,6 @@ func parseOptions(block *hcl.Block) (options.Options, hcl.Diagnostics) {
|
||||
return nil, diags
|
||||
}
|
||||
|
||||
// now call the options.Populate to convert bool string fields into actual bools
|
||||
dest.Populate()
|
||||
return dest, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user