X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=lib%2Fxdsconfig%2Ffolderconfig.go;h=bb2b56f8ab8c728382d83e52a4c845025df82ca7;hb=2ad72d9ee3aafb2426b28a86b505da9d24f3e768;hp=e8bff4f548a0988c5a72c3a05cfcd54a62fc5550;hpb=ec7051e1da665206f594c7616ad381bfeaea333a;p=src%2Fxds%2Fxds-server.git diff --git a/lib/xdsconfig/folderconfig.go b/lib/xdsconfig/folderconfig.go index e8bff4f..bb2b56f 100644 --- a/lib/xdsconfig/folderconfig.go +++ b/lib/xdsconfig/folderconfig.go @@ -29,13 +29,14 @@ type FolderConfig struct { SyncThingID string `json:"syncThingID"` BuilderSThgID string `json:"builderSThgID"` Status string `json:"status"` + DefaultSdk string `json:"defaultSdk"` - // Private fields - rootPath string + // Not exported fields + RootPath string `json:"-"` } // NewFolderConfig creates a new folder object -func NewFolderConfig(id, label, rootDir, path string) FolderConfig { +func NewFolderConfig(id, label, rootDir, path string, defaultSdk string) FolderConfig { return FolderConfig{ ID: id, Label: label, @@ -43,7 +44,8 @@ func NewFolderConfig(id, label, rootDir, path string) FolderConfig { Type: FolderTypeCloudSync, SyncThingID: "", Status: FolderStatusDisable, - rootPath: rootDir, + RootPath: rootDir, + DefaultSdk: defaultSdk, } } @@ -53,26 +55,30 @@ func (c *FolderConfig) GetFullPath(dir string) string { dir = "" } if filepath.IsAbs(dir) { - return filepath.Join(c.rootPath, dir) + return filepath.Join(c.RootPath, dir) } - return filepath.Join(c.rootPath, c.RelativePath, dir) + return filepath.Join(c.RootPath, c.RelativePath, dir) } -// FolderVerify is called to verify that a configuration is valid -func FolderVerify(fCfg FolderConfig) error { +// Verify is called to verify that a configuration is valid +func (c *FolderConfig) Verify() error { var err error - if fCfg.Type != FolderTypeCloudSync { + if c.Type != FolderTypeCloudSync { err = fmt.Errorf("Unsupported folder type") } - if fCfg.SyncThingID == "" { + 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 { - fCfg.Status = FolderStatusErrorConfig - log.Printf("ERROR FolderVerify: %v\n", err) + c.Status = FolderStatusErrorConfig + log.Printf("ERROR Verify: %v\n", err) } return err