Code Review
/
src
/
xds
/
xds-server.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Refit source files to have a public xs-apiv1 lib package.
[src/xds/xds-server.git]
/
lib
/
xdsserver
/
folder-pathmap.go
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
(file)
--- a/
lib/folder/folder-pathmap.go
+++ b/
lib/xdsserver/folder-pathmap.go
@@
-1,4
+1,4
@@
-package
fold
er
+package
xdsserv
er
import (
"fmt"
import (
"fmt"
@@
-8,7
+8,7
@@
import (
"strings"
common "github.com/iotbzh/xds-common/golib"
"strings"
common "github.com/iotbzh/xds-common/golib"
- "github.com/iotbzh/xds-server/lib/x
dsconfig
"
+ "github.com/iotbzh/xds-server/lib/x
sapiv1
"
uuid "github.com/satori/go.uuid"
)
uuid "github.com/satori/go.uuid"
)
@@
-16,16
+16,16
@@
import (
// PathMap .
type PathMap struct {
// PathMap .
type PathMap struct {
- globalConfig *xdsconfig.Config
- config
FolderConfig
+ *Context
+ config
xsapiv1.
FolderConfig
}
// NewFolderPathMap Create a new instance of PathMap
}
// NewFolderPathMap Create a new instance of PathMap
-func NewFolderPathMap(
gc *xdsconfig.Config
) *PathMap {
+func NewFolderPathMap(
ctx *Context
) *PathMap {
f := PathMap{
f := PathMap{
-
globalConfig: gc
,
- config: FolderConfig{
- Status: StatusDisable,
+
Context: ctx
,
+ config:
xsapiv1.
FolderConfig{
+ Status:
xsapiv1.
StatusDisable,
},
}
return &f
},
}
return &f
@@
-41,7
+41,7
@@
func (f *PathMap) NewUID(suffix string) string {
}
// Add a new folder
}
// 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")
}
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) {
// Use shareRootDir if ServerPath is a relative path
dir := cfg.DataPathMap.ServerPath
if !filepath.IsAbs(dir) {
- dir = filepath.Join(f.
global
Config.FileConf.ShareRootDir, dir)
+ dir = filepath.Join(f.Config.FileConf.ShareRootDir, dir)
}
// Sanity check
}
// 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
}
// Write a specific message that will be check back on agent side
- msg := "Pathmap checked message written by xds-server ID: " + f.
global
Config.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)
}
}
}
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
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
}
return f.config
}
@@
-146,7
+146,7
@@
func (f *PathMap) Remove() error {
}
// Update update some fields of a folder
}
// 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")
}
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
}
// RegisterEventChange requests registration for folder change event
-func (f *PathMap) RegisterEventChange(cb *
EventCB, data *
EventCBData) error {
+func (f *PathMap) RegisterEventChange(cb *
FolderEventCB, data *Folder
EventCBData) error {
return nil
}
return nil
}