10 "github.com/gin-gonic/gin"
11 common "github.com/iotbzh/xds-common/golib"
15 type XDSAgentTarball struct {
17 Arch string `json:"arch"`
18 Version string `json:"version"`
19 RawVersion string `json:"raw-version"`
20 FileURL string `json:"fileUrl"`
24 type XDSAgentInfo struct {
25 Tarballs []XDSAgentTarball `json:"tarballs"`
28 // getXdsAgentInfo : return various information about Xds Agent
29 func (s *APIService) getXdsAgentInfo(c *gin.Context) {
32 tarballURL := "assets/xds-agent-tarballs"
33 tarballDir := filepath.Join(s.cfg.FileConf.WebAppDir, "assets", "xds-agent-tarballs")
34 if common.Exists(tarballDir) {
35 files, err := filepath.Glob(path.Join(tarballDir, "xds-agent_*.zip"))
37 s.log.Debugf("Error while retrieving xds-agent tarballs: dir=%s, error=%v", tarballDir, err)
39 for _, ff := range files {
40 file := filepath.Base(ff)
41 // Assume that tarball name format is: xds-agent_OS-ARCH-RAWVERSION.zip
42 fs := strings.TrimSuffix(strings.TrimPrefix(file, "xds-agent_"), ".zip")
43 f := strings.Split(fs, "-")
46 vers := strings.Split(f[2], "_")
52 newT := XDSAgentTarball{
57 FileURL: filepath.Join(tarballURL, file),
60 s.log.Infof("Added XDS-Agent tarball: %s", file)
61 res.Tarballs = append(res.Tarballs, newT)
64 s.log.Debugf("Error while retrieving xds-agent, decoding failure: file:%v", ff)
69 c.JSON(http.StatusOK, res)