steve

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2022 License: Apache-2.0 Imports: 94 Imported by: 0

Documentation

Index

Constants

View Source
const OfflineLabel = "dice/offline"

Variables

View Source
var ErrConfigRequired = errors.New("rest config is required")

Functions

func DefaultAPIServer added in v1.5.0

func DefaultAPIServer() *server.Server

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

func GetURLPrefix(clusterName string) string

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 Parse added in v1.5.0

func Parse(apiOp *types.APIRequest, urlParser parse.URLParser) error

func RemoveCache added in v1.4.0

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 APIFunc

type APIFunc func(schema.Factory, *types.APIRequest)

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) *Aggregator

NewAggregator new an aggregator with steve servers for all current clusters

func (*Aggregator) Add

func (a *Aggregator) Add(clusterInfo apistructs.ClusterInfo)

Add starts a steve server for k8s cluster with clusterName and add it into aggregator

func (*Aggregator) Audit added in v1.4.0

func (a *Aggregator) Audit(userID, orgID, templateName string, ctx map[string]interface{}) error

Audit creates an audit event by bundle.

func (*Aggregator) Auth added in v1.4.0

func (a *Aggregator) Auth(userID, orgID, clusterName string) (apiuser.Info, error)

Auth authenticates by userID and orgID.

func (*Aggregator) CordonNode added in v1.4.0

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 added in v1.4.0

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 added in v1.4.0

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 added in v1.4.0

func (a *Aggregator) DrainNode(ctx context.Context, req *apistructs.SteveRequest) error

DrainNode drains a node and creates an audit event.

func (*Aggregator) GetAllClusters added in v1.4.0

func (a *Aggregator) GetAllClusters() []string

func (*Aggregator) GetSteveResource added in v1.4.0

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 added in v1.4.0

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 added in v1.4.0

func (a *Aggregator) IsServerReady(clusterName string) bool

func (*Aggregator) LabelNode added in v1.4.0

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 added in v1.5.0

func (a *Aggregator) ListClusters() (ready, unready []string)

ListClusters list ready and unready clusters in steveAggregator

func (*Aggregator) ListSteveResource added in v1.4.0

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 added in v1.4.0

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 added in v1.4.0

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 added in v1.4.0

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 added in v1.4.0

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 added in v1.4.0

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 added in v1.4.0

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 CacheKey added in v1.4.0

type CacheKey struct {
	Kind        string
	Namespace   string
	ClusterName string
}

func (*CacheKey) GetKey added in v1.4.0

func (k *CacheKey) GetKey() string

type ColumnDefinition added in v1.5.0

type ColumnDefinition struct {
	metav1.TableColumnDefinition `json:",inline"`
	Field                        string `json:"field,omitempty"`
}

type Controllers added in v1.4.0

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 added in v1.4.0

func NewController(cfg *rest.Config, opts *generic.FactoryOptions) (*Controllers, error)

func (*Controllers) Start added in v1.4.0

func (c *Controllers) Start(ctx context.Context) error

type DynamicColumns added in v1.5.0

type DynamicColumns struct {
	// contains filtered or unexported fields
}

func NewDynamicColumns added in v1.5.0

func NewDynamicColumns(config *rest.Config) (*DynamicColumns, error)

func (*DynamicColumns) SetColumns added in v1.5.0

func (d *DynamicColumns) SetColumns(ctx context.Context, schema *types.APISchema) error

type Factory added in v1.4.0

type Factory struct {
	Config *rest.Config
	// contains filtered or unexported fields
}

func NewFactory added in v1.4.0

func NewFactory(cfg *rest.Config, impersonate bool) (*Factory, error)

func (*Factory) AdminClient added in v1.4.0

func (p *Factory) AdminClient(ctx *types.APIRequest, s *types.APISchema, namespace string) (dynamic.ResourceInterface, error)

func (*Factory) AdminClientForWatch added in v1.4.0

func (p *Factory) AdminClientForWatch(ctx *types.APIRequest, s *types.APISchema, namespace string) (dynamic.ResourceInterface, error)

func (*Factory) AdminDynamicClient added in v1.4.0

func (p *Factory) AdminDynamicClient() dynamic.Interface

func (*Factory) AdminK8sInterface added in v1.4.0

func (p *Factory) AdminK8sInterface() (kubernetes.Interface, error)

func (*Factory) Client added in v1.4.0

func (p *Factory) Client(ctx *types.APIRequest, s *types.APISchema, namespace string) (dynamic.ResourceInterface, error)

func (*Factory) ClientForWatch added in v1.4.0

func (p *Factory) ClientForWatch(ctx *types.APIRequest, s *types.APISchema, namespace string) (dynamic.ResourceInterface, error)

func (*Factory) DynamicClient added in v1.4.0

func (p *Factory) DynamicClient(ctx *types.APIRequest) (dynamic.Interface, error)

func (*Factory) IsImpersonating added in v1.4.0

func (p *Factory) IsImpersonating() bool

func (*Factory) K8sInterface added in v1.4.0

func (p *Factory) K8sInterface(ctx *types.APIRequest) (kubernetes.Interface, error)

func (*Factory) MetadataClient added in v1.4.0

func (p *Factory) MetadataClient() metadata.Interface

func (*Factory) TableAdminClient added in v1.4.0

func (p *Factory) TableAdminClient(ctx *types.APIRequest, s *types.APISchema, namespace string) (dynamic.ResourceInterface, error)

func (*Factory) TableAdminClientForWatch added in v1.4.0

func (p *Factory) TableAdminClientForWatch(ctx *types.APIRequest, s *types.APISchema, namespace string) (dynamic.ResourceInterface, error)

func (*Factory) TableClient added in v1.4.0

func (p *Factory) TableClient(ctx *types.APIRequest, s *types.APISchema, namespace string) (dynamic.ResourceInterface, error)

func (*Factory) TableClientForWatch added in v1.4.0

func (p *Factory) TableClientForWatch(ctx *types.APIRequest, s *types.APISchema, namespace string) (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) Write

func (rw *Response) Write(apiOp *types.APIRequest, code int, obj types.APIObject)

func (*Response) WriteList

func (rw *Response) WriteList(apiOp *types.APIRequest, code int, obj types.APIObjectList)

type SchemasHandler added in v1.5.0

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 New

func New(ctx context.Context, restConfig *rest.Config, opts *Options) (*Server, error)

New create a steve server

func (*Server) Handle

func (c *Server) Handle(apiOp *types.APIRequest)

func (*Server) ListenAndServe

func (c *Server) ListenAndServe(ctx context.Context, httpsPort, httpPort int, opts *server.ListenOpts) error

func (*Server) SetSchemas added in v1.4.0

func (c *Server) SetSchemas(apiOp *types.APIRequest) error

func (*Server) StartAggregation

func (c *Server) StartAggregation(ctx context.Context)

type StatusCodeGetter

type StatusCodeGetter struct {
	Response *Response
}

func (*StatusCodeGetter) Header

func (scg *StatusCodeGetter) Header() http.Header

func (*StatusCodeGetter) Write

func (scg *StatusCodeGetter) Write([]byte) (int, error)

func (*StatusCodeGetter) WriteHeader

func (scg *StatusCodeGetter) WriteHeader(code int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL