summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.vscode/settings.json12
-rw-r--r--cmd-exec.go16
-rw-r--r--cmd-misc.go4
-rw-r--r--cmd-projects.go22
-rw-r--r--cmd-sdks.go16
-rw-r--r--glide.yaml4
-rw-r--r--main.go2
-rw-r--r--utils.go12
8 files changed, 39 insertions, 49 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json
index d0f7e6d..8427f3c 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -22,15 +22,7 @@
},
// Words to add to dictionary for a workspace.
"cSpell.words": [
- "apiv",
- "iosk",
- "zhouhui",
- "ldflags",
- "socketio",
- "xdsconfig",
- "sdkid",
- "godotenv",
- "crosssdk",
- "prjs"
+ "apiv", "iosk", "zhouhui", "ldflags", "socketio", "xdsconfig", "sdkid",
+ "godotenv", "crosssdk", "prjs", "xaapiv", "urfave"
]
}
diff --git a/cmd-exec.go b/cmd-exec.go
index c02496b..b8d88b5 100644
--- a/cmd-exec.go
+++ b/cmd-exec.go
@@ -5,7 +5,7 @@ import (
"os"
"strings"
- "github.com/iotbzh/xds-agent/lib/apiv1"
+ "github.com/iotbzh/xds-agent/lib/xaapiv1"
"github.com/urfave/cli"
)
@@ -49,7 +49,7 @@ func exec(ctx *cli.Context) error {
Log.Infof("Execute: /exec %v", argsCommand)
// Log useful info for debugging
- ver := apiv1.XDSVersion{}
+ ver := xaapiv1.XDSVersion{}
XdsVersionGet(&ver)
Log.Infof("XDS version: %v", ver)
@@ -78,25 +78,25 @@ func exec(ctx *cli.Context) error {
}
}
- IOsk.On(apiv1.ExecOutEvent, func(ev apiv1.ExecOutMsg) {
+ IOsk.On(xaapiv1.ExecOutEvent, func(ev xaapiv1.ExecOutMsg) {
outFunc(ev.Timestamp, ev.Stdout, ev.Stderr)
})
- IOsk.On(apiv1.ExecExitEvent, func(ev apiv1.ExecExitMsg) {
+ IOsk.On(xaapiv1.ExecExitEvent, func(ev xaapiv1.ExecExitMsg) {
exitChan <- exitResult{ev.Error, ev.Code}
})
- IOsk.On(apiv1.EVTProjectChange, func(ev apiv1.EventMsg) {
+ IOsk.On(xaapiv1.EVTProjectChange, func(ev xaapiv1.EventMsg) {
prj, _ := ev.DecodeProjectConfig()
Log.Infof("Event %v (%v): %v", ev.Type, ev.Time, prj)
})
- evReg := apiv1.EventRegisterArgs{Name: apiv1.EVTProjectChange}
+ evReg := xaapiv1.EventRegisterArgs{Name: xaapiv1.EVTProjectChange}
if err := HTTPCli.Post("/events/register", &evReg, nil); err != nil {
return cli.NewExitError(err, 1)
}
// Retrieve the project definition
- prj := apiv1.ProjectConfig{}
+ prj := xaapiv1.ProjectConfig{}
if err := HTTPCli.Get("/projects/"+prjID, &prj); err != nil {
return cli.NewExitError(err, 1)
}
@@ -125,7 +125,7 @@ func exec(ctx *cli.Context) error {
}
// Send build command
- args := apiv1.ExecArgs{
+ args := xaapiv1.ExecArgs{
ID: prjID,
SdkID: sdkid,
Cmd: strings.Trim(argsCommand[0], " "),
diff --git a/cmd-misc.go b/cmd-misc.go
index b4b579d..1a5d6d4 100644
--- a/cmd-misc.go
+++ b/cmd-misc.go
@@ -3,7 +3,7 @@ package main
import (
"fmt"
- "github.com/iotbzh/xds-agent/lib/apiv1"
+ "github.com/iotbzh/xds-agent/lib/xaapiv1"
"github.com/urfave/cli"
)
@@ -33,7 +33,7 @@ func xdsVersion(ctx *cli.Context) error {
verbose := ctx.Bool("verbose")
// Get version
- ver := apiv1.XDSVersion{}
+ ver := xaapiv1.XDSVersion{}
if err := XdsVersionGet(&ver); err != nil {
return cli.NewExitError(err.Error(), 1)
}
diff --git a/cmd-projects.go b/cmd-projects.go
index 23e75c5..e244e41 100644
--- a/cmd-projects.go
+++ b/cmd-projects.go
@@ -4,7 +4,7 @@ import (
"fmt"
"strings"
- "github.com/iotbzh/xds-agent/lib/apiv1"
+ "github.com/iotbzh/xds-agent/lib/xaapiv1"
"github.com/urfave/cli"
)
@@ -92,7 +92,7 @@ func initCmdProjects(cmdDef *[]cli.Command) {
func projectsList(ctx *cli.Context) error {
// Get projects list
- prjs := []apiv1.ProjectConfig{}
+ prjs := []xaapiv1.ProjectConfig{}
if err := ProjectsListGet(&prjs); err != nil {
return cli.NewExitError(err.Error(), 1)
}
@@ -105,7 +105,7 @@ func projectsGet(ctx *cli.Context) error {
if id == "" {
return cli.NewExitError("id parameter or option must be set", 1)
}
- prjs := make([]apiv1.ProjectConfig, 1)
+ prjs := make([]xaapiv1.ProjectConfig, 1)
if err := HTTPCli.Get("/projects/"+id, &prjs[0]); err != nil {
return cli.NewExitError(err, 1)
}
@@ -113,7 +113,7 @@ func projectsGet(ctx *cli.Context) error {
return nil
}
-func _displayProjects(prjs []apiv1.ProjectConfig, verbose bool) {
+func _displayProjects(prjs []xaapiv1.ProjectConfig, verbose bool) {
// Display result
first := true
writer := NewTableWriter()
@@ -126,7 +126,7 @@ func _displayProjects(prjs []apiv1.ProjectConfig, verbose bool) {
fmt.Fprintln(writer, "Label:\t", folder.Label)
fmt.Fprintln(writer, "Path type:\t", folder.Type)
fmt.Fprintln(writer, "Local Path:\t", folder.ClientPath)
- if folder.Type != apiv1.TypeCloudSync {
+ if folder.Type != xaapiv1.TypeCloudSync {
fmt.Fprintln(writer, "Server Path:\t", folder.ServerPath)
}
fmt.Fprintln(writer, "Status:\t", folder.Status)
@@ -151,17 +151,17 @@ func _displayProjects(prjs []apiv1.ProjectConfig, verbose bool) {
func projectsAdd(ctx *cli.Context) error {
// Decode project type
- var ptype apiv1.ProjectType
+ var ptype xaapiv1.ProjectType
switch strings.ToLower(ctx.String("type")) {
case "pathmap", "pm":
- ptype = apiv1.TypePathMap
+ ptype = xaapiv1.TypePathMap
case "cloudsync", "cs":
- ptype = apiv1.TypeCloudSync
+ ptype = xaapiv1.TypeCloudSync
default:
return cli.NewExitError("Unknown project type", 1)
}
- prj := apiv1.ProjectConfig{
+ prj := xaapiv1.ProjectConfig{
ServerID: XdsServerIDGet(),
Label: ctx.String("label"),
Type: ptype,
@@ -170,7 +170,7 @@ func projectsAdd(ctx *cli.Context) error {
}
Log.Infof("POST /project %v", prj)
- newPrj := apiv1.ProjectConfig{}
+ newPrj := xaapiv1.ProjectConfig{}
err := HTTPCli.Post("/projects", prj, &newPrj)
if err != nil {
return cli.NewExitError(err, 1)
@@ -182,7 +182,7 @@ func projectsAdd(ctx *cli.Context) error {
}
func projectsRemove(ctx *cli.Context) error {
- var res apiv1.ProjectConfig
+ var res xaapiv1.ProjectConfig
id := GetID(ctx)
if id == "" {
return cli.NewExitError("id parameter or option must be set", 1)
diff --git a/cmd-sdks.go b/cmd-sdks.go
index 8568b3a..af6c417 100644
--- a/cmd-sdks.go
+++ b/cmd-sdks.go
@@ -4,7 +4,7 @@ import (
"fmt"
"strconv"
- "github.com/iotbzh/xds-agent/lib/apiv1"
+ "github.com/iotbzh/xds-agent/lib/xaapiv1"
"github.com/urfave/cli"
)
@@ -62,7 +62,7 @@ func initCmdSdks(cmdDef *[]cli.Command) {
func sdksList(ctx *cli.Context) error {
// Get SDKs list
- sdks := []apiv1.SDK{}
+ sdks := []xaapiv1.SDK{}
if err := sdksListGet(&sdks); err != nil {
return cli.NewExitError(err.Error(), 1)
}
@@ -75,16 +75,16 @@ func sdksGet(ctx *cli.Context) error {
if id == "" {
return cli.NewExitError("id parameter or option must be set", 1)
}
- sdks := apiv1.SDK{}
- url := "server/" + strconv.Itoa(XdsServerIndexGet()) + "/sdks/" + id
+ sdks := xaapiv1.SDK{}
+ url := "servers/" + strconv.Itoa(XdsServerIndexGet()) + "/sdks/" + id
if err := HTTPCli.Get(url, &sdks); err != nil {
return cli.NewExitError(err.Error(), 1)
}
- _displaySdks([]apiv1.SDK{sdks}, true)
+ _displaySdks([]xaapiv1.SDK{sdks}, true)
return nil
}
-func _displaySdks(sdks []apiv1.SDK, verbose bool) {
+func _displaySdks(sdks []xaapiv1.SDK, verbose bool) {
// Display result
first := true
writer := NewTableWriter()
@@ -112,8 +112,8 @@ func _displaySdks(sdks []apiv1.SDK, verbose bool) {
writer.Flush()
}
-func sdksListGet(sdks *[]apiv1.SDK) error {
- url := "server/" + strconv.Itoa(XdsServerIndexGet()) + "/sdks"
+func sdksListGet(sdks *[]xaapiv1.SDK) error {
+ url := "servers/" + strconv.Itoa(XdsServerIndexGet()) + "/sdks"
if err := HTTPCli.Get(url, &sdks); err != nil {
return err
}
diff --git a/glide.yaml b/glide.yaml
index bc1a3f0..830ac5d 100644
--- a/glide.yaml
+++ b/glide.yaml
@@ -12,9 +12,9 @@ import:
- package: github.com/sebd71/go-socket.io-client
version: 46defcb47f
- package: github.com/iotbzh/xds-agent
- version: 4e9af3723740f16f
+ version: v1.0.0-rc1
subpackages:
- - agent
+ - lib/xaapiv1
- package: github.com/iotbzh/xds-common
version: ^0.1.0
subpackages:
diff --git a/main.go b/main.go
index b7f110e..1c75e50 100644
--- a/main.go
+++ b/main.go
@@ -64,8 +64,6 @@ func exitError(code int, f string, a ...interface{}) {
func main() {
var earlyDebug []string
- EnvConfFileMap := make(map[string]string)
-
// Allow to set app name from cli (useful for debugging)
if AppName == "" {
AppName = os.Getenv("XDS_APPNAME")
diff --git a/utils.go b/utils.go
index 6a05ef3..b21fc19 100644
--- a/utils.go
+++ b/utils.go
@@ -3,21 +3,21 @@ package main
import (
"encoding/json"
- "github.com/iotbzh/xds-agent/lib/apiv1"
+ "github.com/iotbzh/xds-agent/lib/xaapiv1"
"github.com/urfave/cli"
)
-var cacheXdsVersion *apiv1.XDSVersion
+var cacheXdsVersion *xaapiv1.XDSVersion
// XdsVersionGet Get version of XDS agent & server
-func XdsVersionGet(ver *apiv1.XDSVersion) error {
+func XdsVersionGet(ver *xaapiv1.XDSVersion) error {
// Use cached data
if cacheXdsVersion != nil {
ver = cacheXdsVersion
return nil
}
- dataVer := apiv1.XDSVersion{}
+ dataVer := xaapiv1.XDSVersion{}
if err := HTTPCli.Get("/version", &dataVer); err != nil {
return err
}
@@ -29,7 +29,7 @@ func XdsVersionGet(ver *apiv1.XDSVersion) error {
// XdsServerIDGet returns the XDS Server ID
func XdsServerIDGet() string {
- ver := apiv1.XDSVersion{}
+ ver := xaapiv1.XDSVersion{}
if err := XdsVersionGet(&ver); err != nil {
return ""
}
@@ -46,7 +46,7 @@ func XdsServerIndexGet() int {
}
// ProjectsListGet Get the list of existing projects
-func ProjectsListGet(prjs *[]apiv1.ProjectConfig) error {
+func ProjectsListGet(prjs *[]xaapiv1.ProjectConfig) error {
var data []byte
if err := HTTPCli.HTTPGet("/projects", &data); err != nil {
return err