X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=lib%2Fxdsserver%2Ffolder-pathmap.go;fp=lib%2Ffolder%2Ffolder-pathmap.go;h=c5318de68e53a8d4b4bc95692e8cebfb93daebbd;hb=2f7828d01f4c4ca2909f95f098627cd5475ed225;hp=c5691a337f1e860c5401400b8e0ca6212c59b8f7;hpb=5caebfb4b7c3b73988f067082b219ce5b7f409ba;p=src%2Fxds%2Fxds-server.git diff --git a/lib/folder/folder-pathmap.go b/lib/xdsserver/folder-pathmap.go similarity index 84% rename from lib/folder/folder-pathmap.go rename to lib/xdsserver/folder-pathmap.go index c5691a3..c5318de 100644 --- a/lib/folder/folder-pathmap.go +++ b/lib/xdsserver/folder-pathmap.go @@ -1,4 +1,4 @@ -package folder +package xdsserver import ( "fmt" @@ -8,7 +8,7 @@ import ( "strings" common "github.com/iotbzh/xds-common/golib" - "github.com/iotbzh/xds-server/lib/xdsconfig" + "github.com/iotbzh/xds-server/lib/xsapiv1" uuid "github.com/satori/go.uuid" ) @@ -16,16 +16,16 @@ import ( // PathMap . type PathMap struct { - globalConfig *xdsconfig.Config - config FolderConfig + *Context + config xsapiv1.FolderConfig } // NewFolderPathMap Create a new instance of PathMap -func NewFolderPathMap(gc *xdsconfig.Config) *PathMap { +func NewFolderPathMap(ctx *Context) *PathMap { f := PathMap{ - globalConfig: gc, - config: FolderConfig{ - Status: StatusDisable, + Context: ctx, + config: xsapiv1.FolderConfig{ + Status: xsapiv1.StatusDisable, }, } return &f @@ -41,7 +41,7 @@ func (f *PathMap) NewUID(suffix string) string { } // Add a new folder -func (f *PathMap) Add(cfg FolderConfig) (*FolderConfig, error) { +func (f *PathMap) Add(cfg xsapiv1.FolderConfig) (*xsapiv1.FolderConfig, error) { if cfg.DataPathMap.ServerPath == "" { return nil, fmt.Errorf("ServerPath must be set") } @@ -49,7 +49,7 @@ func (f *PathMap) Add(cfg FolderConfig) (*FolderConfig, error) { // Use shareRootDir if ServerPath is a relative path dir := cfg.DataPathMap.ServerPath if !filepath.IsAbs(dir) { - dir = filepath.Join(f.globalConfig.FileConf.ShareRootDir, dir) + dir = filepath.Join(f.Config.FileConf.ShareRootDir, dir) } // Sanity check @@ -92,20 +92,20 @@ func (f *PathMap) Add(cfg FolderConfig) (*FolderConfig, error) { } // Write a specific message that will be check back on agent side - msg := "Pathmap checked message written by xds-server ID: " + f.globalConfig.ServerUID + "\n" + msg := "Pathmap checked message written by xds-server ID: " + f.Config.ServerUID + "\n" if n, err := fd.WriteString(msg); n != len(msg) || err != nil { return nil, fmt.Errorf(errMsg, 5, err) } } } - f.config.Status = StatusEnable + f.config.Status = xsapiv1.StatusEnable return &f.config, nil } // GetConfig Get public part of folder config -func (f *PathMap) GetConfig() FolderConfig { +func (f *PathMap) GetConfig() xsapiv1.FolderConfig { return f.config } @@ -146,7 +146,7 @@ func (f *PathMap) Remove() error { } // Update update some fields of a folder -func (f *PathMap) Update(cfg FolderConfig) (*FolderConfig, error) { +func (f *PathMap) Update(cfg xsapiv1.FolderConfig) (*xsapiv1.FolderConfig, error) { if f.config.ID != cfg.ID { return nil, fmt.Errorf("Invalid id") } @@ -155,7 +155,7 @@ func (f *PathMap) Update(cfg FolderConfig) (*FolderConfig, error) { } // RegisterEventChange requests registration for folder change event -func (f *PathMap) RegisterEventChange(cb *EventCB, data *EventCBData) error { +func (f *PathMap) RegisterEventChange(cb *FolderEventCB, data *FolderEventCBData) error { return nil }