go: delete pertinent ENVs after loading settings
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
e8ac4e39ce
commit
fc4460d5e1
@ -1,6 +1,8 @@
|
|||||||
package settings
|
package settings
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
|
||||||
"git.dotya.ml/mirre-mt/pcmt/config"
|
"git.dotya.ml/mirre-mt/pcmt/config"
|
||||||
"git.dotya.ml/mirre-mt/pcmt/slogging"
|
"git.dotya.ml/mirre-mt/pcmt/slogging"
|
||||||
"golang.org/x/exp/slog"
|
"golang.org/x/exp/slog"
|
||||||
@ -22,6 +24,14 @@ type Settings struct {
|
|||||||
dbIsSetUp bool
|
dbIsSetUp bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cleantgt is a list of ENV vars pertaining to pcmt.
|
||||||
|
var cleantgt = []string{
|
||||||
|
"PCMT_LIVE",
|
||||||
|
"PCMT_DEVEL",
|
||||||
|
"PCMT_CONNSTRING",
|
||||||
|
"PCMT_DBTYPE",
|
||||||
|
}
|
||||||
|
|
||||||
// New returns a new instance of the settings struct.
|
// New returns a new instance of the settings struct.
|
||||||
func New() *Settings {
|
func New() *Settings {
|
||||||
return &Settings{}
|
return &Settings{}
|
||||||
@ -205,3 +215,15 @@ func (s *Settings) SetDbType(dbType string) {
|
|||||||
func (s *Settings) SetDbIsSetUp(is bool) {
|
func (s *Settings) SetDbIsSetUp(is bool) {
|
||||||
s.dbIsSetUp = is
|
s.dbIsSetUp = is
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EraseENVs attempts to clear environment vars pertaining to pcmt.
|
||||||
|
func (s *Settings) EraseENVs() error {
|
||||||
|
for _, v := range cleantgt {
|
||||||
|
err := os.Unsetenv(v)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user