Add XDS-agent tarball download feature
[src/xds/xds-server.git] / lib / apiv1 / agent.go
1 package apiv1
2
3 import (
4         "net/http"
5
6         "path/filepath"
7
8         "github.com/gin-gonic/gin"
9 )
10
11 type XDSAgentTarball struct {
12         OS      string `json:"os"`
13         FileURL string `json:"fileUrl"`
14 }
15 type XDSAgentInfo struct {
16         Tarballs []XDSAgentTarball `json:"tarballs"`
17 }
18
19 // getXdsAgentInfo : return various information about Xds Agent
20 func (s *APIService) getXdsAgentInfo(c *gin.Context) {
21         // TODO: retrieve link dynamically by reading assets/xds-agent-tarballs
22         tarballDir := "assets/xds-agent-tarballs"
23         response := XDSAgentInfo{
24                 Tarballs: []XDSAgentTarball{
25                         XDSAgentTarball{
26                                 OS:      "linux",
27                                 FileURL: filepath.Join(tarballDir, "xds-agent_linux-amd64-v0.0.1_3cdf92c.zip"),
28                         },
29                         XDSAgentTarball{
30                                 OS:      "windows",
31                                 FileURL: filepath.Join(tarballDir, "xds-agent_windows-386-v0.0.1_3cdf92c.zip"),
32                         },
33                 },
34         }
35
36         c.JSON(http.StatusOK, response)
37 }