X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=lib%2Fapiv1%2Fagent.go;fp=lib%2Fapiv1%2Fagent.go;h=0000000000000000000000000000000000000000;hb=0e72ccd733207877bd8edca55fd6aed0877139e5;hp=925f12ba320b2926bbfeed1a254dc4c933d5f52e;hpb=ac9e80f7f32a1c04c171a4d208f0ab7d3a5ca154;p=src%2Fxds%2Fxds-server.git 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) -}