summaryrefslogtreecommitdiffstats
path: root/lib/apiv1
diff options
context:
space:
mode:
authorSebastien Douheret <sebastien.douheret@iot.bzh>2017-10-06 17:53:51 +0200
committerSebastien Douheret <sebastien.douheret@iot.bzh>2017-11-06 15:57:03 +0100
commit0e72ccd733207877bd8edca55fd6aed0877139e5 (patch)
tree948fd6eebea259c8a09b313427e0112433418d30 /lib/apiv1
parentac9e80f7f32a1c04c171a4d208f0ab7d3a5ca154 (diff)
Cleanup and improvements
- Save server data into file - FolderType is now a string - cleanup useless code Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
Diffstat (limited to 'lib/apiv1')
-rw-r--r--lib/apiv1/agent.go70
-rw-r--r--lib/apiv1/apiv1.go1
-rw-r--r--lib/apiv1/version.go2
3 files changed, 2 insertions, 71 deletions
diff --git a/lib/apiv1/agent.go b/lib/apiv1/agent.go
deleted file mode 100644
index 925f12b..0000000
--- a/lib/apiv1/agent.go
+++ /dev/null
@@ -1,70 +0,0 @@
-package apiv1
-
-import (
- "net/http"
- "path"
- "strings"
-
- "path/filepath"
-
- "github.com/gin-gonic/gin"
- common "github.com/iotbzh/xds-common/golib"
-)
-
-// XDSAgentTarball .
-type XDSAgentTarball struct {
- OS string `json:"os"`
- Arch string `json:"arch"`
- Version string `json:"version"`
- RawVersion string `json:"raw-version"`
- FileURL string `json:"fileUrl"`
-}
-
-// XDSAgentInfo .
-type XDSAgentInfo struct {
- Tarballs []XDSAgentTarball `json:"tarballs"`
-}
-
-// getXdsAgentInfo : return various information about Xds Agent
-func (s *APIService) getXdsAgentInfo(c *gin.Context) {
-
- res := XDSAgentInfo{}
- tarballURL := "assets/xds-agent-tarballs"
- tarballDir := filepath.Join(s.cfg.FileConf.WebAppDir, "assets", "xds-agent-tarballs")
- if common.Exists(tarballDir) {
- files, err := filepath.Glob(path.Join(tarballDir, "xds-agent_*.zip"))
- if err != nil {
- s.log.Debugf("Error while retrieving xds-agent tarballs: dir=%s, error=%v", tarballDir, err)
- }
- for _, ff := range files {
- file := filepath.Base(ff)
- // Assume that tarball name format is: xds-agent_OS-ARCH-RAWVERSION.zip
- fs := strings.TrimSuffix(strings.TrimPrefix(file, "xds-agent_"), ".zip")
- f := strings.Split(fs, "-")
-
- if len(f) >= 3 {
- vers := strings.Split(f[2], "_")
- ver := f[2]
- if len(vers) > 1 {
- ver = vers[0]
- }
-
- newT := XDSAgentTarball{
- OS: f[0],
- Arch: f[1],
- Version: ver,
- RawVersion: f[2],
- FileURL: filepath.Join(tarballURL, file),
- }
-
- s.log.Infof("Added XDS-Agent tarball: %s", file)
- res.Tarballs = append(res.Tarballs, newT)
-
- } else {
- s.log.Debugf("Error while retrieving xds-agent, decoding failure: file:%v", ff)
- }
- }
- }
-
- c.JSON(http.StatusOK, res)
-}
diff --git a/lib/apiv1/apiv1.go b/lib/apiv1/apiv1.go
index 262f513..0a96311 100644
--- a/lib/apiv1/apiv1.go
+++ b/lib/apiv1/apiv1.go
@@ -34,7 +34,6 @@ func New(r *gin.Engine, sess *session.Sessions, cfg *xdsconfig.Config, mfolders
}
s.apiRouter.GET("/version", s.getVersion)
- s.apiRouter.GET("/xdsagent/info", s.getXdsAgentInfo)
s.apiRouter.GET("/config", s.getConfig)
s.apiRouter.POST("/config", s.setConfig)
diff --git a/lib/apiv1/version.go b/lib/apiv1/version.go
index e022441..8f928ec 100644
--- a/lib/apiv1/version.go
+++ b/lib/apiv1/version.go
@@ -7,6 +7,7 @@ import (
)
type version struct {
+ ID string `json:"id"`
Version string `json:"version"`
APIVersion string `json:"apiVersion"`
VersionGitTag string `json:"gitTag"`
@@ -15,6 +16,7 @@ type version struct {
// getInfo : return various information about server
func (s *APIService) getVersion(c *gin.Context) {
response := version{
+ ID: s.cfg.ServerUID,
Version: s.cfg.Version,
APIVersion: s.cfg.APIVersion,
VersionGitTag: s.cfg.VersionGitTag,