Documentation
¶
Index ¶
- Constants
- func ConvertAndSendWatchEvent[T any](c *gin.Context, e watch.Event, target T) bool
- func ConvertWatchEventObject[T any](c *gin.Context, e watch.Event, _ T) (T, bool)
- func ErrorFromWatchEvent(e watch.Event) error
- func FilteredWatchEventType(eventType watch.EventType, matches bool) (watch.EventType, bool)
- func NewAuthMiddleware(ctx context.Context, cfg config.ServerConfig, client libClient.Client, ...) gin.HandlerFunc
- func NewHealthChecker() grpchealth.Checker
- func SendSSEWatchError(c *gin.Context, err error)
- func SendSSEWatchEvent[T any](c *gin.Context, eventType watch.EventType, obj T) bool
- func SendSSEWatchStartError(c *gin.Context, err error) bool
- func SetSSEHeaders(c *gin.Context)
- func WriteSSEKeepalive(c *gin.Context) bool
- type AuthMiddlewareOpt
- type ImageStageMap
- type RefreshResourceType
- type Server
- type TagMap
- type WatchEvent
Constants ¶
const ( GroupByImageRepository = "image_repo" GroupByGitRepository = "git_repo" GroupByChartRepository = "chart_repo" OrderByFirstSeen = "first_seen" OrderByTag = "tag" )
const CLIVersionHeader = "X-Kargo-CLI-Version"
CLIVersionHeader is the HTTP header used to convey the CLI version in requests to the API server.
TODO(krancour): Move this closer to CLI-version-checking middleware once it exists.
Variables ¶
This section is empty.
Functions ¶
func ConvertAndSendWatchEvent ¶
ConvertAndSendWatchEvent converts a watch event's object to the target type and sends it as an SSE event. It handles both unstructured objects (from real clients) and typed objects (from fake clients in tests). Returns true if the caller should continue processing (including on conversion errors), false if the watch should be terminated (write failure or a watch.Error event).
func ConvertWatchEventObject ¶
ConvertWatchEventObject converts a watch event's object to the target type. It handles both unstructured objects (from real clients) and typed objects (from fake clients in tests). Returns the converted object and true if successful, or the zero value and false if conversion failed.
func ErrorFromWatchEvent ¶
ErrorFromWatchEvent maps Kubernetes watch.Error events into client-visible errors that watch handlers can return or stream.
func FilteredWatchEventType ¶
FilteredWatchEventType returns the event type to send for a client-side filtered watch event. Kubernetes server-side selectors send a DELETED event when a previously matching object is modified so it no longer matches; this helper mirrors that behavior for filters we must evaluate in-process.
Because we hold no per-client matched set, we cannot tell whether a non-matching MODIFIED object previously matched, so we emit a synthetic DELETED for every non-matching MODIFIED event — including objects the client never received an ADDED for. This over-emits DELETEs relative to a real server-side selector, but a DELETE for an object the client is not tracking is a harmless no-op. Achieving exact fidelity would require tracking sent object identities per client, which is not worth the complexity here.
func NewAuthMiddleware ¶
func NewAuthMiddleware( ctx context.Context, cfg config.ServerConfig, client libClient.Client, opts ...AuthMiddlewareOpt, ) gin.HandlerFunc
NewAuthMiddleware returns an initialized Gin middleware handler for authentication.
func NewHealthChecker ¶
func NewHealthChecker() grpchealth.Checker
func SendSSEWatchError ¶
SendSSEWatchError sends a watch error as an SSE error event. Watch endpoints may have already sent response headers, so HTTP status codes are no longer a reliable way to report expired resource versions after streaming begins.
func SendSSEWatchEvent ¶
SendSSEWatchEvent sends an object as an SSE watch event. Returns true if the caller should continue processing, false if the watch should be terminated (write failure).
func SendSSEWatchStartError ¶
SendSSEWatchStartError sends startup watch errors that are part of the watch protocol as SSE error events. It returns true when the error was handled.
func SetSSEHeaders ¶
SetSSEHeaders configures the standard headers for Server-Sent Events (SSE) streaming on a gin context.
func WriteSSEKeepalive ¶
WriteSSEKeepalive writes a keepalive comment to keep the SSE connection alive. Returns true if successful, false if the write failed.
Types ¶
type AuthMiddlewareOpt ¶
type AuthMiddlewareOpt func(*authMiddleware)
AuthMiddlewareOpt is a functional option for configuring the auth middleware returned by NewAuthMiddleware.
func WithExemptPaths ¶
func WithExemptPaths(paths []string) AuthMiddlewareOpt
WithExemptPaths adds additional exempt paths for the auth middleware. These are added to the default exempt paths, which are /v1beta1/system/public-server-config and /v1beta1/login.
type ImageStageMap ¶ added in v1.8.8
ImageStageMap represents the stages where an image is used
type RefreshResourceType ¶ added in v1.8.8
type RefreshResourceType string
RefreshResourceType represents the type of Kargo resource to refresh.
const ( RefreshResourceTypeClusterConfig RefreshResourceType = "ClusterConfig" RefreshResourceTypeProjectConfig RefreshResourceType = "ProjectConfig" RefreshResourceTypeStage RefreshResourceType = "Stage" RefreshResourceTypeWarehouse RefreshResourceType = "Warehouse" )
RefreshResourceType constants for supported resource types. They are PascalCase representations of the Kargo resource kinds for compatibility purposes with Kubernetes REST mappers.
func (RefreshResourceType) IsNamespaced ¶ added in v1.8.8
func (t RefreshResourceType) IsNamespaced() bool
IsNamespaced returns true if the resource type is namespaced.
func (RefreshResourceType) NameEqualsProject ¶ added in v1.8.8
func (t RefreshResourceType) NameEqualsProject() bool
NameEqualsProject returns true if the name of the resource should be the same as the project name. This is true for ProjectConfig resources.
func (RefreshResourceType) String ¶ added in v1.8.8
func (t RefreshResourceType) String() string
String returns the string representation of the RefreshResourceType.
type Server ¶
func NewServer ¶
func NewServer( cfg config.ServerConfig, kubeClient kubernetes.Client, rolesDB rbac.RolesDatabase, sender event.Sender, ) Server
type TagMap ¶ added in v1.8.8
type TagMap struct {
Tags map[string]*ImageStageMap `json:"tags"`
} // @name TagMap
TagMap represents the tags for a repository
type WatchEvent ¶ added in v1.8.8
WatchEvent represents a watch event in an SSE stream. It contains the event type (ADDED, MODIFIED, DELETED) and the object that was affected.
Source Files
¶
- abort_promotion_v1alpha1.go
- abort_verification_v1alpha1.go
- admin_login_v1alpha1.go
- approve_freight_v1alpha1.go
- auth_middleware.go
- body_limit_middleware.go
- common.go
- create_api_token_v1alpha1.go
- create_config_map_v1alpha1.go
- create_generic_credentials_v1alpha1.go
- create_or_update_resource_v1alpha1.go
- create_repo_credentials_v1alpha1.go
- create_resource_v1alpha1.go
- create_role_v1alpha1.go
- delete_analysistemplate_v1alpha1.go
- delete_api_token_v1alpha1.go
- delete_cluster_config_v1alpha1.go
- delete_clusteranalysistemplate_v1alpha1.go
- delete_config_map_v1alpha1.go
- delete_freight_v1alpha1.go
- delete_generic_credentials_v1alpha1.go
- delete_project_config_v1alpha1.go
- delete_project_v1alpha1.go
- delete_repo_credentials_v1alpha1.go
- delete_resource_v1alpha1.go
- delete_role_v1alpha1.go
- delete_stage_v1alpha1.go
- delete_warehouse_v1alpha1.go
- get_analysisrun_logs_v1alpha1.go
- get_analysisrun_v1alpha1.go
- get_analysistemplate_v1alpha1.go
- get_api_token_v1alpha1.go
- get_cluster_config_v1alpha1.go
- get_cluster_promotion_task_v1alpha1.go
- get_clusteranalysistemplate_v1alpha1.go
- get_config_map_v1alpha1.go
- get_config_v1alpha1.go
- get_controller_heartbeats_v1alpha1.go
- get_freight_links_v1alpha1.go
- get_freight_v1alpha1.go
- get_generic_credentials_v1alpha1.go
- get_project_config_v1alpha1.go
- get_project_v1alpha1.go
- get_promotion_task_v1alpha1.go
- get_promotion_v1alpha1.go
- get_public_config_v1alpha1.go
- get_repo_credentials_v1alpha1.go
- get_role_v1alpha1.go
- get_stage_links_v1alpha1.go
- get_stage_v1alpha1.go
- get_version_info_v1alpha1.go
- get_warehouse_v1alpha1.go
- grant_v1alpha1.go
- grpc_health.go
- list_analysistemplates_v1alpha1.go
- list_api_tokens_v1alpha1.go
- list_cluster_promotion_tasks_v1alpha1.go
- list_clusteranalysistemplates_v1alpha1.go
- list_config_maps_v1alpha1.go
- list_for_watch_seed.go
- list_generic_credentials_v1alpha1.go
- list_images_v1alpha1.go
- list_project_events_v1alpha1.go
- list_projects_v1alpha1.go
- list_promotion_tasks_v1alpha1.go
- list_promotions_v1alpha1.go
- list_repo_credentials_v1alpha1.go
- list_roles_v1alpha1.go
- list_stages_v1alpha1.go
- list_warehouses_v1alpha1.go
- patch_config_map_v1alpha1.go
- patch_generic_credentials_v1alpha1.go
- patch_repo_credentials_v1alpha1.go
- project_middleware.go
- promote_downstream_v1alpha1.go
- promote_to_stage_v1alpha1.go
- query_freights_v1alpha1.go
- refresh_cluster_config_v1alpha1.go
- refresh_project_config_v1alpha1.go
- refresh_promotion_v1alpha1.go
- refresh_stage_v1alpha1.go
- refresh_v1alpha1.go
- refresh_warehouse_v1alpha1.go
- resource_version.go
- rest_router.go
- reverify_v1alpha1.go
- revoke_v1alpha1.go
- server.go
- update_config_map_v1alpha1.go
- update_freight_alias_v1alpha1.go
- update_generic_credentials_v1alpha1.go
- update_repo_credentials_v1alpha1.go
- update_resource_v1alpha1.go
- update_role_v1alpha1.go
- validators.go
- watch_cluster_config_v1alpha1.go
- watch_freight_v1alpha1.go
- watch_helpers.go
- watch_project_config_v1alpha1.go
- watch_promotion_v1alpha1.go
- watch_promotions_v1alpha1.go
- watch_stages_v1alpha1.go
- watch_warehouses_v1alpha1.go