Skip to content

Commit

Permalink
enum value map added
Browse files Browse the repository at this point in the history
  • Loading branch information
valllabh committed Jan 9, 2024
1 parent 7562b14 commit 6ee42eb
Show file tree
Hide file tree
Showing 21 changed files with 33,054 additions and 33,011 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ func main() {
Message: "This is a sample message",
}



}
```

Expand Down
4 changes: 2 additions & 2 deletions enum-value/enum-value-map.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ while IFS= read -r -d '' enumValueMapJson; do

# replace proto from $file
newEnumValueMapJson=${enumValueMapJson/proto\//}
newEnumValueMapJson=${enumValueMapJson/enum-value-map.json/enum-value-map/enum-value-map.json/}
newEnumValueMapJson=${newEnumValueMapJson/enum-value-map.json/enum-value-map/enum-value-map.json}

# create directory if not exist
mkdir -p $(dirname $newEnumValueMapJson)
Expand All @@ -16,7 +16,7 @@ while IFS= read -r -d '' enumValueMapJson; do
cp $enumValueMapJson $newEnumValueMapJson

# replace enum-value-map.json to enum-value-map.go.template from $newFile
enumValueMapGoFile=${newEnumValueMapJson/enum-value-map.json/enum-value-map/map.go}
enumValueMapGoFile=${newEnumValueMapJson/enum-value-map.json/map.go}

# create directory if not exist
mkdir -p $(dirname $enumValueMapGoFile)
Expand Down
11 changes: 11 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
package main

import enumValueMap "github.com/valllabh/ocsf-schema-golang/ocsf/v1_0_0/enum-value-map"

// Nothing to see here, move along

func main() {

}

func testEnumValue() {
ev, _ := enumValueMap.GetEnumValue("ACCOUNT_CHANGE_CATEGORY_UID_IDENTITY_ACCESS_MANAGEMENT")
println(ev.Name, ev.Value)
}
1 change: 1 addition & 0 deletions ocsf/v1_0_0/enum-value-map/enum-value-map.json

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions ocsf/v1_0_0/enum-value-map/map.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package enumValueMap

import (
"embed"
"encoding/json"
)

//go:embed enum-value-map.json
var embedFs embed.FS

// struct to hold the enum value
type EnumValue struct {
Name string `json:"name"`
Value int64 `json:"value"`
}

type EnumValueMap = map[string]EnumValue

var enumValueMap EnumValueMap

func init() {
data, _ := embedFs.ReadFile("enum-value-map.json")
json.Unmarshal(data, &enumValueMap)
}

func GetEnumValue(name string) (EnumValue, bool) {
enumValue, enumValueExits := enumValueMap[name]
return enumValue, enumValueExits
}
2,644 changes: 1,322 additions & 1,322 deletions ocsf/v1_0_0/events/application/application.pb.go

Large diffs are not rendered by default.

2,354 changes: 1,177 additions & 1,177 deletions ocsf/v1_0_0/events/application/enums/enums.pb.go

Large diffs are not rendered by default.

1,372 changes: 686 additions & 686 deletions ocsf/v1_0_0/events/discovery/discovery.pb.go

Large diffs are not rendered by default.

Loading

0 comments on commit 6ee42eb

Please sign in to comment.