Help us shape the future of Go! Take the 2026 Go Developer Survey

patch

package
v2.17.2 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: BSD-3-Clause Imports: 55 Imported by: 0

Documentation

Index

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

ListImagePatches returns the paginated patch history for the environment.

func (*ImagePatchHandler) ListPatchTargets

ListPatchTargets returns scanned images with fixable counts and latest patch runs.

func (*ImagePatchHandler) PatchImage

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

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

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

func (s *Service) PatchedRefs(ctx context.Context, envID string) (map[string]struct{}, error)

PatchedRefs returns every name a completed patch output can be scanned under (normalized and familiar), used to keep patch outputs from being patched again.

func (*Service) RecoverInterruptedPatches added in v2.17.0

func (s *Service) RecoverInterruptedPatches(ctx context.Context) error

func (*Service) Targets added in v2.16.0

func (s *Service) Targets(ctx context.Context, envID string) ([]Target, error)

Targets lists images whose latest completed scan found fixable vulnerabilities and kept a report, skipping patch outputs and images patched since that scan.

type Target added in v2.16.0

type Target struct {
	ImageID   string `json:"imageId"`
	ImageName string `json:"imageName"`
}

Target is one image a scheduled patch run covers.

Jump to

Keyboard shortcuts

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