aboutsummaryrefslogtreecommitdiffstats
path: root/skate
diff options
context:
space:
mode:
Diffstat (limited to 'skate')
-rw-r--r--skate/cmd/skate-map/main.go3
-rw-r--r--skate/map.go17
2 files changed, 19 insertions, 1 deletions
diff --git a/skate/cmd/skate-map/main.go b/skate/cmd/skate-map/main.go
index 060e324..3d5630b 100644
--- a/skate/cmd/skate-map/main.go
+++ b/skate/cmd/skate-map/main.go
@@ -66,7 +66,7 @@ func main() {
flag.Parse()
availableMappers := map[string]skate.Mapper{
// Add new mapper functions here. TODO: add more docs, and improve
- // composability, e.g. like middleware.
+ // composability, e.g. like middleware. Also improve naming.
"id": skate.Identity,
"ff": skate.CreateFixedMapper(*extraValue),
"ti": skate.MapperTitle,
@@ -77,6 +77,7 @@ func main() {
"cni": skate.MapperContainerName,
"cns": skate.MapperContainerNameSandcrawler,
"rcns": skate.MapperReleaseContainerName,
+ "vcns": skate.MapperReleaseResolvedContainerName,
}
if *logFile != "" {
f, err := os.OpenFile(*logFile, os.O_CREATE|os.O_APPEND, 0644)
diff --git a/skate/map.go b/skate/map.go
index a06b5ae..1d21818 100644
--- a/skate/map.go
+++ b/skate/map.go
@@ -257,6 +257,23 @@ func MapperReleaseContainerName(p []byte) (fields [][]byte, err error) {
return [][]byte{key, p}, nil
}
+// MapperReleaseResolvedContainerName extracts slug container name from
+// resolved container names.
+func MapperReleaseResolvedContainerName(p []byte) (fields [][]byte, err error) {
+ var (
+ doc Release
+ key []byte
+ )
+ if err := json.Unmarshal(p, &doc); err != nil {
+ return nil, err
+ }
+ if doc.Extra.Skate.ResolvedContainerName == "" {
+ return nil, nil
+ }
+ key = []byte(sandcrawlerSlugify(wsReplacer.Replace(strings.TrimSpace(doc.Extra.Skate.ResolvedContainerName))))
+ return [][]byte{key, p}, nil
+}
+
// MapperPartial works on partial documents.
func MapperPartial(p []byte) (fields [][]byte, err error) {
return nil, nil