Documentation ¶
Index ¶
- Variables
- func CreateAdmissionGenerator(apis *APIs, filename string, projectRootPath string, outputBase string) generator.Generator
- func CreateApisGenerator(apis *APIs, filename string) generator.Generator
- func CreateInstallGenerator(apigroup *APIGroup, filename string) generator.Generator
- func CreateUnversionedGenerator(apigroup *APIGroup, filename string) generator.Generator
- func CreateVersionedGenerator(apiversion *APIVersion, apigroup *APIGroup, filename string) generator.Generator
- func GetGroup(t *types.Type) string
- func GetGroupPackage(t *types.Type) string
- func GetKind(t *types.Type, group string) string
- func GetVersion(t *types.Type, group string) string
- func HasSubresource(t *types.Type) bool
- func IsAPIResource(t *types.Type) bool
- func IsAPISubresource(t *types.Type) bool
- func IsApisDir(dir string) bool
- func IsNonNamespaced(t *types.Type) bool
- func IsUnversioned(t *types.Type, group string) bool
- func IsVersioned(t *types.Type, group string) bool
- type APIGroup
- type APIResource
- type APISubresource
- type APIVersion
- type APIs
- type APIsBuilder
- func (b *APIsBuilder) GenClient(c *types.Type) bool
- func (b *APIsBuilder) GenDeepCopy(c *types.Type) bool
- func (b *APIsBuilder) GetControllerTag(c *types.Type) string
- func (b *APIsBuilder) GetNameAndImport(tags SubresourceTags) (string, string)
- func (b *APIsBuilder) GetResourceTag(c *types.Type) string
- func (b *APIsBuilder) GetSubresourceTags(c *types.Type) []string
- func (b *APIsBuilder) GetSubresources(c *APIResource) map[string]*APISubresource
- func (b *APIsBuilder) IsInPackage(tags SubresourceTags) bool
- func (b *APIsBuilder) ParseAPIs()
- func (b *APIsBuilder) ParseDomain()
- func (b *APIsBuilder) ParseGroupNames()
- func (b *APIsBuilder) ParseIndex()
- func (b *APIsBuilder) ParsePackages()
- func (b *APIsBuilder) ParseStructsAndAliases(apigroup *APIGroup)
- type AdmissionGeneratorParam
- type Alias
- type Comments
- type CustomArgs
- type Field
- type Gen
- func (g *Gen) DefaultNameSystem() string
- func (g *Gen) Execute(arguments *args.GeneratorArgs) error
- func (g *Gen) NameSystems() namer.NameSystems
- func (g *Gen) Packages(context *generator.Context, arguments *args.GeneratorArgs) generator.Packages
- func (g *Gen) ParsePackages(context *generator.Context, arguments *args.GeneratorArgs) (sets.String, sets.String, string, string)
- type GenUnversionedType
- type ResourceTags
- type Struct
- type SubresourceTags
Constants ¶
This section is empty.
Variables ¶
var APIsTemplate = `` /* 1216-byte string literal not displayed */
var AdmissionsInstallTemplate = `` /* 847-byte string literal not displayed */
var InstallAPITemplate = `` /* 649-byte string literal not displayed */
var UnversionedAPITemplate = `` /* 7250-byte string literal not displayed */
var VersionedAPITemplate = `
func addKnownTypes(scheme *runtime.Scheme) error {
// TODO this will get cleaned up with the scheme types are fixed
scheme.AddKnownTypes(SchemeGroupVersion,
{{ range $api := .Resources -}}
&{{ $api.Kind }}{},
&{{ $api.Kind }}List{},
{{ range $subresource := $api.Subresources -}}
&{{ $subresource.Kind }}{},
{{ end -}}
{{ end -}}
)
return nil
}
var (
ApiVersion = builders.NewApiVersion("{{.Group}}.{{.Domain}}", "{{.Version}}").WithResources(
{{ range $api := .Resources -}}
{{$api.Group}}.{{$api.Group|public}}{{$api.Kind}}Storage,
{{ if $api.REST }}{{ else -}}
builders.NewApiResource( // Resource status endpoint
{{ $api.Group }}.Internal{{ $api.Kind }}Status,
func() runtime.Object { return &{{ $api.Kind }}{} }, // Register versioned resource
func() runtime.Object { return &{{ $api.Kind }}List{} }, // Register versioned resource list
&{{ $api.Group }}.{{ $api.StatusStrategy }}{builders.StatusStorageStrategySingleton},
),{{ end -}}
{{ range $subresource := $api.Subresources -}}
builders.NewApiResourceWithStorage(
{{ $api.Group }}.Internal{{ $subresource.Kind }}REST,
func() runtime.Object { return &{{ $subresource.Request }}{} }, // Register versioned resource
nil,
{{ if $subresource.REST }}{{ $api.Group }}.New{{ $subresource.REST }}{{ else -}}
func(generic.RESTOptionsGetter) rest.Storage { return &{{ $api.Group }}.{{ $subresource.Kind }}REST{ {{$api.Group}}.New{{$api.Kind}}Registry({{$api.Group}}.{{$api.Group|public}}{{$api.Kind}}Storage) } },
{{ end -}}
),
{{ end -}}
{{ end -}}
)
// Required by code generated by go2idl
AddToScheme = (&runtime.SchemeBuilder{
ApiVersion.SchemeBuilder.AddToScheme,
RegisterDefaults,
RegisterConversions,
addKnownTypes,
func(scheme *runtime.Scheme) error {
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
},
}).AddToScheme
SchemeBuilder = ApiVersion.SchemeBuilder
localSchemeBuilder = SchemeBuilder
SchemeGroupVersion = ApiVersion.GroupVersion
)
// Required by code generated by go2idl
// Kind takes an unqualified kind and returns a Group qualified GroupKind
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
}
// Required by code generated by go2idl
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
{{ range $api := .Resources -}}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type {{$api.Kind}}List struct {
metav1.TypeMeta ` + "`json:\",inline\"`" + `
metav1.ListMeta ` + "`json:\"metadata,omitempty\"`" + `
Items []{{$api.Kind}} ` + "`json:\"items\"`" + `
}
{{ range $subresource := $api.Subresources -}}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type {{$subresource.Request}}List struct {
metav1.TypeMeta ` + "`json:\",inline\"`" + `
metav1.ListMeta ` + "`json:\"metadata,omitempty\"`" + `
Items []{{$subresource.Request}} ` + "`json:\"items\"`" + `
}
{{ end }}{{ end -}}
`
Functions ¶
func CreateAdmissionGenerator ¶ added in v1.12.4
func CreateApisGenerator ¶
func CreateInstallGenerator ¶
func CreateVersionedGenerator ¶
func CreateVersionedGenerator(apiversion *APIVersion, apigroup *APIGroup, filename string) generator.Generator
func GetGroupPackage ¶
func HasSubresource ¶
HasSubresource returns true if t is an APIResource with one or more Subresources
func IsAPIResource ¶
IsAPIResource returns true if t has a +resource comment tag
func IsAPISubresource ¶
IsAPISubresource returns true if t has a +subresource-request comment tag
func IsNonNamespaced ¶
IsNonNamespaced returns true if t has a +nonNamespaced comment tag
Types ¶
type APIGroup ¶
type APIGroup struct { // Package is the name of the go package the api group is under - e.g. github.com/pwittrock/apiserver-helloworld/apis Package string // Domain is the domain portion of the group - e.g. k8s.io Domain string // Group is the short name of the group - e.g. mushroomkingdom Group string GroupTitle string // Versions is the list of all versions for this group keyed by name Versions map[string]*APIVersion UnversionedResources map[string]*APIResource // Structs is a list of unversioned definitions that must be generated Structs []*Struct Aliases map[string]*Alias Pkg *types.Package PkgPath string }
type APIResource ¶
type APIResource struct { // Domain is the group domain - e.g. k8s.io Domain string // Group is the group name - e.g. mushroomkingdom Group string // Version is the api version - e.g. v1beta1 Version string // Kind is the resource name - e.g. PeachesCastle Kind string // Resource is the resource name - e.g. peachescastles Resource string // ShortName is the resource short name - e.g. pc ShortName string // REST is the rest.Storage implementation used to handle requests // This field is optional. The standard REST implementation will be used // by default. REST string // Subresources is a map of subresources keyed by name Subresources map[string]*APISubresource // Type is the Type object from code-gen Type *types.Type // Strategy is name of the struct to use for the strategy Strategy string // Strategy is name of the struct to use for the strategy StatusStrategy string // NonNamespaced indicates that the resource kind is non namespaced NonNamespaced bool }
type APISubresource ¶
type APISubresource struct { // Domain is the group domain - e.g. k8s.io Domain string // Group is the group name - e.g. mushroomkingdom Group string // Version is the api version - e.g. v1beta1 Version string // Kind is the resource name - e.g. PeachesCastle Kind string // Resource is the resource name - e.g. peachescastles Resource string // Request is the subresource request type - e.g. ScaleCastle Request string // REST is the rest.Storage implementation used to handle requests REST string // Path is the subresource path - e.g. scale Path string // ImportPackage is the import statement that must appear for the Request ImportPackage string // RequestType is the type of the request RequestType *types.Type // RESTType is the type of the request handler RESTType *types.Type }
type APIVersion ¶
type APIVersion struct { // Domain is the group domain - e.g. k8s.io Domain string // Group is the group name - e.g. mushroomkingdom Group string // Version is the api version - e.g. v1beta1 Version string // Resources is a list of resources appearing in the API version keyed by name Resources map[string]*APIResource // Pkg is the Package object from code-gen Pkg *types.Package }
type APIs ¶
type APIs struct { // Domain is the domain portion of the group - e.g. k8s.io Domain string // Package is the name of the go package the api group is under - e.g. github.com/pwittrock/apiserver-helloworld/apis Package string Pkg *types.Package // Groups is a list of API groups Groups map[string]*APIGroup }
type APIsBuilder ¶
type APIsBuilder struct { Domain string VersionedPkgs sets.String UnversionedPkgs sets.String APIsPkg string APIsPkgRaw *types.Package GroupNames sets.String APIs *APIs ByGroupKindVersion map[string]map[string]map[string]*APIResource ByGroupVersionKind map[string]map[string]map[string]*APIResource SubByGroupVersionKind map[string]map[string]map[string]*types.Type Groups map[string]types.Package // contains filtered or unexported fields }
func NewAPIsBuilder ¶
func NewAPIsBuilder(context *generator.Context, arguments *args.GeneratorArgs) *APIsBuilder
func (*APIsBuilder) GenDeepCopy ¶
func (b *APIsBuilder) GenDeepCopy(c *types.Type) bool
func (*APIsBuilder) GetControllerTag ¶
func (b *APIsBuilder) GetControllerTag(c *types.Type) string
func (*APIsBuilder) GetNameAndImport ¶
func (b *APIsBuilder) GetNameAndImport(tags SubresourceTags) (string, string)
GetNameAndImport converts
func (*APIsBuilder) GetResourceTag ¶
func (b *APIsBuilder) GetResourceTag(c *types.Type) string
GetResourceTag returns the value of the "+resource=" comment tag
func (*APIsBuilder) GetSubresourceTags ¶
func (b *APIsBuilder) GetSubresourceTags(c *types.Type) []string
func (*APIsBuilder) GetSubresources ¶
func (b *APIsBuilder) GetSubresources(c *APIResource) map[string]*APISubresource
func (*APIsBuilder) IsInPackage ¶
func (b *APIsBuilder) IsInPackage(tags SubresourceTags) bool
Returns true if the subresource Request type is in the same package as the resource type
func (*APIsBuilder) ParseAPIs ¶
func (b *APIsBuilder) ParseAPIs()
func (*APIsBuilder) ParseDomain ¶
func (b *APIsBuilder) ParseDomain()
ParseDomain parses the domain from the apis/doc.go file comment "// +domain=YOUR_DOMAIN".
func (*APIsBuilder) ParseGroupNames ¶
func (b *APIsBuilder) ParseGroupNames()
ParseGroupNames initializes b.GroupNames with the set of all groups
func (*APIsBuilder) ParseIndex ¶
func (b *APIsBuilder) ParseIndex()
ParseIndex indexes all types with the comment "// +resource=RESOURCE" by GroupVersionKind and GroupKindVersion
func (*APIsBuilder) ParsePackages ¶
func (b *APIsBuilder) ParsePackages()
ParsePackages parses out the sets of Versioned, Unversioned packages and identifies the root Apis package.
func (*APIsBuilder) ParseStructsAndAliases ¶ added in v1.12.2
func (b *APIsBuilder) ParseStructsAndAliases(apigroup *APIGroup)
type AdmissionGeneratorParam ¶ added in v1.12.4
type AdmissionGeneratorParam struct {
Kind string
}
type Comments ¶
type Comments []string
Comments is a structure for using comment tags on go structs and fields
func (Comments) GetTag ¶
GetTags returns the value for the first comment with a prefix matching "+name=" e.g. "+name=foo\n+name=bar" would return "foo"
type CustomArgs ¶
type CustomArgs struct{}
CustomArgs is used tby the go2idl framework to pass args specific to this generator.
type Gen ¶
type Gen struct {
// contains filtered or unexported fields
}
func (*Gen) DefaultNameSystem ¶
DefaultNameSystem returns the default name system for ordering the types to be processed by the generators in this package.
func (*Gen) NameSystems ¶
func (g *Gen) NameSystems() namer.NameSystems
NameSystems returns the name system used by the generators in this package.
type GenUnversionedType ¶
type GenUnversionedType struct { Type *types.Type Resource *APIResource }
type ResourceTags ¶
ResourceTags contains the tags present in a "+resource=" comment
func ParseResourceTag ¶
func ParseResourceTag(tag string) ResourceTags
ParseResourceTag parses the tags in a "+resource=" comment into a ResourceTags struct
type SubresourceTags ¶
SubresourceTags contains the tags present in a "+subresource=" comment
func ParseSubresourceTag ¶
func ParseSubresourceTag(c *APIResource, tag string) SubresourceTags
ParseSubresourceTag parses the tags in a "+subresource=" comment into a SubresourceTags struct