Documentation
¶
Index ¶
- func RegisterRoutes(api huma.API, imagePatchService *Service, ...)
- type ImagePatchHandler
- func (h *ImagePatchHandler) ListImagePatches(ctx context.Context, input *ListImagePatchesInput) (*handlerutil.Page[imagepatch.PatchRecord], error)
- func (h *ImagePatchHandler) ListPatchTargets(ctx context.Context, input *ListPatchTargetsInput) (*handlerutil.Page[imagepatch.PatchTarget], error)
- func (h *ImagePatchHandler) PatchImage(ctx context.Context, input *PatchImageInput) (*handlerutil.Out[imagepatch.PatchRecord], error)
- type ImagePatchRecord
- type ListImagePatchesInput
- type ListPatchTargetsInput
- type PatchImageInput
- type Service
- func (s *Service) AggregatePatchTargets(ctx context.Context, params pagination.QueryParams) (base.Paginated[imagepatch.PatchTarget], error)
- func (s *Service) ListPatchTargets(ctx context.Context, envID string, params pagination.QueryParams) ([]imagepatch.PatchTarget, pagination.Response, error)
- func (s *Service) ListPatches(ctx context.Context, envID string, params pagination.QueryParams) ([]imagepatch.PatchRecord, pagination.Response, error)
- func (s *Service) PatchImage(ctx context.Context, envID, imageID string, opts imagepatch.PatchOptions, ...) (*imagepatch.PatchRecord, error)
- func (s *Service) PatchTarget(ctx context.Context, envID string, target Target, recordID string) error
- func (s *Service) PatchedRefs(ctx context.Context, envID string) (map[string]struct{}, error)
- func (s *Service) RecoverInterruptedPatches(ctx context.Context) error
- func (s *Service) Targets(ctx context.Context, envID string) ([]Target, error)
- type Target
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterRoutes ¶
func RegisterRoutes(api huma.API, imagePatchService *Service, appCtx handlerutil.ActivityAppContext)
RegisterRoutes registers image patching routes.
Types ¶
type ImagePatchHandler ¶
type ImagePatchHandler struct {
// contains filtered or unexported fields
}
ImagePatchHandler provides Huma-based image patching endpoints.
func (*ImagePatchHandler) ListImagePatches ¶
func (h *ImagePatchHandler) ListImagePatches(ctx context.Context, input *ListImagePatchesInput) (*handlerutil.Page[imagepatch.PatchRecord], error)
ListImagePatches returns the paginated patch history for the environment.
func (*ImagePatchHandler) ListPatchTargets ¶
func (h *ImagePatchHandler) ListPatchTargets(ctx context.Context, input *ListPatchTargetsInput) (*handlerutil.Page[imagepatch.PatchTarget], error)
ListPatchTargets returns scanned images with fixable counts and latest patch runs.
func (*ImagePatchHandler) PatchImage ¶
func (h *ImagePatchHandler) PatchImage(ctx context.Context, input *PatchImageInput) (*handlerutil.Out[imagepatch.PatchRecord], error)
PatchImage starts a background patch run for an image.
type ImagePatchRecord ¶
type ImagePatchRecord struct {
database.BaseModel
EnvironmentID string `json:"environmentId" gorm:"column:environment_id;index:idx_image_patches_env_image"`
OriginalImageID string `json:"originalImageId" gorm:"column:original_image_id;index:idx_image_patches_env_image"`
OriginalRef string `json:"originalRef" gorm:"column:original_ref"`
OriginalDigest string `json:"originalDigest,omitempty" gorm:"column:original_digest"`
PatchedRef string `json:"patchedRef" gorm:"column:patched_ref"`
Mode string `json:"mode" gorm:"column:mode"`
Status string `json:"status" gorm:"column:status" sortable:"true"`
PackagesUpdated *int `json:"packagesUpdated,omitempty" gorm:"column:packages_updated"`
Error *string `json:"error,omitempty" gorm:"column:error"`
ActivityID *string `json:"activityId,omitempty" gorm:"column:activity_id"`
DurationMs *int64 `json:"durationMs,omitempty" gorm:"column:duration_ms"`
}
ImagePatchRecord stores one Copacetic image patch run.
func (*ImagePatchRecord) TableName ¶
func (r *ImagePatchRecord) TableName() string
func (*ImagePatchRecord) ToDto ¶
func (r *ImagePatchRecord) ToDto() imagepatch.PatchRecord
type ListImagePatchesInput ¶
type ListImagePatchesInput struct {
EnvironmentID string `path:"id" doc:"Environment ID"`
Search string `query:"search" doc:"Search query"`
Sort string `query:"sort" doc:"Sort field"`
Order string `query:"order" doc:"Sort order"`
Start int `query:"start" doc:"Start offset"`
Limit int `query:"limit" doc:"Limit"`
Status string `query:"status" doc:"Filter by patch status"`
}
type ListPatchTargetsInput ¶
type ListPatchTargetsInput struct {
EnvironmentID string `path:"id" doc:"Environment ID"`
Search string `query:"search" doc:"Search query"`
Sort string `query:"sort" doc:"Column to sort by"`
Order string `query:"order" default:"desc" doc:"Sort direction"`
Start int `query:"start" default:"0" doc:"Start offset"`
Limit int `query:"limit" default:"20" doc:"Limit"`
}
type PatchImageInput ¶
type PatchImageInput struct {
EnvironmentID string `path:"id" doc:"Environment ID"`
ImageID string `path:"imageId" doc:"Image ID to patch"`
Body imagepatch.PatchOptions
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service patches image OS packages in place using the Copacetic library and records each run in the image_patches table.
func NewService ¶
func NewService( db *database.DB, dockerService *docker.DockerClientService, settingsService *settings.SettingsService, activityService *activity.ActivityService, registryService *registry.ContainerRegistryService, vulnerabilityService *vulnerability.VulnerabilityService, ) *Service
func (*Service) AggregatePatchTargets ¶ added in v2.16.1
func (s *Service) AggregatePatchTargets(ctx context.Context, params pagination.QueryParams) (base.Paginated[imagepatch.PatchTarget], error)
func (*Service) ListPatchTargets ¶
func (s *Service) ListPatchTargets(ctx context.Context, envID string, params pagination.QueryParams) ([]imagepatch.PatchTarget, pagination.Response, error)
ListPatchTargets returns scanned images with their fixable-vulnerability counts and latest patch run, for the security page's patching view. Images that are themselves patch outputs are folded into their original's row: they are excluded from the list and surface as that row's LastPatchScan instead.
func (*Service) ListPatches ¶
func (s *Service) ListPatches(ctx context.Context, envID string, params pagination.QueryParams) ([]imagepatch.PatchRecord, pagination.Response, error)
ListPatches returns the paginated patch history for an environment.
func (*Service) PatchImage ¶
func (s *Service) PatchImage(ctx context.Context, envID, imageID string, opts imagepatch.PatchOptions, user usertypes.Actor) (*imagepatch.PatchRecord, error)
PatchImage starts a background patch run for the given image and returns the pending record (carrying the activity ID) immediately.
func (*Service) PatchTarget ¶ added in v2.16.0
func (s *Service) PatchTarget(ctx context.Context, envID string, target Target, recordID string) error
PatchTarget patches one scanned image and waits for the result. recordID keys the patch so a redelivered task resumes its own record instead of patching twice.
func (*Service) PatchedRefs ¶
PatchedRefs returns every name a completed patch output can be scanned under (normalized and familiar), used to keep patch outputs from being patched again.