github.com/aquasecurity/trivy-iac@v0.8.1-0.20240127024015-3d8e412cf0ab/pkg/scanners/kubernetes/parser/manifest.go (about) 1 package parser 2 3 import ( 4 "fmt" 5 6 "gopkg.in/yaml.v3" 7 ) 8 9 type Manifest struct { 10 Path string 11 Content *ManifestNode 12 } 13 14 func (m *Manifest) UnmarshalYAML(value *yaml.Node) error { 15 16 switch value.Tag { 17 case "!!map": 18 node := new(ManifestNode) 19 node.Path = m.Path 20 if err := value.Decode(node); err != nil { 21 return err 22 } 23 m.Content = node 24 default: 25 return fmt.Errorf("failed to handle tag: %s", value.Tag) 26 } 27 28 return nil 29 } 30 31 func (m *Manifest) ToRego() interface{} { 32 return m.Content.ToRego() 33 }