Documentation
¶
Index ¶
- Variables
- type Command
- type GenericAPIServer
- type OpenAPIDefinition
- type Server
- func (r *Server) Build(ctx context.Context) (*Command, error)
- func (r *Server) Execute(ctx context.Context) error
- func (r *Server) WithConfigFns(fns ...func(config *server.RecommendedConfig) *server.RecommendedConfig) *Server
- func (r *Server) WithEtcdPath(etcdPath string) *Server
- func (r *Server) WithFlagFns(fns ...func(set *pflag.FlagSet) *pflag.FlagSet) *Server
- func (a *Server) WithLocalDebugExtension() *Server
- func (r *Server) WithOpenAPIDefinitions(name, version string, defs openapicommon.GetOpenAPIDefinitions) *Server
- func (r *Server) WithOptionsFns(fns ...func(*ServerOptions) *ServerOptions) *Server
- func (r *Server) WithResourceAndHandler(obj resource.Object, sp *rest.StorageProvider) *Server
- func (r *Server) WithServerFns(fns ...func(server *GenericAPIServer) *GenericAPIServer) *Server
- func (r *Server) WithServerName(serverName string) *Server
- func (r *Server) WithoutEtcd() *Server
- type ServerOptions
- type SingletonProvider
- type Storage
Constants ¶
This section is empty.
Variables ¶
var APIServer = &Server{ StorageProvider: map[schema.GroupResource]*SingletonProvider{}, }
APIServer builds an apiserver to server Kubernetes resources and sub resources.
Functions ¶
This section is empty.
Types ¶
type GenericAPIServer ¶
type GenericAPIServer = server.GenericAPIServer
GenericAPIServer is an alias for pkgserver.GenericAPIServer
type OpenAPIDefinition ¶
type OpenAPIDefinition = common.OpenAPIDefinition
OpenAPIDefinition is an alias for common.OpenAPIDefinition
type Server ¶
type Server struct {
ServerName string
EtcdPath string
StorageProvider map[schema.GroupResource]*SingletonProvider
Schemes []*runtime.Scheme
// contains filtered or unexported fields
}
Server builds a new apiserver for a single API group
func NewAPIServer ¶ added in v0.0.4
func NewAPIServer() *Server
func (*Server) WithConfigFns ¶
func (r *Server) WithConfigFns(fns ...func(config *server.RecommendedConfig) *server.RecommendedConfig) *Server
WithConfigFns sets functions to customize the RecommendedConfig
func (*Server) WithEtcdPath ¶
func (*Server) WithFlagFns ¶
WithFlagFns sets functions to customize the flags for the compiled binary.
func (*Server) WithLocalDebugExtension ¶
WithLocalDebugExtension adds an optional local-debug mode to the apiserver so that it can be tested locally without involving a complete kubernetes cluster. A flag named "--standalone-debug-mode" will also be added the binary which forcily requires "--bind-address" to be "127.0.0.1" in order to avoid security issues.
func (*Server) WithOpenAPIDefinitions ¶
func (r *Server) WithOpenAPIDefinitions( name, version string, defs openapicommon.GetOpenAPIDefinitions) *Server
WithOpenAPIDefinitions registers OpenAPI definitions for the API server.
Root cause of the ~1 / SSA / kubectl issue ¶
kube-openapi builds $ref strings as:
"#/.../schemas/" + EscapeJsonPointer(GetDefinitionName(goPath))
GetDefinitionName for non-GVK types falls back to returning the name unchanged (containing "/"). EscapeJsonPointer then converts "/" → "~1".
If we override GetDefinitionName to return "~1"-encoded names (which is what we need so that component KEYS are "~1"-encoded and the TypeConverter can find them), EscapeJsonPointer double-encodes the "~" → "~0", yielding "~01" in the $ref. In newer kube-openapi, BuildOpenAPIDefinitionsForResources finds sub-types by looking up the raw $ref content in the definitions map. "~01" is NOT a key in the map (map has "~1" aliases and "/" Go-path keys), so TargetStatus/ConfigStatus/etc. are never included in the TypeConverter's schema. The TypeConverter then fails with "no type found matching: ~1-name".
Fix: bypass EscapeJsonPointer with a custom ReferenceCallback ¶
By providing our OWN ref callback to GetOpenAPIDefinitions — one that inserts the GetDefinitionName output DIRECTLY into the $ref without calling EscapeJsonPointer — we ensure:
$ref = GetDefinitionName(goPath) = "github.com~1sdcio~1...TargetStatus" key = GetDefinitionName(goPath) = "github.com~1sdcio~1...TargetStatus" $ref == key → raw lookup always works, no double-encoding
This satisfies BOTH the TypeConverter (which does a raw lookup of the $ref content in its schema) AND kubectl (which looks up component names literally).
The "~1"-encoded alias entries in the definitions map are still needed so that BuildOpenAPIDefinitionsForResources can find root types when getResourceNamesForGroup passes their canonical (~1-encoded) names.
func (*Server) WithOptionsFns ¶
func (r *Server) WithOptionsFns(fns ...func(*ServerOptions) *ServerOptions) *Server
WithOptionsFns sets functions to customize the ServerOptions used to create the apiserver
func (*Server) WithResourceAndHandler ¶
WithResourceAndHandler registers a request handler for the resource rather than the default etcd backend storage.
Note: WithResourceAndHandler should never be called after the GroupResource has already been registered with another version.
Note: WithResourceAndHandler will NOT register the "status" subresource for the resource object.
func (*Server) WithServerFns ¶
func (r *Server) WithServerFns(fns ...func(server *GenericAPIServer) *GenericAPIServer) *Server
WithServerFns sets functions to customize the GenericAPIServer
func (*Server) WithServerName ¶
func (*Server) WithoutEtcd ¶
WithoutEtcd removes etcd related settings from apiserver.
type ServerOptions ¶
type ServerOptions = options.ServerOptions
ServerOptions is an alias for apiserverbuilder.ServerOptions
type SingletonProvider ¶ added in v0.0.4
type SingletonProvider struct {
sync.Once
Provider *builderrest.StorageProvider
Storage registryrest.Storage
// contains filtered or unexported fields
}
singletonProvider ensures different versions of the same resource share storage
func (*SingletonProvider) Get ¶ added in v0.0.4
func (s *SingletonProvider) Get(ctx context.Context, scheme *runtime.Scheme, optsGetter generic.RESTOptionsGetter) (registryrest.Storage, error)
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
resourcerest
Package resourcerest defines interfaces for resource REST implementations.
|
Package resourcerest defines interfaces for resource REST implementations. |
|
resourcestrategy
Package resourcestrategy defines interfaces for customizing how resources are converted and stored.
|
Package resourcestrategy defines interfaces for customizing how resources are converted and stored. |