steve

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: Apache-2.0 Imports: 101 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const OfflineLabel = "dice/offline"

Variables

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

Functions

func DefaultAPIServer

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

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

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 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, 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 CacheKey

type CacheKey struct {
	Kind        string
	Namespace   string
	ClusterName string
}

func (*CacheKey) GetKey

func (k *CacheKey) GetKey() string

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)

func (*Controllers) Start

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

type DynamicColumns

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

func NewDynamicColumns

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

func (*DynamicColumns) SetColumns

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

type Factory

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

func NewFactory

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

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 (p *Factory) AdminDynamicClient() dynamic.Interface

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 (p *Factory) IsImpersonating() bool

func (*Factory) K8sInterface

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

func (*Factory) MetadataClient

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

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

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

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