Skip to content

Commit

Permalink
fix (test): broken utest
Browse files Browse the repository at this point in the history
  • Loading branch information
mickael-kerjean committed Mar 12, 2024
1 parent 2251070 commit c96dd9f
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions server/common/config_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,22 @@ import (
"os"
)

var configKeysToEncrypt []string = []string{
"middleware.identity_provider.params",
"middleware.attribute_mapping.params",
}
var (
configKeysToEncrypt []string = []string{
"middleware.identity_provider.params",
"middleware.attribute_mapping.params",
}
config_path func() string
)

func configPath() string {
return GetAbsolutePath(CONFIG_PATH, "config.json")
func init() {
config_path = func() string {
return GetAbsolutePath(CONFIG_PATH, "config.json")
}
}

func LoadConfig() ([]byte, error) {
file, err := os.OpenFile(configPath(), os.O_RDONLY, os.ModePerm)
file, err := os.OpenFile(config_path(), os.O_RDONLY, os.ModePerm)
if err != nil {
if os.IsNotExist(err) {
os.MkdirAll(GetAbsolutePath(CONFIG_PATH), os.ModePerm)
Expand Down Expand Up @@ -71,12 +76,12 @@ func LoadConfig() ([]byte, error) {
}

func SaveConfig(v []byte) error {
file, err := os.Create(configPath())
file, err := os.Create(config_path())
if err != nil {
return fmt.Errorf(
"Filestash needs to be able to create/edit its own configuration which it can't at the moment. "+
"Change the permission for filestash to create and edit `%s`",
configPath(),
config_path(),
)
}

Expand Down

0 comments on commit c96dd9f

Please sign in to comment.