diff --git a/pkg/assets/assets.go b/pkg/assets/assets.go index f17785a6ef..92f2d7e585 100644 --- a/pkg/assets/assets.go +++ b/pkg/assets/assets.go @@ -3,7 +3,7 @@ package assets import ( "net/http" "os" - "path" + "path/filepath" "github.com/owncloud/ocis-pkg/v2/log" "github.com/owncloud/ocis-settings/pkg/config" @@ -27,7 +27,7 @@ type assets struct { func (a assets) Open(original string) (http.File, error) { if a.config.Asset.Path != "" { if stat, err := os.Stat(a.config.Asset.Path); err == nil && stat.IsDir() { - custom := path.Join( + custom := filepath.Join( a.config.Asset.Path, original, ) diff --git a/pkg/config/config.go b/pkg/config/config.go index 2479925efa..dd18bcc232 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -44,7 +44,7 @@ type Asset struct { // Storage defines the available storage configuration. type Storage struct { - RootMountPath string + DataPath string } // TokenManager is the config for using the reva token manager diff --git a/pkg/flagset/flagset.go b/pkg/flagset/flagset.go index ed14961b00..9b77e8418b 100644 --- a/pkg/flagset/flagset.go +++ b/pkg/flagset/flagset.go @@ -158,10 +158,11 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag { Destination: &cfg.GRPC.Namespace, }, &cli.StringFlag{ - Name: "mount-path", + Name: "data-path", + Value: "/var/tmp/ocis-settings", Usage: "Mount path for the storage", - EnvVars: []string{"SETTINGS_ROOT_MOUNT_PATH"}, - Destination: &cfg.Storage.RootMountPath, + EnvVars: []string{"SETTINGS_DATA_PATH"}, + Destination: &cfg.Storage.DataPath, }, &cli.StringFlag{ Name: "jwt-secret", diff --git a/pkg/store/filesystem/paths.go b/pkg/store/filesystem/paths.go index a2fcd8d231..e7840a1d56 100644 --- a/pkg/store/filesystem/paths.go +++ b/pkg/store/filesystem/paths.go @@ -10,7 +10,7 @@ const folderNameValues = "values" // buildFolderPathForBundles builds the folder path for storing settings bundles. If mkdir is true, folders in the path will be created if necessary. func (s Store) buildFolderPathForBundles(mkdir bool) string { - folderPath := filepath.Join(s.mountPath, folderNameBundles) + folderPath := filepath.Join(s.dataPath, folderNameBundles) if mkdir { s.ensureFolderExists(folderPath) } @@ -25,7 +25,7 @@ func (s Store) buildFilePathForBundle(bundleID string, mkdir bool) string { // buildFolderPathForValues builds the folder path for storing settings values. If mkdir is true, folders in the path will be created if necessary. func (s Store) buildFolderPathForValues(mkdir bool) string { - folderPath := filepath.Join(s.mountPath, folderNameValues) + folderPath := filepath.Join(s.dataPath, folderNameValues) if mkdir { s.ensureFolderExists(folderPath) } diff --git a/pkg/store/filesystem/store.go b/pkg/store/filesystem/store.go index 398ea3910d..8e0e2e1058 100644 --- a/pkg/store/filesystem/store.go +++ b/pkg/store/filesystem/store.go @@ -3,7 +3,6 @@ package store import ( "os" - "path" olog "github.com/owncloud/ocis-pkg/v2/log" "github.com/owncloud/ocis-settings/pkg/config" @@ -18,8 +17,8 @@ var ( // Store interacts with the filesystem to manage settings information type Store struct { - mountPath string - Logger olog.Logger + dataPath string + Logger olog.Logger } // New creates a new store @@ -32,16 +31,16 @@ func New(cfg *config.Config) settings.Manager { ), } - dest := path.Join(cfg.Storage.RootMountPath, Name) - if _, err := os.Stat(dest); err != nil { - s.Logger.Info().Msgf("creating container on %v", dest) - err := os.MkdirAll(dest, 0700) + if _, err := os.Stat(cfg.Storage.DataPath); err != nil { + s.Logger.Info().Msgf("creating container on %v", cfg.Storage.DataPath) + err := os.MkdirAll(cfg.Storage.DataPath, 0700) + if err != nil { - s.Logger.Err(err).Msgf("providing container on %v", dest) + s.Logger.Err(err).Msgf("providing container on %v", cfg.Storage.DataPath) } } - s.mountPath = dest + s.dataPath = cfg.Storage.DataPath return &s }