aboutsummaryrefslogtreecommitdiffstats
path: root/lib/apiv1/agent.go
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/agent.go
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/agent.go')
-rw-r--r--lib/apiv1/agent.go70
1 files changed, 0 insertions, 70 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)
-}