Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultAPIServer() *server.Server
- func DefaultSchemaTemplates(ctx context.Context, clusterName string, cf *Factory, ...) []schema.Template
- func DefaultSchemas(baseSchema *types.APISchemas)
- func DefaultTemplate(ctx context.Context, clusterName string, clientGetter proxy.ClientGetter, ...) schema.Template
- func GetURLPrefix(clusterName string) string
- func NewHandler(cfg *rest.Config, sf schema.Factory, authMiddleware auth.Middleware, ...) (*apiserver.Server, http.Handler, error)
- func NewPrefixed(r *http.Request, schemas *types.APISchemas, prefix string) (types.URLBuilder, error)
- func Parse(apiOp *types.APIRequest, urlParser parse.URLParser) error
- func Register(ctx context.Context, cols *DynamicColumns, ...)
- func RemoveCache(clusterName, namespace, kind string)
- func RoutesWrapper(prefix string) router.RouterFunc
- type APIFunc
- type Aggregator
- func (a *Aggregator) Add(clusterInfo *clusterpb.ClusterInfo)
- func (a *Aggregator) Audit(userID, orgID, templateName string, ctx map[string]interface{}) error
- func (a *Aggregator) Auth(userID, orgID, clusterName string) (apiuser.Info, error)
- func (a *Aggregator) CordonNode(ctx context.Context, req *apistructs.SteveRequest) error
- func (a *Aggregator) CreateSteveResource(ctx context.Context, req *apistructs.SteveRequest) (types.APIObject, error)
- func (a *Aggregator) Delete(clusterName string)
- func (a *Aggregator) DeleteSteveResource(ctx context.Context, req *apistructs.SteveRequest) error
- func (a *Aggregator) DrainNode(ctx context.Context, req *apistructs.SteveRequest) error
- func (a *Aggregator) GetAllClusters() []string
- func (a *Aggregator) GetSteveResource(ctx context.Context, req *apistructs.SteveRequest) (types.APIObject, error)
- func (a *Aggregator) HasAccess(clusterName string, apiOp *types.APIRequest, verb string) (bool, error)
- func (a *Aggregator) IsServerReady(clusterName string) bool
- func (a *Aggregator) LabelNode(ctx context.Context, req *apistructs.SteveRequest, labels map[string]string) error
- func (a *Aggregator) ListClusters() (ready, unready []string)
- func (a *Aggregator) ListSteveResource(ctx context.Context, req *apistructs.SteveRequest) ([]types.APIObject, error)
- func (a *Aggregator) OfflineNode(ctx context.Context, userID, orgID, clusterName string, nodeIDs []string) error
- func (a *Aggregator) OnlineNode(ctx context.Context, req *apistructs.SteveRequest) error
- func (a *Aggregator) PatchNode(ctx context.Context, req *apistructs.SteveRequest) error
- func (a *Aggregator) Serve(clusterName string, apiOp *types.APIRequest) error
- func (a *Aggregator) ServeHTTP(rw http.ResponseWriter, req *http.Request)
- func (a *Aggregator) UnCordonNode(ctx context.Context, req *apistructs.SteveRequest) error
- func (a *Aggregator) UnlabelNode(ctx context.Context, req *apistructs.SteveRequest, labels []string) error
- func (a *Aggregator) UpdateSteveResource(ctx context.Context, req *apistructs.SteveRequest) (types.APIObject, error)
- type CacheKey
- type ColumnDefinition
- type Controllers
- type DynamicColumns
- type Factory
- func (p *Factory) AdminClient(ctx *types.APIRequest, s *types.APISchema, namespace string, ...) (dynamic.ResourceInterface, error)
- func (p *Factory) AdminClientForWatch(ctx *types.APIRequest, s *types.APISchema, namespace string, ...) (dynamic.ResourceInterface, error)
- func (p *Factory) AdminDynamicClient() dynamic.Interface
- func (p *Factory) AdminK8sInterface() (kubernetes.Interface, error)
- func (p *Factory) Client(ctx *types.APIRequest, s *types.APISchema, namespace string, ...) (dynamic.ResourceInterface, error)
- func (p *Factory) ClientForWatch(ctx *types.APIRequest, s *types.APISchema, namespace string, ...) (dynamic.ResourceInterface, error)
- func (p *Factory) DynamicClient(ctx *types.APIRequest, warningHandler rest.WarningHandler) (dynamic.Interface, error)
- func (p *Factory) IsImpersonating() bool
- func (p *Factory) K8sInterface(ctx *types.APIRequest) (kubernetes.Interface, error)
- func (p *Factory) MetadataClient() metadata.Interface
- func (p *Factory) TableAdminClient(ctx *types.APIRequest, s *types.APISchema, namespace string, ...) (dynamic.ResourceInterface, error)
- func (p *Factory) TableAdminClientForWatch(ctx *types.APIRequest, s *types.APISchema, namespace string, ...) (dynamic.ResourceInterface, error)
- func (p *Factory) TableClient(ctx *types.APIRequest, s *types.APISchema, namespace string, ...) (dynamic.ResourceInterface, error)
- func (p *Factory) TableClientForWatch(ctx *types.APIRequest, s *types.APISchema, namespace string, ...) (dynamic.ResourceInterface, error)
- type Options
- type PrefixedURLBuilder
- type Response
- type SchemasHandler
- type Server
- type StatusCodeGetter
Constants ¶
const OfflineLabel = "dice/offline"
Variables ¶
var ErrConfigRequired = errors.New("rest config is required")
Functions ¶
func DefaultAPIServer ¶
func DefaultSchemaTemplates ¶
func DefaultSchemaTemplates(ctx context.Context, clusterName string, cf *Factory, discovery discovery.DiscoveryInterface, asl accesscontrol.AccessSetLookup) []schema.Template
func DefaultSchemas ¶
func DefaultSchemas(baseSchema *types.APISchemas)
func DefaultTemplate ¶
func DefaultTemplate(ctx context.Context, clusterName string, clientGetter proxy.ClientGetter, asl accesscontrol.AccessSetLookup) schema.Template
func GetURLPrefix ¶
GetURLPrefix get steve API prefix with cluster name
func NewHandler ¶
func NewHandler(cfg *rest.Config, sf schema.Factory, authMiddleware auth.Middleware, next http.Handler, routerFunc router.RouterFunc, prefix string) (*apiserver.Server, http.Handler, error)
NewHandler return an rancher api server and a steve server handler
func NewPrefixed ¶
func NewPrefixed(r *http.Request, schemas *types.APISchemas, prefix string) (types.URLBuilder, error)
func Register ¶
func Register(ctx context.Context, cols *DynamicColumns, discovery discovery.DiscoveryInterface, crd apiextcontrollerv1.CustomResourceDefinitionController, apiService v1.APIServiceController, ssar authorizationv1client.SelfSubjectAccessReviewInterface, schemasHandler SchemasHandler, schemas *schema2.Collection)
func RemoveCache ¶
func RemoveCache(clusterName, namespace, kind string)
func RoutesWrapper ¶
func RoutesWrapper(prefix string) router.RouterFunc
RoutesWrapper wraps a router for steve server with different prefix
Types ¶
type Aggregator ¶
type Aggregator struct { Ctx context.Context Bdl *bundle.Bundle // contains filtered or unexported fields }
func NewAggregator ¶
func NewAggregator(ctx context.Context, bdl *bundle.Bundle, clusterSvc clusterpb.ClusterServiceServer, size int) *Aggregator
NewAggregator new an aggregator with steve servers for all current clusters
func (*Aggregator) Add ¶
func (a *Aggregator) Add(clusterInfo *clusterpb.ClusterInfo)
Add starts a steve server for k8s cluster with clusterName and add it into aggregator
func (*Aggregator) Audit ¶
func (a *Aggregator) Audit(userID, orgID, templateName string, ctx map[string]interface{}) error
Audit creates an audit event by bundle.
func (*Aggregator) Auth ¶
func (a *Aggregator) Auth(userID, orgID, clusterName string) (apiuser.Info, error)
Auth authenticates by userID and orgID.
func (*Aggregator) CordonNode ¶
func (a *Aggregator) CordonNode(ctx context.Context, req *apistructs.SteveRequest) error
CordonNode cordons a node and creates an audit event. Required fields: ClusterName, Name
func (*Aggregator) CreateSteveResource ¶
func (a *Aggregator) CreateSteveResource(ctx context.Context, req *apistructs.SteveRequest) (types.APIObject, error)
CreateSteveResource creates a k8s resource described by req.Obj from steve server and creates an audit event. Required fields: ClusterName, Type, Obj
func (*Aggregator) Delete ¶
func (a *Aggregator) Delete(clusterName string)
Delete closes a steve server for k8s cluster with clusterName and delete it from aggregator
func (*Aggregator) DeleteSteveResource ¶
func (a *Aggregator) DeleteSteveResource(ctx context.Context, req *apistructs.SteveRequest) error
DeleteSteveResource delete a k8s resource from steve server and creates an audit event. Required fields: ClusterName, Type, Name
func (*Aggregator) DrainNode ¶
func (a *Aggregator) DrainNode(ctx context.Context, req *apistructs.SteveRequest) error
DrainNode drains a node and creates an audit event.
func (*Aggregator) GetAllClusters ¶
func (a *Aggregator) GetAllClusters() []string
func (*Aggregator) GetSteveResource ¶
func (a *Aggregator) GetSteveResource(ctx context.Context, req *apistructs.SteveRequest) (types.APIObject, error)
GetSteveResource gets k8s resource from steve server. Required fields: ClusterName, Name, Type.
func (*Aggregator) HasAccess ¶
func (a *Aggregator) HasAccess(clusterName string, apiOp *types.APIRequest, verb string) (bool, error)
HasAccess set schemas for apiOp and check access for user in apiOp
func (*Aggregator) IsServerReady ¶
func (a *Aggregator) IsServerReady(clusterName string) bool
func (*Aggregator) LabelNode ¶
func (a *Aggregator) LabelNode(ctx context.Context, req *apistructs.SteveRequest, labels map[string]string) error
LabelNode labels a node and creates an audit event. Required filed: ClusterName, Name, labels
func (*Aggregator) ListClusters ¶
func (a *Aggregator) ListClusters() (ready, unready []string)
ListClusters list ready and unready clusters in steveAggregator
func (*Aggregator) ListSteveResource ¶
func (a *Aggregator) ListSteveResource(ctx context.Context, req *apistructs.SteveRequest) ([]types.APIObject, error)
ListSteveResource lists k8s resource from steve server. Required fields: ClusterName, Type.
func (*Aggregator) OfflineNode ¶
func (a *Aggregator) OfflineNode(ctx context.Context, userID, orgID, clusterName string, nodeIDs []string) error
OfflineNode offlines a node by sending request to monitor. And creates an audit event. nodeID format: nodeName/hostIP
func (*Aggregator) OnlineNode ¶
func (a *Aggregator) OnlineNode(ctx context.Context, req *apistructs.SteveRequest) error
OnlineNode onlines a node by removing node offline label. And creates an audit event.
func (*Aggregator) PatchNode ¶
func (a *Aggregator) PatchNode(ctx context.Context, req *apistructs.SteveRequest) error
PatchNode patch a node described by req.Obj from steve server. Required fields: ClusterName, Name, Obj
func (*Aggregator) Serve ¶
func (a *Aggregator) Serve(clusterName string, apiOp *types.APIRequest) error
func (*Aggregator) ServeHTTP ¶
func (a *Aggregator) ServeHTTP(rw http.ResponseWriter, req *http.Request)
ServeHTTP forwards API request to corresponding steve server
func (*Aggregator) UnCordonNode ¶
func (a *Aggregator) UnCordonNode(ctx context.Context, req *apistructs.SteveRequest) error
UnCordonNode uncordons a node and creates an audit event. Required fields: ClusterName, Name
func (*Aggregator) UnlabelNode ¶
func (a *Aggregator) UnlabelNode(ctx context.Context, req *apistructs.SteveRequest, labels []string) error
UnlabelNode unlabels a node and creates an audit event. Required filed: ClusterName, Name, labels
func (*Aggregator) UpdateSteveResource ¶
func (a *Aggregator) UpdateSteveResource(ctx context.Context, req *apistructs.SteveRequest) (types.APIObject, error)
UpdateSteveResource update a k8s resource described by req.Obj from steve server and creates an audit event. Required fields: ClusterName, Type, Name, Obj
type ColumnDefinition ¶
type ColumnDefinition struct { metav1.TableColumnDefinition `json:",inline"` Field string `json:"field,omitempty"` }
type Controllers ¶
type Controllers struct { RESTConfig *rest.Config K8s kubernetes.Interface Core corev1.Interface RBAC rbacv1.Interface API apiregistrationv1.Interface CRD apiextensionsv1.Interface // contains filtered or unexported fields }
func NewController ¶
func NewController(cfg *rest.Config, opts *generic.FactoryOptions) (*Controllers, error)
type DynamicColumns ¶
type DynamicColumns struct {
// contains filtered or unexported fields
}
func NewDynamicColumns ¶
func NewDynamicColumns(config *rest.Config) (*DynamicColumns, error)
func (*DynamicColumns) SetColumns ¶
type Factory ¶
func (*Factory) AdminClient ¶
func (p *Factory) AdminClient(ctx *types.APIRequest, s *types.APISchema, namespace string, warningHandler rest.WarningHandler) (dynamic.ResourceInterface, error)
func (*Factory) AdminClientForWatch ¶
func (p *Factory) AdminClientForWatch(ctx *types.APIRequest, s *types.APISchema, namespace string, warningHandler rest.WarningHandler) (dynamic.ResourceInterface, error)
func (*Factory) AdminDynamicClient ¶
func (*Factory) AdminK8sInterface ¶
func (p *Factory) AdminK8sInterface() (kubernetes.Interface, error)
func (*Factory) Client ¶
func (p *Factory) Client(ctx *types.APIRequest, s *types.APISchema, namespace string, warningHandler rest.WarningHandler) (dynamic.ResourceInterface, error)
func (*Factory) ClientForWatch ¶
func (p *Factory) ClientForWatch(ctx *types.APIRequest, s *types.APISchema, namespace string, warningHandler rest.WarningHandler) (dynamic.ResourceInterface, error)
func (*Factory) DynamicClient ¶
func (p *Factory) DynamicClient(ctx *types.APIRequest, warningHandler rest.WarningHandler) (dynamic.Interface, error)
func (*Factory) IsImpersonating ¶
func (*Factory) K8sInterface ¶
func (p *Factory) K8sInterface(ctx *types.APIRequest) (kubernetes.Interface, error)
func (*Factory) MetadataClient ¶
func (*Factory) TableAdminClient ¶
func (p *Factory) TableAdminClient(ctx *types.APIRequest, s *types.APISchema, namespace string, warningHandler rest.WarningHandler) (dynamic.ResourceInterface, error)
func (*Factory) TableAdminClientForWatch ¶
func (p *Factory) TableAdminClientForWatch(ctx *types.APIRequest, s *types.APISchema, namespace string, warningHandler rest.WarningHandler) (dynamic.ResourceInterface, error)
func (*Factory) TableClient ¶
func (p *Factory) TableClient(ctx *types.APIRequest, s *types.APISchema, namespace string, warningHandler rest.WarningHandler) (dynamic.ResourceInterface, error)
func (*Factory) TableClientForWatch ¶
func (p *Factory) TableClientForWatch(ctx *types.APIRequest, s *types.APISchema, namespace string, warningHandler rest.WarningHandler) (dynamic.ResourceInterface, error)
type Options ¶
type Options struct { // Controllers If the controllers are passed in the caller must also start the controllers Controllers *Controllers ClientFactory *Factory AccessSetLookup accesscontrol.AccessSetLookup AuthMiddleware auth.Middleware Next http.Handler Router router.RouterFunc AggregationSecretNamespace string AggregationSecretName string ClusterRegistry string URLPrefix string ClusterName string }
type PrefixedURLBuilder ¶
type PrefixedURLBuilder struct { types.URLBuilder // contains filtered or unexported fields }
func (*PrefixedURLBuilder) RelativeToRoot ¶
func (u *PrefixedURLBuilder) RelativeToRoot(path string) string
type Response ¶
type Response struct { StatusCode int ResponseData interface{} }
func (*Response) WriteList ¶
func (rw *Response) WriteList(apiOp *types.APIRequest, code int, obj types.APIObjectList)
type SchemasHandler ¶
type SchemasHandler interface {
OnSchemas(schemas *schema2.Collection) error
}
type Server ¶
type Server struct { http.Handler ClientFactory *Factory ClusterCache clustercache.ClusterCache SchemaFactory schema.Factory RESTConfig *rest.Config BaseSchemas *types.APISchemas AccessSetLookup accesscontrol.AccessSetLookup APIServer *apiserver.Server ClusterRegistry string URLPrefix string ClusterName string // contains filtered or unexported fields }
func (*Server) Handle ¶
func (c *Server) Handle(apiOp *types.APIRequest)
func (*Server) ListenAndServe ¶
func (*Server) SetSchemas ¶
func (c *Server) SetSchemas(apiOp *types.APIRequest) error
func (*Server) StartAggregation ¶
type StatusCodeGetter ¶
type StatusCodeGetter struct {
Response *Response
}
func (*StatusCodeGetter) Header ¶
func (scg *StatusCodeGetter) Header() http.Header
func (*StatusCodeGetter) WriteHeader ¶
func (scg *StatusCodeGetter) WriteHeader(code int)