steve

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: Apache-2.0 Imports: 55 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OrgManagerGroup = "erda-org-manager"
	OrgOpsGroup     = "erda-org-ops"
	OrgSupportGroup = "erda-org-support"
)

Variables

View Source
var (
	UserGroups  map[string]UserGroupInfo
	RoleToGroup map[string]string
)
View Source
var (
	ServiceAccountExpression = `` /* 279-byte string literal not displayed */

	ClusterRoleExpression = `` /* 169-byte string literal not displayed */

	ClusterRoleBindingExpression = `` /* 1008-byte string literal not displayed */

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

Functions

func DefaultSchemaTemplates

func DefaultSchemaTemplates(ctx context.Context, clusterName string, cf *client.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 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) Delete

func (a *Aggregator) Delete(clusterName string) error

Delete closes a steve server for k8s cluster with clusterName and delete it from aggregator

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

type Options

type Options struct {
	// Controllers If the controllers are passed in the caller must also start the controllers
	Controllers                *steveserver.Controllers
	ClientFactory              *client.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 Server

type Server struct {
	http.Handler

	ClientFactory   *client.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) error

func (*Server) ListenAndServe

func (c *Server) ListenAndServe(ctx context.Context, httpsPort, httpPort int, opts *server.ListenOpts) 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)

type UserGroupInfo

type UserGroupInfo struct {
	ServiceAccountName      string
	ServiceAccountNamespace string
}

type UserGroupType

type UserGroupType string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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