targetcluster

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2025 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetToken

func GetToken(r *http.Request) string

GetToken extracts the token from the request Authorization header

func IsIntrospectionQuery

func IsIntrospectionQuery(r *http.Request) bool

IsIntrospectionQuery checks if the request contains a GraphQL introspection query

func MatchURL

func MatchURL(path string, appCfg config.Config) (clusterName string, kcpWorkspace string, valid bool)

MatchURL attempts to match the given path against known patterns and extract variables

func SetContexts

func SetContexts(r *http.Request, workspace, token string, enableKcp bool) *http.Request

SetContexts sets the required contexts for KCP and authentication

Types

type AuthMetadata

type AuthMetadata struct {
	Type       string `json:"type"`
	Token      string `json:"token,omitempty"`
	Kubeconfig string `json:"kubeconfig,omitempty"`
	CertData   string `json:"certData,omitempty"`
	KeyData    string `json:"keyData,omitempty"`
}

AuthMetadata represents authentication information

type CAMetadata

type CAMetadata struct {
	Data string `json:"data"`
}

CAMetadata represents CA certificate information

type ClusterMetadata

type ClusterMetadata struct {
	Host string        `json:"host"`
	Path string        `json:"path,omitempty"`
	Auth *AuthMetadata `json:"auth,omitempty"`
	CA   *CAMetadata   `json:"ca,omitempty"`
}

ClusterMetadata represents the cluster connection metadata stored in schema files

type ClusterRegistry

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

ClusterRegistry manages multiple target clusters and handles HTTP routing to them

func NewClusterRegistry

func NewClusterRegistry(
	log *logger.Logger,
	appCfg appConfig.Config,
	roundTripperFactory RoundTripperFactory,
) *ClusterRegistry

NewClusterRegistry creates a new cluster registry

func (*ClusterRegistry) Close

func (cr *ClusterRegistry) Close() error

Close closes all clusters and cleans up the registry

func (*ClusterRegistry) GetCluster

func (cr *ClusterRegistry) GetCluster(name string) (*TargetCluster, bool)

GetCluster returns a cluster by name

func (*ClusterRegistry) LoadCluster

func (cr *ClusterRegistry) LoadCluster(schemaFilePath string) error

LoadCluster loads a target cluster from a schema file

func (*ClusterRegistry) RemoveCluster

func (cr *ClusterRegistry) RemoveCluster(schemaFilePath string) error

RemoveCluster removes a cluster by schema file path

func (*ClusterRegistry) ServeHTTP

func (cr *ClusterRegistry) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP routes HTTP requests to the appropriate target cluster

func (*ClusterRegistry) UpdateCluster

func (cr *ClusterRegistry) UpdateCluster(schemaFilePath string) error

UpdateCluster updates an existing cluster from a schema file

type FileData

type FileData struct {
	Components      *spec3.Components `json:"components,omitempty"`
	ClusterMetadata *ClusterMetadata  `json:"x-cluster-metadata,omitempty"`
}

FileData represents the data extracted from a schema file

type GraphQLHandler

type GraphQLHandler struct {
	Schema  *graphql.Schema
	Handler http.Handler
}

GraphQLHandler wraps a GraphQL schema and HTTP handler

type GraphQLServer

type GraphQLServer struct {
	AppCfg appConfig.Config
	// contains filtered or unexported fields
}

GraphQLServer provides utility methods for creating GraphQL handlers

func NewGraphQLServer

func NewGraphQLServer(log *logger.Logger, appCfg appConfig.Config) *GraphQLServer

NewGraphQLServer creates a new GraphQL server

func (*GraphQLServer) CreateHandler

func (s *GraphQLServer) CreateHandler(schema *graphql.Schema) *GraphQLHandler

CreateHandler creates a new GraphQL handler from a schema

func (*GraphQLServer) HandleSubscription

func (s *GraphQLServer) HandleSubscription(w http.ResponseWriter, r *http.Request, schema *graphql.Schema)

HandleSubscription handles GraphQL subscription requests using Server-Sent Events

type RoundTripperFactory

type RoundTripperFactory func(http.RoundTripper, rest.TLSClientConfig) http.RoundTripper

RoundTripperFactory creates HTTP round trippers for authentication

type TargetCluster

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

TargetCluster represents a single target Kubernetes cluster

func NewTargetCluster

func NewTargetCluster(
	name string,
	schemaFilePath string,
	log *logger.Logger,
	appCfg appConfig.Config,
	roundTripperFactory func(http.RoundTripper, rest.TLSClientConfig) http.RoundTripper,
) (*TargetCluster, error)

NewTargetCluster creates a new TargetCluster from a schema file

func (*TargetCluster) GetConfig

func (tc *TargetCluster) GetConfig() *rest.Config

GetConfig returns the cluster's rest.Config

func (*TargetCluster) GetEndpoint

func (tc *TargetCluster) GetEndpoint(appCfg appConfig.Config) string

GetEndpoint returns the HTTP endpoint for this cluster's GraphQL API

func (*TargetCluster) GetHandler added in v0.2.3

func (tc *TargetCluster) GetHandler() *GraphQLHandler

GetHandler returns the cluster's GraphQL handler (useful for testing)

func (*TargetCluster) GetName

func (tc *TargetCluster) GetName() string

GetName returns the cluster name

func (*TargetCluster) ServeHTTP

func (tc *TargetCluster) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP handles HTTP requests for this cluster

Jump to

Keyboard shortcuts

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