@@ -16,14 +16,19 @@ package registry
16
16
17
17
import (
18
18
"context"
19
+ "embed"
19
20
"fmt"
20
21
"github.com/google/go-containerregistry/pkg/name"
21
22
"github.com/google/go-containerregistry/pkg/v1/remote"
22
23
"github.com/seqeralabs/staticreg/pkg/cfg"
23
24
"github.com/seqeralabs/staticreg/pkg/registry"
25
+ "html/template"
24
26
"strings"
25
27
)
26
28
29
+ //go:embed img/*
30
+ var icons embed.FS
31
+
27
32
const defaultUserAgent = "seqera/staticreg"
28
33
29
34
var (
@@ -108,27 +113,25 @@ func (c *Registry) ImageInfo(ctx context.Context, image string, tag string) (reg
108
113
scanUrls = append (scanUrls , c .getScanUrl (ref .String (), "" , cf .Architecture ))
109
114
}
110
115
}
111
- inspectUrl := fmt .Sprintf ("%s/view/inspect?image=%s" , waveServerUrl , ref )
116
+ inspectIcon , _ := icons .ReadFile ("img/inspect-icon.svg" )
117
+ inspectUrl := template .HTML (fmt .Sprintf ("<a href=%s/view/inspect?image=%s>%s</a>" , waveServerUrl , ref , inspectIcon ))
118
+
119
+ scanUrl := template .HTML (strings .Join (scanUrls , "" ))
112
120
113
- return registry.ImageInfo {Image : i , Reference : ref .String (), Architectures : architectures , ScanUrls : scanUrls , InspectUrl : inspectUrl }, nil
121
+ return registry.ImageInfo {Image : i , Reference : ref .String (), Architectures : architectures , ScanUrl : scanUrl , InspectUrl : inspectUrl }, nil
114
122
}
115
123
116
124
func (c * Registry ) getScanUrl (ref string , digest string , platform string ) string {
117
125
118
126
waveServerUrl := c .cfg .WaveServerUrl
119
-
127
+ scanIcon , _ := icons . ReadFile ( "img/scan-icon.svg" )
120
128
if ! strings .Contains (waveServerUrl , "https://" ) && ! strings .Contains (waveServerUrl , "http://" ) {
121
129
waveServerUrl = "https://" + waveServerUrl
122
130
}
123
131
124
- const scanSvg = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-shield-check" viewBox="0 0 16 16">
125
- <path d="M5.338 1.59a61 61 0 0 0-2.837.856.48.48 0 0 0-.328.39c-.554 4.157.726 7.19 2.253 9.188a10.7 10.7 0 0 0 2.287 2.233c.346.244.652.42.893.533q.18.085.293.118a1 1 0 0 0 .101.025 1 1 0 0 0 .1-.025q.114-.034.294-.118c.24-.113.547-.29.893-.533a10.7 10.7 0 0 0 2.287-2.233c1.527-1.997 2.807-5.031 2.253-9.188a.48.48 0 0 0-.328-.39c-.651-.213-1.75-.56-2.837-.855C9.552 1.29 8.531 1.067 8 1.067c-.53 0-1.552.223-2.662.524zM5.072.56C6.157.265 7.31 0 8 0s1.843.265 2.928.56c1.11.3 2.229.655 2.887.87a1.54 1.54 0 0 1 1.044 1.262c.596 4.477-.787 7.795-2.465 9.99a11.8 11.8 0 0 1-2.517 2.453 7 7 0 0 1-1.048.625c-.28.132-.581.24-.829.24s-.548-.108-.829-.24a7 7 0 0 1-1.048-.625 11.8 11.8 0 0 1-2.517-2.453C1.928 10.487.545 7.169 1.141 2.692A1.54 1.54 0 0 1 2.185 1.43 63 63 0 0 1 5.072.56"/>
126
- <path d="M10.854 5.146a.5.5 0 0 1 0 .708l-3 3a.5.5 0 0 1-.708 0l-1.5-1.5a.5.5 0 1 1 .708-.708L7.5 7.793l2.646-2.647a.5.5 0 0 1 .708 0"/>
127
- </svg>`
128
-
129
- url := fmt .Sprintf ("<a href=%s/view/scans?image=%s title=%s>%s</a>" , waveServerUrl , ref , platform , scanSvg )
132
+ url := fmt .Sprintf ("<a href=%s/view/scans?image=%s title=%s>%s</a>" , waveServerUrl , ref , platform , scanIcon )
130
133
if digest != "" {
131
- url = fmt .Sprintf ("<a href=%s/view/scans?image=%s@%s title=%s>%s</a>" , waveServerUrl , ref , digest , platform , scanSvg )
134
+ url = fmt .Sprintf ("<a href=%s/view/scans?image=%s@%s title=%s>%s</a>" , waveServerUrl , ref , digest , platform , scanIcon )
132
135
}
133
136
return url
134
137
}
0 commit comments