Skip to content

Commit 6bdb41f

Browse files
authored
Merge pull request #1149 from zebrunner/#1142
Add support of *-debug browser images
2 parents 445283a + b1f2ee2 commit 6bdb41f

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

capabilities/parsing.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ func init() {
9090
ValueProcessor: addArg("remote-allow-origins", "--remote-allow-origins=*"),
9191
},
9292
"browserVersion": {
93+
ValueProcessor: func(value interface{}) interface{} {
94+
// debug browser images tags should be like 125.0-debug
95+
if v, ok := value.(string); ok {
96+
return strings.TrimSuffix(v, "-debug")
97+
}
98+
return value
99+
},
93100
DeleteCapabilityProcessor: func(value interface{}) bool {
94101
if version, ok := value.(string); ok {
95102
version = strings.ToLower(version)

handlers/definitions.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package handlers
22

33
import (
44
"net/http"
5-
"strings"
65
"time"
76

87
"github.com/gin-gonic/gin"
@@ -42,10 +41,6 @@ func GetImages(c *gin.Context) {
4241

4342
imagesDataResponse := make([]imageDataModel, 0, len(images))
4443
for _, image := range images {
45-
if strings.Contains(image.Tag, "-debug") {
46-
continue
47-
}
48-
4944
imgData := imageDataModel{
5045
Name: image.BrowserName,
5146
Version: image.Tag,

handlers/reporting.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package handlers
22

33
import (
4+
"encoding/json"
45
"fmt"
56
"net/http"
67
"os"
78
"runtime"
9+
"strings"
810
"time"
911

1012
log "github.com/sirupsen/logrus"
@@ -58,12 +60,21 @@ func ListDrivers(c *gin.Context) {
5860
return
5961
}
6062

61-
_, err = c.Writer.Write(resBody)
62-
if err != nil {
63-
c.Status(http.StatusInternalServerError)
64-
log.WithError(err).Error("Failed to write body server")
63+
originalImages := make([]imageDataModel, 0)
64+
if err := json.Unmarshal(resBody, &originalImages); err != nil {
65+
log.WithError(err).Error("Failed to unmarshal list of the images from task-definitions server")
6566
return
6667
}
68+
69+
filteredImages := make([]imageDataModel, 0)
70+
for _, image := range originalImages {
71+
// -debug images should not be added to the reporting, it should be available silently
72+
if strings.Contains(image.Version, "-debug") {
73+
continue
74+
}
75+
filteredImages = append(filteredImages, image)
76+
}
77+
c.JSON(http.StatusOK, filteredImages)
6778
}
6879

6980
func Welcome(c *gin.Context) {

0 commit comments

Comments
 (0)