istio.io/istio@v0.0.0-20240520182934-d79c90f27776/pkg/config/schema/codegen/templates/collections.go.tmpl (about)

     1  {{- .FilePrefix}}
     2  // Code generated by pkg/config/schema/codegen/tools/collections.main.go. DO NOT EDIT.
     3  
     4  package {{.PackageName}}
     5  
     6  import (
     7  	"istio.io/istio/pkg/config/schema/collection"
     8  	"istio.io/istio/pkg/config/schema/resource"
     9  	"istio.io/istio/pkg/config/validation"
    10  {{ .CustomImport }}
    11    "reflect"
    12  {{- range .Packages}}
    13  	{{.ImportName}} "{{.PackageName}}"
    14  {{- end}}
    15  )
    16  
    17  var (
    18  {{ range .Entries }}
    19  	{{ .Resource.Identifier }} = resource.Builder {
    20  			Identifier: "{{ .Resource.Identifier }}",
    21  			Group: "{{ .Resource.Group }}",
    22  			Kind: "{{ .Resource.Kind }}",
    23  			Plural: "{{ .Resource.Plural }}",
    24  			Version: "{{ .Resource.Version }}",
    25  			{{- if .Resource.VersionAliases }}
    26              VersionAliases: []string{
    27  				{{- range $alias := .Resource.VersionAliases}}
    28  			        "{{$alias}}",
    29  		 	    {{- end}}
    30  			},
    31  			{{- end}}
    32  			Proto: "{{ .Resource.Proto }}",
    33  			{{- if ne .Resource.StatusProto "" }}StatusProto: "{{ .Resource.StatusProto }}",{{end}}
    34  			ReflectType: reflect.TypeOf(&{{.ClientImport}}.{{.SpecType}}{}).Elem(),
    35  			{{- if ne .StatusType "" }}StatusType: reflect.TypeOf(&{{.StatusImport}}.{{.StatusType}}{}).Elem(), {{end}}
    36  			ProtoPackage: "{{ .Resource.ProtoPackage }}",
    37  			{{- if ne "" .Resource.StatusProtoPackage}}StatusPackage: "{{ .Resource.StatusProtoPackage }}", {{end}}
    38  			ClusterScoped: {{ .Resource.ClusterScoped }},
    39  			Synthetic: {{ .Resource.Synthetic }},
    40  			Builtin: {{ .Resource.Builtin }},
    41  			ValidateProto: {{ .Resource.Validate }},
    42  		}.MustBuild()
    43  {{ end }}
    44  
    45  	// All contains all collections in the system.
    46  	All = collection.NewSchemasBuilder().
    47  	{{- range .Entries }}
    48  		MustAdd({{ .Resource.Identifier }}).
    49  	{{- end }}
    50  		Build()
    51  
    52  	// Kube contains only kubernetes collections.
    53  	Kube = collection.NewSchemasBuilder().
    54  	{{- range .Entries }}
    55  		{{- if or (contains .Resource.Group "k8s.io") .Resource.Builtin  }}
    56  		MustAdd({{ .Resource.Identifier }}).
    57  		{{- end }}
    58  	{{- end }}
    59  		Build()
    60  
    61  	// Pilot contains only collections used by Pilot.
    62  	Pilot = collection.NewSchemasBuilder().
    63  	{{- range .Entries }}
    64  		{{- if (contains .Resource.Group "istio.io") }}
    65  		MustAdd({{ .Resource.Identifier }}).
    66  		{{- end}}
    67  	{{- end }}
    68  		Build()
    69  
    70  	// pilotGatewayAPI contains only collections used by Pilot, including the full Gateway API.
    71  	pilotGatewayAPI = collection.NewSchemasBuilder().
    72  	{{- range .Entries }}
    73  		{{- if or (contains .Resource.Group "istio.io") (contains .Resource.Group "gateway.networking.k8s.io") }}
    74  		MustAdd({{ .Resource.Identifier }}).
    75  		{{- end}}
    76  	{{- end }}
    77  		Build()
    78  
    79  	// PilotStableGatewayAPI contains only collections used by Pilot, including beta+ Gateway API.
    80  	pilotStableGatewayAPI = collection.NewSchemasBuilder().
    81  	{{- range .Entries }}
    82  		{{- if or
    83         (contains .Resource.Group "istio.io")
    84         (and
    85            (contains .Resource.Group "gateway.networking.k8s.io")
    86            (not (contains .Resource.Version "alpha")))
    87      }}
    88  		MustAdd({{ .Resource.Identifier }}).
    89  		{{- end}}
    90  	{{- end }}
    91  		Build()
    92  )