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