diff options
Diffstat (limited to 'lib/apiv1')
-rw-r--r-- | lib/apiv1/agent.go | 70 | ||||
-rw-r--r-- | lib/apiv1/apiv1.go | 1 | ||||
-rw-r--r-- | lib/apiv1/version.go | 2 |
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, |