Documentation
¶
Index ¶
- func GetToken(r *http.Request) string
- func IsIntrospectionQuery(r *http.Request) bool
- func MatchURL(path string, appCfg config.Config) (clusterName string, kcpWorkspace string, valid bool)
- func SetContexts(r *http.Request, workspace, token string, enableKcp bool) *http.Request
- type AuthMetadata
- type CAMetadata
- type ClusterMetadata
- type ClusterRegistry
- func (cr *ClusterRegistry) Close() error
- func (cr *ClusterRegistry) GetCluster(name string) (*TargetCluster, bool)
- func (cr *ClusterRegistry) LoadCluster(schemaFilePath string) error
- func (cr *ClusterRegistry) RemoveCluster(schemaFilePath string) error
- func (cr *ClusterRegistry) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (cr *ClusterRegistry) UpdateCluster(schemaFilePath string) error
- type FileData
- type GraphQLHandler
- type GraphQLServer
- type RoundTripperFactory
- type TargetCluster
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsIntrospectionQuery ¶
IsIntrospectionQuery checks if the request contains a GraphQL introspection query
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 {
Definitions map[string]any `json:"definitions"`
ClusterMetadata *ClusterMetadata `json:"x-cluster-metadata,omitempty"`
}
FileData represents the data extracted from a schema file
type GraphQLHandler ¶
GraphQLHandler wraps a GraphQL schema and HTTP handler
type GraphQLServer ¶
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) 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