summaryrefslogtreecommitdiffstats
path: root/lib/xdsconfig/folderconfig.go
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-08-10 12:19:34 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-08-16 14:27:28 +0200
commitdd6f08b10b1597f44e3dc25509ac9a45336b0914 (patch)
tree3dcb835306bc3adbae7c27d94fc8a51de8d6f09a /lib/xdsconfig/folderconfig.go
parent0262f5bef6ff67e77b844a04733c57740fba9f00 (diff)
Add folder interface and support native pathmap folder type.
Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'lib/xdsconfig/folderconfig.go')
-rw-r--r--lib/xdsconfig/folderconfig.go85
1 files changed, 0 insertions, 85 deletions
diff --git a/lib/xdsconfig/folderconfig.go b/lib/xdsconfig/folderconfig.go
deleted file mode 100644
index bb2b56f..0000000
--- a/lib/xdsconfig/folderconfig.go
+++ /dev/null
@@ -1,85 +0,0 @@
-package xdsconfig
-
-import (
- "fmt"
- "log"
- "path/filepath"
-)
-
-// FolderType constances
-const (
- FolderTypeDocker = 0
- FolderTypeWindowsSubsystem = 1
- FolderTypeCloudSync = 2
-
- FolderStatusErrorConfig = "ErrorConfig"
- FolderStatusDisable = "Disable"
- FolderStatusEnable = "Enable"
-)
-
-// FolderType is the type of sharing folder
-type FolderType int
-
-// FolderConfig is the config for one folder
-type FolderConfig struct {
- ID string `json:"id" binding:"required"`
- Label string `json:"label"`
- RelativePath string `json:"path"`
- Type FolderType `json:"type"`
- SyncThingID string `json:"syncThingID"`
- BuilderSThgID string `json:"builderSThgID"`
- Status string `json:"status"`
- DefaultSdk string `json:"defaultSdk"`
-
- // Not exported fields
- RootPath string `json:"-"`
-}
-
-// NewFolderConfig creates a new folder object
-func NewFolderConfig(id, label, rootDir, path string, defaultSdk string) FolderConfig {
- return FolderConfig{
- ID: id,
- Label: label,
- RelativePath: path,
- Type: FolderTypeCloudSync,
- SyncThingID: "",
- Status: FolderStatusDisable,
- RootPath: rootDir,
- DefaultSdk: defaultSdk,
- }
-}
-
-// GetFullPath returns the full path
-func (c *FolderConfig) GetFullPath(dir string) string {
- if &dir == nil {
- dir = ""
- }
- if filepath.IsAbs(dir) {
- return filepath.Join(c.RootPath, dir)
- }
- return filepath.Join(c.RootPath, c.RelativePath, dir)
-}
-
-// Verify is called to verify that a configuration is valid
-func (c *FolderConfig) Verify() error {
- var err error
-
- if c.Type != FolderTypeCloudSync {
- err = fmt.Errorf("Unsupported folder type")
- }
-
- if c.SyncThingID == "" {
- err = fmt.Errorf("device id not set (SyncThingID field)")
- }
-
- if c.RootPath == "" {
- err = fmt.Errorf("RootPath must not be empty")
- }
-
- if err != nil {
- c.Status = FolderStatusErrorConfig
- log.Printf("ERROR Verify: %v\n", err)
- }
-
- return err
-}