imageupdate

package
v3.0.0-...-a8f5813 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: BSD-3-Clause Imports: 52 Imported by: 0

Documentation

Overview

Package imageupdate owns image update checks, persistence, and HTTP routes.

Index

Constants

View Source
const (
	UpdateTypeDigest    = "digest"
	UpdateTypeTag       = "tag"
	UpdateTypeLocal     = "local"
	UpdateTypeNotPulled = "not_pulled"
)

Variables

This section is empty.

Functions

func RegisterImageUpdates

func RegisterImageUpdates(
	api huma.API,
	imageUpdateSvc *ImageUpdateService,
	getUpdateInfoByImageRefs func(context.Context, []string) (map[string]*types.ImageUpdateInfo, error),
	appCtx handlerutil.ActivityAppContext,
)

RegisterImageUpdates registers image update endpoints.

Types

type CheckImageUpdateByIDInput

type CheckImageUpdateByIDInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	ImageID       string `path:"imageId" doc:"Image ID"`
}

type CheckImageUpdateInput

type CheckImageUpdateInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	ImageRef      string `query:"imageRef" doc:"Image reference"`
}

type CheckImagesActionInput

type CheckImagesActionInput struct {
	Body          *types.BatchImageUpdateRequest `required:"false"`
	EnvironmentID string                         `path:"id" doc:"Environment ID"`
	Action        string                         `query:"action" required:"true" enum:"all,batch" doc:"Check every local image or only the listed image references"`
}

type GetUpdateInfoByRefsInput

type GetUpdateInfoByRefsInput struct {
	EnvironmentID string `path:"id" doc:"Environment ID"`
	ImageRefs     string `query:"imageRefs" doc:"Comma-separated image references"`
}

type ImageParts

type ImageParts struct {
	Registry   string
	Repository string
	Tag        string
}

type ImageUpdate

type ImageUpdate struct {
	UpdateType     string `json:"updateType"`
	CurrentVersion string `json:"currentVersion"`
	LatestVersion  string `json:"latestVersion,omitempty"`
	CheckTime      string `json:"checkTime"`
	HasUpdate      bool   `json:"hasUpdate"`
}

type ImageUpdateHandler

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

func (*ImageUpdateHandler) CheckImageUpdate

func (*ImageUpdateHandler) CheckImageUpdateByID

func (*ImageUpdateHandler) CheckImages

func (*ImageUpdateHandler) GetUpdateInfoByRefs

func (*ImageUpdateHandler) GetUpdateSummary

type ImageUpdateRecord

type ImageUpdateRecord struct {
	database.BaseModel

	ProjectID   string `json:"projectId,omitempty" gorm:"column:project_id;not null;default:'';index"`
	ServiceName string `json:"serviceName,omitempty" gorm:"column:service_name;not null;default:''"`
	PolicyKey   string `json:"-" gorm:"column:policy_key;not null;default:''"`

	ContainerID string `json:"containerId,omitempty" gorm:"column:container_id;not null;default:'';index"`
	ImageID     string `json:"imageId,omitempty" gorm:"column:image_id;not null;default:'';index"`

	CheckTime        time.Time  `json:"checkTime" gorm:"column:check_time"`
	LatestSeenAt     *time.Time `json:"latestSeenAt,omitempty" gorm:"column:latest_seen_at"`
	LatestVersion    *string    `json:"latestVersion,omitempty" gorm:"column:latest_version"`
	CurrentDigest    *string    `json:"currentDigest,omitempty" gorm:"column:current_digest"`
	LatestDigest     *string    `json:"latestDigest,omitempty" gorm:"column:latest_digest"`
	LastError        *string    `json:"lastError,omitempty" gorm:"column:last_error"`
	AuthMethod       *string    `json:"authMethod,omitempty" gorm:"column:auth_method"`
	AuthUsername     *string    `json:"authUsername,omitempty" gorm:"column:auth_username"`
	AuthRegistry     *string    `json:"authRegistry,omitempty" gorm:"column:auth_registry"`
	ID               string     `json:"id" gorm:"primaryKey;type:text"`
	Repository       string     `json:"repository"`
	Tag              string     `json:"tag"`
	UpdateType       string     `json:"updateType" gorm:"column:update_type"`
	CurrentVersion   string     `json:"currentVersion" gorm:"column:current_version"`
	ResponseTimeMs   int        `json:"responseTimeMs" gorm:"column:response_time_ms"`
	HasUpdate        bool       `json:"hasUpdate" gorm:"column:has_update"`
	UsedCredential   bool       `json:"usedCredential,omitempty" gorm:"column:used_credential"`
	NotificationSent bool       `json:"notificationSent" gorm:"column:notification_sent;default:false"`
}

func (*ImageUpdateRecord) IsDigestUpdate

func (i *ImageUpdateRecord) IsDigestUpdate() bool

func (*ImageUpdateRecord) IsTagUpdate

func (i *ImageUpdateRecord) IsTagUpdate() bool

func (*ImageUpdateRecord) NeedsUpdate

func (i *ImageUpdateRecord) NeedsUpdate() bool

func (*ImageUpdateRecord) TableName

func (i *ImageUpdateRecord) TableName() string

func (*ImageUpdateRecord) UpdateInfo

func (i *ImageUpdateRecord) UpdateInfo() *types.ImageUpdateInfo

UpdateInfo returns the public status of this check.

type ImageUpdateService

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

func (*ImageUpdateService) CheckImageUpdate

func (s *ImageUpdateService) CheckImageUpdate(ctx context.Context, imageRef string) (*types.ImageUpdateResponse, error)

func (*ImageUpdateService) CheckImageUpdateByID

func (s *ImageUpdateService) CheckImageUpdateByID(ctx context.Context, imageID string) (*types.ImageUpdateResponse, error)

func (*ImageUpdateService) CheckImages

CheckImages returns each ref's result; usable credentials replace the stored registries for this check.

func (*ImageUpdateService) CheckWorkflow

func (s *ImageUpdateService) CheckWorkflow() *flow.Workflow

func (*ImageUpdateService) CleanupOrphanedRecords

func (s *ImageUpdateService) CleanupOrphanedRecords(ctx context.Context) error

func (*ImageUpdateService) DeleteRecordsForImages

func (s *ImageUpdateService) DeleteRecordsForImages(ctx context.Context, imageIDs []string) error

DeleteRecordsForImages removes rows keyed by id or image_id for the given images.

func (*ImageUpdateService) GetUnnotifiedUpdates

func (s *ImageUpdateService) GetUnnotifiedUpdates(ctx context.Context) (map[string]*ImageUpdateRecord, error)

func (*ImageUpdateService) GetUpdateSummary

func (s *ImageUpdateService) GetUpdateSummary(ctx context.Context) (*types.ImageUpdateSummary, error)

func (*ImageUpdateService) MarkImageRefUpToDateAfterPull

func (s *ImageUpdateService) MarkImageRefUpToDateAfterPull(ctx context.Context, imageRef string) error

func (*ImageUpdateService) MarkUpdatesAsNotified

func (s *ImageUpdateService) MarkUpdatesAsNotified(ctx context.Context, records []*ImageUpdateRecord) error

func (*ImageUpdateService) MonitoredImageRefs

func (s *ImageUpdateService) MonitoredImageRefs(ctx context.Context, imageRefs []string) ([]string, error)

MonitoredImageRefs keeps the refs whose containers still permit update checks.

func (*ImageUpdateService) RegisterWorkflows

func (s *ImageUpdateService) RegisterWorkflows(engine *flow.Engine) error

RegisterWorkflows defines the image-check workflow; call it before the host starts.

func (*ImageUpdateService) RunImageCheck

func (*ImageUpdateService) SendBatchUpdateNotifications

func (s *ImageUpdateService) SendBatchUpdateNotifications(ctx context.Context) error

SendBatchUpdateNotifications errors only when the pending set is unknown; failed deliveries retry on the next flush.

func (*ImageUpdateService) StoredUpdateByImageID

func (s *ImageUpdateService) StoredUpdateByImageID(ctx context.Context, imageID string) (*ImageUpdateRecord, bool, error)

type ImageUpdateServiceParams

type ImageUpdateServiceParams struct {
	fx.In

	DB                  *database.DB
	SettingsService     *settings.SettingsService
	RegistryService     *registry.ContainerRegistryService
	DockerService       *docker.DockerClientService
	EventService        *event.EventService
	NotificationService *notification.NotificationService
	ActivityService     *activity.ActivityService
}

type Module

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

func New

func New(service *ImageUpdateService, getUpdateInfo func(context.Context, []string) (map[string]*types.ImageUpdateInfo, error)) *Module

New wires image update routes and registers the arcane.image.updates gauges once.

func (*Module) RegisterRoutes

func (m *Module) RegisterRoutes(api huma.API, appCtx handlerutil.ActivityAppContext)

func (*Module) Service

func (m *Module) Service() *ImageUpdateService

Directories

Path Synopsis
children

Jump to

Keyboard shortcuts

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