mirror of
https://github.com/netbirdio/netbird.git
synced 2025-06-20 17:58:02 +02:00
Create config dir if using default configPath
This commit is contained in:
parent
41b50a08d4
commit
06c7af058b
@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/wiretrustee/wiretrustee/connection"
|
"github.com/wiretrustee/wiretrustee/connection"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config Configuration type
|
// Config Configuration type
|
||||||
@ -23,6 +24,15 @@ type Config struct {
|
|||||||
|
|
||||||
//Write writes configPath to a file
|
//Write writes configPath to a file
|
||||||
func (cfg *Config) Write(path string) error {
|
func (cfg *Config) Write(path string) error {
|
||||||
|
|
||||||
|
if path == defaultConfigPath {
|
||||||
|
configDir := filepath.Dir(path)
|
||||||
|
err := os.MkdirAll(configDir, 0750)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bs, err := json.Marshal(cfg)
|
bs, err := json.Marshal(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user