diff --git a/examples/demo/env.in b/examples/demo/env.in new file mode 100644 index 0000000..e3d284e --- /dev/null +++ b/examples/demo/env.in @@ -0,0 +1,9 @@ +# env.in - input (example file) for .env file + +SCOPES_LOGLEVEL=debug +#SCOPES_LOGLEVEL=warn +SCOPES_SERVER_PORT=8123 +SCOPES_DOCROOT=~/html/public + +SCOPES_SQLITE_CONNSTR=data/scopes.sqlite +SCOPES_PGSQL_CONNSTR="user=testuser password=secret dbname=testdb" diff --git a/examples/demo/etc/etc.go b/examples/demo/etc/etc.go index f9e0296..5355692 100644 --- a/examples/demo/etc/etc.go +++ b/examples/demo/etc/etc.go @@ -44,7 +44,8 @@ func Config() lib.Config { } // collect here the names of fields that may be overridden via -// explicit Override() or SCOPES_* environment settings. +// explicit Overrides() or SCOPES_* environment settings +// (via .env or explicit setting of environment variables). const ( HOME = "home" LOGFILE = "logfile" @@ -53,11 +54,3 @@ const ( DOCROOT = "docroot" PGSQL_CONNSTR = "pgsql_connstr" ) - -// put something like this (without comment markup) -// in separate (non-versioned) settings.go file: -/*func Overrides() config.Settings { - return config.Settings{ - SERVER_PORT: "8126", - } -}*/ diff --git a/tests/etc/etc.go b/tests/etc/etc.go index c785e50..e3349ff 100644 --- a/tests/etc/etc.go +++ b/tests/etc/etc.go @@ -13,7 +13,6 @@ import ( ) func Config() lib.Config { - //ovr := Overrides().Use ovr := config.Overrides("env-test").Use b := config.Base @@ -54,7 +53,8 @@ var ( ) // collect here the names of fields that may be overridden via -// explicit Override() or SCOPES_* environment settings. +// explicit Overrides() or SCOPES_* environment settings +// (via .env or explicit setting of environment variables). const ( HOME = "home" LOGFILE = "logfile" @@ -62,12 +62,3 @@ const ( SERVER_PORT = "server_port" SERVER_URL = "server_url" ) - -// in a production scenario this should be put in a separate -// file `settings.go` that should not be stored in code repository. -func Overrides() config.Settings { - return config.Settings{ - //HOME: "tests", - LOGLEVEL: "debug", - } -} diff --git a/tests/etc/etc_sql.go b/tests/etc/etc_sql.go index f34fc7d..0db77da 100644 --- a/tests/etc/etc_sql.go +++ b/tests/etc/etc_sql.go @@ -6,7 +6,7 @@ import ( ) func ConfigSqlite() *sql.Cfg { - ovr := OverridesSql().Use + ovr := config.Overrides("env-test").Use return &sql.Cfg{ Driver: "sqlite", Connstr: ovr("somefile.sqlite", SQLITE_CONNSTR), @@ -14,7 +14,6 @@ func ConfigSqlite() *sql.Cfg { } func ConfigPgsql() *sql.Cfg { - //ovr := OverridesSql().Use ovr := config.Overrides("env-test").Use return &sql.Cfg{ Driver: "postgres", @@ -24,19 +23,10 @@ func ConfigPgsql() *sql.Cfg { } // collect here the names of fields that may be overridden via -// explicit Override() or SCOPES_* environment settings. +// explicit Overrides() or SCOPES_* environment settings +// (via .env or explicit setting of environment variables). const ( SQLITE_CONNSTR = "sqlite_connstr" PGSQL_CONNSTR = "pgsql_connstr" PGSQL_SCHEMA = "pgsql_schema" ) - -// in a production scenario this should be put in a separate -// file `settings.go` that should not be stored in code repository. -func OverridesSql() config.Settings { - return config.Settings{ - //SQLITE_CONNSTR: ":memory", - SQLITE_CONNSTR: "data/scopes.sqlite", - PGSQL_CONNSTR: "user=ccotest password=cco dbname=scpstest", - } -}