-
Notifications
You must be signed in to change notification settings - Fork 124
/
serverless_block.go
52 lines (44 loc) · 1.11 KB
/
serverless_block.go
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package structure
import (
"github.com/bridgecrewio/yor/src/common/structure"
"go.opencensus.io/tag"
)
type ServerlessBlock struct {
structure.Block
}
func (b *ServerlessBlock) GetFramework() string {
return "Serverless"
}
func (b *ServerlessBlock) UpdateTags() {
if !b.IsTaggable {
return
}
mergedTags := b.MergeTags()
slsMergedTags := make([]tag.Tag, 0)
for _, t := range mergedTags {
key, _ := tag.NewKey(t.GetKey())
slsTag := tag.Tag{
Key: key,
Value: t.GetValue(),
}
slsMergedTags = append(slsMergedTags, slsTag)
}
slsMergedTagsValue := make(map[string]interface{})
for _, mergedTag := range slsMergedTags {
slsMergedTagsValue[mergedTag.Key.Name()] = mergedTag.Value
}
rawFunction := b.RawBlock.(structure.Function)
if rawFunction.Tags == nil {
rawFunction.Tags = make(map[string]interface{}, len(slsMergedTags))
}
for _, slsTag := range slsMergedTags {
rawFunction.Tags[slsTag.Key.Name()] = slsTag.Value
}
b.RawBlock = rawFunction
}
func (b *ServerlessBlock) GetTagsLines() structure.Lines {
return b.Block.TagLines
}
func (b *ServerlessBlock) GetSeparator() string {
return "/n"
}