istio.io/istio@v0.0.0-20240520182934-d79c90f27776/pkg/config/schema/codegen/templates/kind.go.tmpl (about) 1 // Code generated by pkg/config/schema/codegen/tools/collections.main.go. DO NOT EDIT. 2 3 package {{.PackageName}} 4 5 import ( 6 "istio.io/istio/pkg/config" 7 "istio.io/istio/pkg/config/schema/gvk" 8 ) 9 10 const ( 11 {{- range $index, $element := .Entries }} 12 {{- if (eq $index 0) }} 13 {{.Resource.Identifier}} Kind = iota 14 {{- else }} 15 {{.Resource.Identifier}} 16 {{- end }} 17 {{- end }} 18 ) 19 20 func (k Kind) String() string { 21 switch k { 22 {{- range .Entries }} 23 case {{.Resource.Identifier}}: 24 return "{{.Resource.Kind}}" 25 {{- end }} 26 default: 27 return "Unknown" 28 } 29 } 30 31 func MustFromGVK(g config.GroupVersionKind) Kind { 32 switch g { 33 {{- range .Entries }} 34 {{- if not (or (eq .Resource.Identifier "Address") (eq .Resource.Identifier "DNSName")) }} 35 case gvk.{{.Resource.Identifier}}: 36 return {{.Resource.Identifier}} 37 {{- end }} 38 {{- end }} 39 } 40 41 panic("unknown kind: " + g.String()) 42 }