forked from openshift/ops-sop-search
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsop.go
More file actions
34 lines (31 loc) · 1 KB
/
sop.go
File metadata and controls
34 lines (31 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package sopsearch
import (
"encoding/json"
"time"
)
// Sop struct contains all the information that will be in the index for the sop document
type Sop struct {
Name string `json:"name"`
Path string `json:"path"`
Author []string `json:"author"`
CreationDate time.Time `json:"creationDate"`
LastUpdated time.Time `json:"lastUpdated"`
Commit string `json:"commit"`
Content string `json:"content"`
Tags []string `json:"tags"`
Link string `json:"links"`
}
// ToBulkJSON takes all the Sop objects and puts them into the map that will be used
//when calling IndexSOP after encoding the Sop into JSON. The name of the SOP will be
//the key and the json encoded sop as the value for the key-value pair.
func ToBulkJSON(s []Sop) (map[string]string, error) {
jmap := make(map[string]string)
for _, f := range s {
obj, err := json.Marshal(f)
if err != nil {
return map[string]string{}, nil
}
jmap[f.Name] = string(obj)
}
return jmap, nil
}