services

package
v0.0.0-...-22c2ce1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 44 Imported by: 0

Documentation

Overview

FIXME: golangci-lint nolint:revive

FIXME: golangci-lint nolint:gocritic,govet,ineffassign,revive,typecheck

FIXME: golangci-lint nolint:gocritic,govet,revive

FIXME: golangci-lint nolint:errcheck,gocritic,gosec,govet,revive

FIXME: golangci-lint nolint:revive

FIXME: golangci-lint nolint:govet,revive

FIXME: golangci-lint Package services handles all service-related features nolint:errcheck,gocritic,govet,revive

nolint:gocritic,govet,revive

FIXME: golangci-lint nolint:govet,revive

FIXME: golangci-lint nolint:revive

FIXME: golangci-lint nolint:revive

FIXME: golangci-lint nolint:revive

FIXME: golangci-lint nolint:gocritic,govet,revive

Package services handles all service-related features

Index

Constants

View Source
const (
	// InventoryEventTypeCreated represent the Created inventory event type
	InventoryEventTypeCreated = "created"
	// InventoryEventTypeUpdated represent the Updated inventory event type
	InventoryEventTypeUpdated = "updated"
	// InventoryEventTypeDelete represent the "delete" inventory event type
	InventoryEventTypeDelete = "delete"
	// InventoryHostTypeEdge represent the inventory host_ype = "edge"
	InventoryHostTypeEdge = "edge"
)
View Source
const (
	// NotificationTopic to be used
	NotificationTopic = "platform.notifications.ingress"
	// NotificationConfigVersion to be used
	NotificationConfigVersion = "v1.1.0"
	// NotificationConfigBundle to be used
	NotificationConfigBundle = "rhel"
	// NotificationConfigApplication to be used
	NotificationConfigApplication = "edge-management"
	// NotificationConfigEventTypeImage to be used
	NotificationConfigEventTypeImage = "image-creation"
	// NotificationConfigEventTypeDevice to be used
	NotificationConfigEventTypeDevice = "update-devices"
	// NotificationConfigUser to be used
	NotificationConfigUser = "fleet-management"
)
View Source
const (
	// PlaybookStatusRunning is the status when a playbook is still running
	PlaybookStatusRunning = "running"
	// PlaybookStatusSuccess is the status when a playbook has run successfully
	PlaybookStatusSuccess = "success"
	// PlaybookStatusFailure is the status when a playbook execution fails
	PlaybookStatusFailure = "failure"
	// PlaybookStatusTimeout is the status when a playbook execution times out
	PlaybookStatusTimeout = "timeout"
)

Status defined by https://github.com/RedHatInsights/playbook-dispatcher/blob/master/schema/run.event.yaml

View Source
const AccountNotSetMsg = "Account is not set"
View Source
const AccountOrOrgIDNotSetMsg = "Account or orgID is not set"
View Source
const CommitImageNotFoundMsg = "Commit image was not found"
View Source
const CommitNotFoundMsg = "Commit was not found"
View Source
const CommitNotValidMsg = "is not valid for update"
View Source
const DBCommitErrorMsg = "Error searching for ImageSet of Device Images"
View Source
const DeviceGroupAccountOrIDUndefinedMsg = "account or deviceGroupID undefined"
View Source
const DeviceGroupAccountOrNameUndefinedMsg = "device group account or name are undefined"
View Source
const DeviceGroupAlreadyExistsMsg = "device group already exists"
View Source
const DeviceGroupDeviceNotSuppliedMsg = "device-group device must be supplied"
View Source
const DeviceGroupDevicesNotFoundMsg = "devices not found in device group"
View Source
const DeviceGroupDevicesNotSuppliedMsg = "devices must be supplied to be added to or removed from device group"
View Source
const DeviceGroupMandatoryFieldsUndefinedMsg = "device group mandatory field are undefined"
View Source
const DeviceGroupNotFoundMsg = "device group was not found"
View Source
const DeviceGroupOrgIDDevicesNotFoundMsg = "devices not found among the device group orgID"
View Source
const DeviceHasImageUndefinedMsg = "device has image undefined"
View Source
const DeviceHasNoImageUpdateMsg = "device has no image update"
View Source
const DeviceNotFoundErrorMsg = "Device was not found"
View Source
const DevicesHasMoreThanOneImageSetMsg = "device has more than one image-set"
View Source
const EntitiesImageSetsMismatchMsg = "does not belong to the same image-set as devices images"
View Source
const IDMustBeIntegerMsg = "ID needs to be an integer"
View Source
const ImageCommitNotFoundMsg = "Image commit not found"
View Source
const ImageHasNoImageSetMsg = "Image has no image-set"
View Source
const ImageNameAlreadyExistsMsg = "image with supplied name already exists"
View Source
const ImageNameChangeIsProhibitedMsg = "image name change is prohibited in the current context"
View Source
const ImageNameUndefinedMsg = "image name is not defined"
View Source
const ImageNotFoundErrorMsg = "image was not found"
View Source
const ImageNotInErrorStateMsg = "image is not in error state"
View Source
const ImageOnlyLatestCanModifyMsg = "only the latest updated image can be modified"
View Source
const ImageSetAlreadyExistsMsg = "image set already exists"
View Source
const ImageSetNotFoundErrorMsg = "image-set was not found"
View Source
const ImageSetUnDefinedMsg = "image-set is undefined"
View Source
const ImageUnDefinedMsg = "image-set is undefined"
View Source
const ImageVersionAlreadyExistsMsg = "updated image version already exists"
View Source
const InvalidURLForCustomRepoMsg = "invalid URL"
View Source
const KafkaAllBrokersDownMsg = "Cannot connect to any Kafka brokers"
View Source
const KafkaProducerInstanceUndefinedMsg = "kafka producer instance is undefined"
View Source
const OrgIDNotSetMsg = "Org ID is not set"
View Source
const OstreeNotFoundMsg = "Ostree not found"
View Source
const PackageNameDoesNotExistMsg = "package name doesn't exist"
View Source
const ParsingISODateErrorMsg = "error occurred while parsing string for ISO date"
View Source
const SomeDevicesDoesNotExistsMsg = "image-set not found for all devices"
View Source
const ThirdPartyRepositoryAlreadyExistsMsg = "custom repository already exists"
View Source
const ThirdPartyRepositoryImagesExistsMsg = "custom repository is used by some images"
View Source
const ThirdPartyRepositoryInfoIsInvalidMsg = "custom repository info is invalid"
View Source
const ThirdPartyRepositoryNameIsEmptyMsg = "custom repository name cannot be empty"
View Source
const ThirdPartyRepositoryNotFoundMsg = "third party repository was not found"
View Source
const ThirdPartyRepositoryURLIsEmptyMsg = "custom repository URL cannot be empty"
View Source
const ThirdPartyRepositoryWithURLAlreadyExistsMsg = "custom repository with url already exists"
View Source
const UpdateNotFoundErrorMsg = "Update was not found"

Variables

View Source
var BuildCommand = exec.Command

BuildCommand references the exec.Command for calls to the system

View Source
var DefaultLoopDelay = 1 * time.Minute
View Source
var ErrOrgIDMismatch = errors.New("context org_id and entity org_id mismatch")

ErrOrgIDMismatch returned when the context orgID is different from an entity OrgID

View Source
var ErrUndefinedCommit = errors.New("entity has defined commit")

ErrUndefinedCommit indicate that the update transaction/image or some entity has no commit defined.

Functions

func GetDiffOnUpdate

func GetDiffOnUpdate(oldImg models.Image, newImg models.Image) models.PackageDiff

GetDiffOnUpdate returns the diff between two images. TODO: Move out to a different package, as this is devices related, either to image service or image models.

func GetImageReposFromDB

func GetImageReposFromDB(orgID string, repos []models.ThirdPartyRepo) (*[]models.ThirdPartyRepo, error)

GetImageReposFromDB return ThirdParty repo of image by OrgID

func GetStorageInstallerIsoURL

func GetStorageInstallerIsoURL(installerID uint) string

GetStorageInstallerIsoURL return the installer application storage url

func RepoRevParse

func RepoRevParse(path string, ref string) (string, error)

RepoRevParse Handle the RevParse separate since we need the stdout parsed

func RetryCreateImageFailHandler

func RetryCreateImageFailHandler(ctx context.Context, job *jobs.Job)

func RetryCreateImageJobHandler

func RetryCreateImageJobHandler(ctx context.Context, job *jobs.Job)

func ReturnDevicesView

func ReturnDevicesView(storedDevices []models.Device, orgID string) ([]models.DeviceView, error)

ReturnDevicesView returns the devices association and status properly

Types

type AccountNotSet

type AccountNotSet struct{}

AccountNotSet indicates the account was nil

func (*AccountNotSet) Error

func (e *AccountNotSet) Error() string

type AccountOrOrgIDNotSet

type AccountOrOrgIDNotSet struct{}

AccountOrOrgIDNotSet indicates the account or orgID was nil

func (*AccountOrOrgIDNotSet) Error

func (e *AccountOrOrgIDNotSet) Error() string

type BasicFileService

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

BasicFileService is the base file service struct It serves as a base for other file services implementations

func (*BasicFileService) GetDownloader

func (s *BasicFileService) GetDownloader() files.Downloader

GetDownloader returns a new downloads for files

func (*BasicFileService) GetExtractor

func (s *BasicFileService) GetExtractor() files.Extractor

GetExtractor returns a new extractor for files

func (*BasicFileService) GetUploader

func (s *BasicFileService) GetUploader() files.Uploader

GetUploader returns a new uploader for files

type CommitImageNotFound

type CommitImageNotFound struct{}

CommitImageNotFound indicates the Commit Image is not found

func (*CommitImageNotFound) Error

func (e *CommitImageNotFound) Error() string

type CommitNotFound

type CommitNotFound struct{}

CommitNotFound indicates commit matching the given id was not found

func (*CommitNotFound) Error

func (e *CommitNotFound) Error() string

type CommitNotValid

type CommitNotValid struct{}

CommitNotValid indicates commit matching the given id was not found

func (*CommitNotValid) Error

func (e *CommitNotValid) Error() string

type CommitService

type CommitService struct {
	Service
}

CommitService is the main implementation of a CommitServiceInterface

func (*CommitService) GetCommitByID

func (s *CommitService) GetCommitByID(commitID uint, orgID string) (*models.Commit, error)

GetCommitByID receives CommitID uint and get a *models.Commit back

func (*CommitService) GetCommitByOSTreeCommit

func (s *CommitService) GetCommitByOSTreeCommit(ost string) (*models.Commit, error)

GetCommitByOSTreeCommit receives an OSTreeCommit string and get a *models.Commit back

func (*CommitService) ValidateDevicesImageSetWithCommit

func (s *CommitService) ValidateDevicesImageSetWithCommit(devicesUUID []string, commitID uint) error

ValidateDevicesImageSetWithCommit validates if user provided commitID belong to same ImageSet as of Device Image

type CommitServiceInterface

type CommitServiceInterface interface {
	GetCommitByID(commitID uint, orgID string) (*models.Commit, error)
	GetCommitByOSTreeCommit(ost string) (*models.Commit, error)
	ValidateDevicesImageSetWithCommit(deviceUUID []string, commitID uint) error
}

CommitServiceInterface defines the interface to handle the business logic of RHEL for Edge Commits

func NewCommitService

func NewCommitService(ctx context.Context, log log.FieldLogger) CommitServiceInterface

NewCommitService gives a instance of the main implementation of CommitServiceInterface

type ConsumerService

type ConsumerService interface {
	Start()
	Close()
}

ConsumerService is the interface that takes care of our consumer implementation

func NewKafkaConsumerService

func NewKafkaConsumerService(config *clowder.KafkaConfig, topic string) ConsumerService

NewKafkaConsumerService gives a instance of the Kafka implementation of ConsumerService

type DBCommitError

type DBCommitError struct{}

DBCommitError indicates a dbError during search

func (*DBCommitError) Error

func (e *DBCommitError) Error() string

type DeviceGroupAccountOrIDUndefined

type DeviceGroupAccountOrIDUndefined struct{}

DeviceGroupAccountOrIDUndefined indicates that device group account or ID was not supplied

func (*DeviceGroupAccountOrIDUndefined) Error

type DeviceGroupAccountOrNameUndefined

type DeviceGroupAccountOrNameUndefined struct{}

DeviceGroupAccountOrNameUndefined indicates that device group account or name are undefined

func (*DeviceGroupAccountOrNameUndefined) Error

type DeviceGroupAlreadyExists

type DeviceGroupAlreadyExists struct{}

DeviceGroupAlreadyExists indicates that device group already exists

func (*DeviceGroupAlreadyExists) Error

func (e *DeviceGroupAlreadyExists) Error() string

type DeviceGroupDeviceNotSupplied

type DeviceGroupDeviceNotSupplied struct{}

DeviceGroupDeviceNotSupplied indicates that device group device was not supplied

func (*DeviceGroupDeviceNotSupplied) Error

type DeviceGroupDevicesNotFound

type DeviceGroupDevicesNotFound struct{}

DeviceGroupDevicesNotFound indicates that devices not found in the device group collection

func (*DeviceGroupDevicesNotFound) Error

type DeviceGroupDevicesNotSupplied

type DeviceGroupDevicesNotSupplied struct{}

DeviceGroupDevicesNotSupplied indicates that device group devices was not supplied

func (*DeviceGroupDevicesNotSupplied) Error

type DeviceGroupMandatoryFieldsUndefined

type DeviceGroupMandatoryFieldsUndefined struct{}

DeviceGroupMandatoryFieldsUndefined indicates that device group mandatory field are undefined

func (*DeviceGroupMandatoryFieldsUndefined) Error

type DeviceGroupNotFound

type DeviceGroupNotFound struct{}

DeviceGroupNotFound indicates the Third Party Repository was not found

func (*DeviceGroupNotFound) Error

func (e *DeviceGroupNotFound) Error() string

type DeviceGroupOrgIDDevicesNotFound

type DeviceGroupOrgIDDevicesNotFound struct{}

DeviceGroupOrgIDDevicesNotFound indicates that devices not found among the device group OrgID

func (*DeviceGroupOrgIDDevicesNotFound) Error

type DeviceGroupsService

type DeviceGroupsService struct {
	Service
	DeviceService DeviceServiceInterface
	UpdateService UpdateServiceInterface
}

DeviceGroupsService is the main implementation of a DeviceGroupsServiceInterface

func (*DeviceGroupsService) AddDeviceGroupDevices

func (s *DeviceGroupsService) AddDeviceGroupDevices(orgID string, deviceGroupID uint, devices []models.Device) (*[]models.Device, error)

AddDeviceGroupDevices add devices to device group

func (*DeviceGroupsService) CreateDeviceGroup

func (s *DeviceGroupsService) CreateDeviceGroup(deviceGroup *models.DeviceGroup) (*models.DeviceGroup, error)

CreateDeviceGroup create a device group for an ID

func (*DeviceGroupsService) DeleteDeviceGroupByID

func (s *DeviceGroupsService) DeleteDeviceGroupByID(ID string) error

DeleteDeviceGroupByID deletes the device group by ID from the database

func (*DeviceGroupsService) DeleteDeviceGroupDevices

func (s *DeviceGroupsService) DeleteDeviceGroupDevices(orgID string, deviceGroupID uint, devices []models.Device) (*[]models.Device, error)

DeleteDeviceGroupDevices delete devices from device-group

func (*DeviceGroupsService) DeviceGroupNameExists

func (s *DeviceGroupsService) DeviceGroupNameExists(orgID string, name string) (bool, error)

DeviceGroupNameExists check if a device group exists by (orgID) and name

func (*DeviceGroupsService) GetDeviceGroupByID

func (s *DeviceGroupsService) GetDeviceGroupByID(ID string) (*models.DeviceGroup, error)

GetDeviceGroupByID gets the device group by ID from the database

func (*DeviceGroupsService) GetDeviceGroupDetailsByID

func (s *DeviceGroupsService) GetDeviceGroupDetailsByID(ID string) (*models.DeviceGroupDetails, error)

GetDeviceGroupDetailsByID gets the device group details by ID from the database

func (*DeviceGroupsService) GetDeviceGroupDeviceByID

func (s *DeviceGroupsService) GetDeviceGroupDeviceByID(orgID string, deviceGroupID uint, deviceID uint) (*models.Device, error)

GetDeviceGroupDeviceByID return the device of a device group by its ID

func (*DeviceGroupsService) GetDeviceGroups

func (s *DeviceGroupsService) GetDeviceGroups(orgID string, limit int, offset int, tx *gorm.DB) (*[]models.DeviceGroupListDetail, error)

GetDeviceGroups get the device groups objects from the database

func (*DeviceGroupsService) GetDeviceGroupsCount

func (s *DeviceGroupsService) GetDeviceGroupsCount(orgID string, tx *gorm.DB) (int64, error)

GetDeviceGroupsCount get the device groups by orgID records count from the database

func (*DeviceGroupsService) GetDeviceImageInfo

func (s *DeviceGroupsService) GetDeviceImageInfo(images map[int]models.DeviceImageInfo, orgID string) error

GetDeviceImageInfo returns the image related to the groups

func (*DeviceGroupsService) UpdateDeviceGroup

func (s *DeviceGroupsService) UpdateDeviceGroup(deviceGroup *models.DeviceGroup, orgID string, ID string) error

UpdateDeviceGroup update an existent group

type DeviceGroupsServiceInterface

type DeviceGroupsServiceInterface interface {
	CreateDeviceGroup(deviceGroup *models.DeviceGroup) (*models.DeviceGroup, error)
	GetDeviceGroups(orgID string, limit int, offset int, tx *gorm.DB) (*[]models.DeviceGroupListDetail, error)
	GetDeviceGroupsCount(orgID string, tx *gorm.DB) (int64, error)
	GetDeviceGroupByID(ID string) (*models.DeviceGroup, error)
	GetDeviceGroupDetailsByID(ID string) (*models.DeviceGroupDetails, error)
	DeleteDeviceGroupByID(ID string) error
	UpdateDeviceGroup(deviceGroup *models.DeviceGroup, orgID string, ID string) error
	GetDeviceGroupDeviceByID(orgID string, deviceGroupID uint, deviceID uint) (*models.Device, error)
	AddDeviceGroupDevices(orgID string, deviceGroupID uint, devices []models.Device) (*[]models.Device, error)
	DeleteDeviceGroupDevices(orgID string, deviceGroupID uint, devices []models.Device) (*[]models.Device, error)
	GetDeviceImageInfo(setOfImages map[int]models.DeviceImageInfo, orgID string) error
	DeviceGroupNameExists(orgID string, name string) (bool, error)
}

DeviceGroupsServiceInterface defines the interface that helps handle the business logic of creating and getting device groups

func NewDeviceGroupsService

func NewDeviceGroupsService(ctx context.Context, log log.FieldLogger) DeviceGroupsServiceInterface

NewDeviceGroupsService return an instance of the main implementation of a DeviceGroupsServiceInterface

type DeviceHasImageUndefined

type DeviceHasImageUndefined struct{}

DeviceHasImageUndefined indicates that device record has image not defined

func (*DeviceHasImageUndefined) Error

func (e *DeviceHasImageUndefined) Error() string

type DeviceHasNoImageUpdate

type DeviceHasNoImageUpdate struct{}

DeviceHasNoImageUpdate indicates that device record no image

func (*DeviceHasNoImageUpdate) Error

func (e *DeviceHasNoImageUpdate) Error() string

type DeviceNotFoundError

type DeviceNotFoundError struct{}

DeviceNotFoundError indicates the device was not found

func (*DeviceNotFoundError) Error

func (e *DeviceNotFoundError) Error() string

type DeviceService

type DeviceService struct {
	Service
	UpdateService UpdateServiceInterface
	ImageService  ImageServiceInterface
	Inventory     inventory.ClientInterface
}

DeviceService is the main implementation of a DeviceServiceInterface

func (*DeviceService) CanUpdate

func (s *DeviceService) CanUpdate(currentDistribution string, updDistribution string) bool

func (*DeviceService) GetDeviceByID

func (s *DeviceService) GetDeviceByID(deviceID uint) (*models.Device, error)

GetDeviceByID receives DeviceID uint and get a *models.Device back

func (*DeviceService) GetDeviceByUUID

func (s *DeviceService) GetDeviceByUUID(deviceUUID string) (*models.Device, error)

GetDeviceByUUID receives UUID string and get a *models.Device back

func (*DeviceService) GetDeviceDetails

func (s *DeviceService) GetDeviceDetails(device inventory.Device, deviceUpdateImagesFilters models.DeviceUpdateImagesFilters) (*models.DeviceDetails, error)

GetDeviceDetails provides details for a given Device by going to inventory API and trying to also merge with the information on our database

func (*DeviceService) GetDeviceDetailsByUUID

func (s *DeviceService) GetDeviceDetailsByUUID(deviceUUID string, deviceUpdateImagesFilters models.DeviceUpdateImagesFilters) (*models.DeviceDetails, error)

GetDeviceDetailsByUUID provides details for a given Device UUID by going to inventory API and trying to also merge with the information on our database

func (*DeviceService) GetDeviceImageInfo

func (s *DeviceService) GetDeviceImageInfo(device inventory.Device, deviceUpdateImagesFilters models.DeviceUpdateImagesFilters) (*models.ImageInfo, error)

GetDeviceImageInfo returns the information of a the running image for a device

func (*DeviceService) GetDeviceImageInfoByUUID

func (s *DeviceService) GetDeviceImageInfoByUUID(deviceUUID string, deviceUpdateImagesFilters models.DeviceUpdateImagesFilters) (*models.ImageInfo, error)

GetDeviceImageInfoByUUID returns the information of a running image for a device given its UUID

func (*DeviceService) GetDeviceLastBootedDeployment

func (s *DeviceService) GetDeviceLastBootedDeployment(device inventory.Device) *inventory.OSTree

GetDeviceLastBootedDeployment returns the last booted deployment for a device

func (*DeviceService) GetDeviceLastDeployment

func (s *DeviceService) GetDeviceLastDeployment(device inventory.Device) *inventory.OSTree

GetDeviceLastDeployment returns the last deployment for a device

func (*DeviceService) GetDevices

func (s *DeviceService) GetDevices(params *inventory.Params) (*models.DeviceDetailsList, error)

GetDevices returns a list of EdgeDevices, which is a mix of device information from EdgeAPI and InventoryAPI

func (*DeviceService) GetDevicesCount

func (s *DeviceService) GetDevicesCount(tx *gorm.DB) (int64, error)

GetDevicesCount get the device groups Org records count from the database

func (*DeviceService) GetDevicesCountByImage

func (s *DeviceService) GetDevicesCountByImage(imageId uint) (int64, error)

GetDevicesCountByImage returns a list of devices running a image in a org.

func (*DeviceService) GetDevicesView

func (s *DeviceService) GetDevicesView(limit int, offset int, tx *gorm.DB) (*models.DeviceViewList, error)

GetDevicesView returns a list of EdgeDevices for a given org.

func (*DeviceService) GetLatestCommitFromDevices

func (s *DeviceService) GetLatestCommitFromDevices(orgID string, devicesUUID []string) (uint, error)

GetLatestCommitFromDevices fetches the commitID from the latest Device Image

func (*DeviceService) GetUpdateAvailableForDevice

func (s *DeviceService) GetUpdateAvailableForDevice(device inventory.Device, latest bool, deviceUpdateImagesFilters models.DeviceUpdateImagesFilters) ([]models.ImageUpdateAvailable, int64, error)

GetUpdateAvailableForDevice returns if it exists an update for the current image at the device.

func (*DeviceService) GetUpdateAvailableForDeviceByUUID

func (s *DeviceService) GetUpdateAvailableForDeviceByUUID(deviceUUID string, latest bool, deviceUpdateImagesFilters models.DeviceUpdateImagesFilters) ([]models.ImageUpdateAvailable, int64, error)

GetUpdateAvailableForDeviceByUUID returns if it exists an update for the current image at the device given its UUID.

func (*DeviceService) ProcessPlatformInventoryCreateEvent

func (s *DeviceService) ProcessPlatformInventoryCreateEvent(message []byte) error

ProcessPlatformInventoryCreateEvent is a method to processes messages from platform.inventory.events kafka topic and save them as devices in the DB

func (*DeviceService) ProcessPlatformInventoryDeleteEvent

func (s *DeviceService) ProcessPlatformInventoryDeleteEvent(message []byte) error

ProcessPlatformInventoryDeleteEvent processes messages from platform.inventory.events kafka topic with event_type="delete"

func (*DeviceService) ProcessPlatformInventoryUpdatedEvent

func (s *DeviceService) ProcessPlatformInventoryUpdatedEvent(message []byte) error

ProcessPlatformInventoryUpdatedEvent processes messages from platform.inventory.events kafka topic with event_type="updated"

func (*DeviceService) SetDeviceUpdateAvailability

func (s *DeviceService) SetDeviceUpdateAvailability(orgID string, deviceID uint) error

SetDeviceUpdateAvailability set whether there is a device Updates available ot not.

func (*DeviceService) SyncDevicesWithInventory

func (s *DeviceService) SyncDevicesWithInventory(orgID string)

func (*DeviceService) SyncInventoryWithDevices

func (s *DeviceService) SyncInventoryWithDevices(orgID string)

type DeviceServiceInterface

type DeviceServiceInterface interface {
	GetDevices(params *inventory.Params) (*models.DeviceDetailsList, error)
	GetDeviceByID(deviceID uint) (*models.Device, error)
	GetDevicesView(limit int, offset int, tx *gorm.DB) (*models.DeviceViewList, error)
	GetDevicesCount(tx *gorm.DB) (int64, error)
	GetDeviceByUUID(deviceUUID string) (*models.Device, error)
	// Device by UUID methods
	GetDeviceDetailsByUUID(deviceUUID string, deviceUpdateImagesFilters models.DeviceUpdateImagesFilters) (*models.DeviceDetails, error)
	GetUpdateAvailableForDeviceByUUID(deviceUUID string, latest bool, deviceUpdateImagesFilters models.DeviceUpdateImagesFilters) ([]models.ImageUpdateAvailable, int64, error)
	GetDeviceImageInfoByUUID(deviceUUID string, deviceUpdateImagesFilters models.DeviceUpdateImagesFilters) (*models.ImageInfo, error)
	GetLatestCommitFromDevices(orgID string, devicesUUID []string) (uint, error)
	// Device Object Methods
	GetDeviceDetails(device inventory.Device, deviceUpdateImagesFilters models.DeviceUpdateImagesFilters) (*models.DeviceDetails, error)
	GetUpdateAvailableForDevice(device inventory.Device, latest bool, deviceUpdateImagesFilters models.DeviceUpdateImagesFilters) ([]models.ImageUpdateAvailable, int64, error)
	GetDeviceImageInfo(device inventory.Device, deviceUpdateImagesFilters models.DeviceUpdateImagesFilters) (*models.ImageInfo, error)
	GetDeviceLastDeployment(device inventory.Device) *inventory.OSTree
	GetDeviceLastBootedDeployment(device inventory.Device) *inventory.OSTree
	ProcessPlatformInventoryCreateEvent(message []byte) error
	ProcessPlatformInventoryUpdatedEvent(message []byte) error
	ProcessPlatformInventoryDeleteEvent(message []byte) error
	SyncDevicesWithInventory(orgID string)
	SyncInventoryWithDevices(orgID string)
}

DeviceServiceInterface defines the interface to handle the business logic of RHEL for Edge Devices

func NewDeviceService

func NewDeviceService(ctx context.Context, log log.FieldLogger) DeviceServiceInterface

NewDeviceService gives a instance of the main implementation of DeviceServiceInterface

type DevicesHasMoreThanOneImageSet

type DevicesHasMoreThanOneImageSet struct{}

DevicesHasMoreThanOneImageSet indicates that device record no image

func (*DevicesHasMoreThanOneImageSet) Error

type EntitiesImageSetsMismatch

type EntitiesImageSetsMismatch struct{}

EntitiesImageSetsMismatch indicates the CommitID does not belong to the same ImageSet as of Device's Image

func (*EntitiesImageSetsMismatch) Error

func (e *EntitiesImageSetsMismatch) Error() string

type EventNotification

type EventNotification struct {
	Metadata map[string]string `json:"metadata"`
	Payload  string            `json:"payload"`
}

EventNotification is used to track events to notification

type FilesService

type FilesService interface {
	GetFile(path string) (io.ReadCloser, error)
	GetSignedURL(path string) (string, error)
	GetExtractor() files.Extractor
	GetUploader() files.Uploader
	GetDownloader() files.Downloader
}

FilesService is the interface for Files-related service information

func NewFilesService

func NewFilesService(log log.FieldLogger) FilesService

NewFilesService creates a new service to handle files

func NewS3FilesServices

func NewS3FilesServices(client files.S3ClientInterface, basicFileService BasicFileService) FilesService

NewS3FilesServices return a new FilesService with s3 client

type HeaderPlayBookDispatcher

type HeaderPlayBookDispatcher struct {
	Service string `json:"service"`
}

HeaderPlayBookDispatcher is the header for Playbook Dispatcher events

type IDMustBeInteger

type IDMustBeInteger struct{}

IDMustBeInteger indicates the ID is required to be an integer value

func (*IDMustBeInteger) Error

func (e *IDMustBeInteger) Error() string

type ImageCommitNotFound

type ImageCommitNotFound struct{}

ImageCommitNotFound occurs when the image commit cannot be found

func (*ImageCommitNotFound) Error

func (e *ImageCommitNotFound) Error() string

type ImageDetail

type ImageDetail struct {
	Image              *models.Image `json:"image"`
	AdditionalPackages int           `json:"additional_packages"`
	Packages           int           `json:"packages"`
	UpdateAdded        int           `json:"update_added"`
	UpdateRemoved      int           `json:"update_removed"`
	UpdateUpdated      int           `json:"update_updated"`
}

ImageDetail return the structure to inform package info to images nolint: unused // golangci-lint does not parse well this block, it says Image not used, but it's used

type ImageHasNoImageSet

type ImageHasNoImageSet struct{}

ImageHasNoImageSet indicates that device record no image

func (*ImageHasNoImageSet) Error

func (e *ImageHasNoImageSet) Error() string

type ImageNameAlreadyExists

type ImageNameAlreadyExists struct{}

ImageNameAlreadyExists indicates the image with supplied name already exists

func (*ImageNameAlreadyExists) Error

func (e *ImageNameAlreadyExists) Error() string

type ImageNameChangeIsProhibited

type ImageNameChangeIsProhibited struct{}

ImageNameChangeIsProhibited indicates that the image name was about to change, but this is not allowed mainly this happens when updating an image

func (*ImageNameChangeIsProhibited) Error

type ImageNameUndefined

type ImageNameUndefined struct{}

ImageNameUndefined indicates the image name is not defined

func (*ImageNameUndefined) Error

func (e *ImageNameUndefined) Error() string

type ImageNotFoundError

type ImageNotFoundError struct{}

ImageNotFoundError indicates the image was not found

func (*ImageNotFoundError) Error

func (e *ImageNotFoundError) Error() string

type ImageNotInErrorState

type ImageNotInErrorState struct{}

ImageNotInErrorState indicates unable to delete an image

func (*ImageNotInErrorState) Error

func (e *ImageNotInErrorState) Error() string

type ImageNotification

type ImageNotification struct {
	Version     string                  `json:"version"`
	Bundle      string                  `json:"bundle"`
	Application string                  `json:"application"`
	EventType   string                  `json:"event_type"`
	Timestamp   string                  `json:"timestamp"`
	Account     string                  `json:"account_id"`
	OrgID       string                  `json:"org_id"`
	Context     string                  `json:"context"`
	Events      []EventNotification     `json:"events"`
	Recipients  []RecipientNotification `json:"recipients"`
}

ImageNotification is the implementation of expected boddy notification

type ImageOnlyLatestCanModify

type ImageOnlyLatestCanModify struct{}

ImageOnlyLatestCanModify indicates only the latest image can be modified

func (*ImageOnlyLatestCanModify) Error

func (e *ImageOnlyLatestCanModify) Error() string

type ImageService

type ImageService struct {
	Service

	ImageBuilder    imagebuilder.ClientInterface
	RepoBuilder     RepoBuilderInterface
	RepoService     RepoServiceInterface
	ProducerService kafkacommon.ProducerServiceInterface
	TopicService    kafkacommon.TopicServiceInterface
	FilesService    FilesService
	Repositories    repositories.ClientInterface
}

ImageService is the main implementation of a ImageServiceInterface

func (*ImageService) AddPackageInfo

func (s *ImageService) AddPackageInfo(image *models.Image) (ImageDetail, error)

AddPackageInfo return info related to packages on image

func (*ImageService) AddUserInfo

func (s *ImageService) AddUserInfo(image *models.Image) error

AddUserInfo downloads the ISO injects the kickstart with username and ssh key and then re-uploads the ISO into our bucket

func (*ImageService) CheckIfIsLatestVersion

func (s *ImageService) CheckIfIsLatestVersion(previousImage *models.Image) error

CheckIfIsLatestVersion make sure that there is no same image version present

func (*ImageService) CheckImageName

func (s *ImageService) CheckImageName(name, orgID string) (bool, error)

CheckImageName returns false if the image does not exist and true if the image exists

func (*ImageService) CreateImage

func (s *ImageService) CreateImage(image *models.Image) error

CreateImage sets up the image for the EDA-based CreateImage

func (*ImageService) CreateInstallerForImage

func (s *ImageService) CreateInstallerForImage(ctx context.Context, image *models.Image) (*models.Image, chan error, error)

CreateInstallerForImage creates a installer given an existing image

func (*ImageService) CreateRepoForImage

func (s *ImageService) CreateRepoForImage(ctx context.Context, img *models.Image) (*models.Repo, error)

CreateRepoForImage creates the OSTree repo to host that image

func (*ImageService) DeleteImage

func (s *ImageService) DeleteImage(i *models.Image) error

func (*ImageService) GetImageByID

func (s *ImageService) GetImageByID(imageID string) (*models.Image, error)

GetImageByID retrieves an image by its identifier

func (*ImageService) GetImageByIDExtended

func (s *ImageService) GetImageByIDExtended(imageID uint, gormDB *gorm.DB) (*models.Image, error)

GetImageByIDExtended retrieves an image by its identifier and uses the supplied gormDB instance This is more customizable function version, that will get only the needed data, if gormDB is nil, we get an image without any related data (Commit, Installer , ThirdPartyRepositories, CustomPackages, Packages ...)

func (*ImageService) GetImageByOSTreeCommitHash

func (s *ImageService) GetImageByOSTreeCommitHash(commitHash string) (*models.Image, error)

GetImageByOSTreeCommitHash retrieves an image by its ostree commit hash

func (*ImageService) GetImageDevicesCount

func (s *ImageService) GetImageDevicesCount(imageId uint) (int64, error)

GetImageDevicesCount returns a list of devices running an image in an org.

func (*ImageService) GetImagesView

func (s *ImageService) GetImagesView(limit int, offset int, tx *gorm.DB) (*[]models.ImageView, error)

GetImagesView returns a list of Images view.

func (*ImageService) GetImagesViewCount

func (s *ImageService) GetImagesViewCount(tx *gorm.DB) (int64, error)

GetImagesViewCount get the Images view records count

func (*ImageService) GetMetadata

func (s *ImageService) GetMetadata(image *models.Image) (*models.Image, error)

GetMetadata return package info when has an update to the image

func (*ImageService) GetRollbackImage

func (s *ImageService) GetRollbackImage(image *models.Image) (*models.Image, error)

GetRollbackImage returns the previous image from the image set in case of a rollback

func (*ImageService) GetUpdateInfo

func (s *ImageService) GetUpdateInfo(image models.Image) (*models.ImageUpdateAvailable, error)

GetUpdateInfo return package info when has an update to the image

func (*ImageService) ProcessImage

func (s *ImageService) ProcessImage(ctx context.Context, img *models.Image, handleInterruptSignal bool) error

ProcessImage creates an Image for an OrgID on Image Builder and on our database

func (*ImageService) ResumeCreateImage

func (s *ImageService) ResumeCreateImage(ctx context.Context, image *models.Image) error

ResumeCreateImage retries the whole post process of the image creation

func (*ImageService) RetryCreateImage

func (s *ImageService) RetryCreateImage(ctx context.Context, image *models.Image) error

RetryCreateImage retries the whole post process of the image creation

func (*ImageService) SendImageNotification

func (s *ImageService) SendImageNotification(i *models.Image) (ImageNotification, error)

SendImageNotification connects to platform.notifications.ingress on image topic

func (*ImageService) SetBuildingStatusOnImageToRetryBuild

func (s *ImageService) SetBuildingStatusOnImageToRetryBuild(image *models.Image) error

SetBuildingStatusOnImageToRetryBuild set building status on image so we can try the build

func (*ImageService) SetDevicesUpdateAvailabilityFromImageSet

func (s *ImageService) SetDevicesUpdateAvailabilityFromImageSet(orgID string, ImageSetID uint) error

SetDevicesUpdateAvailabilityFromImageSet set whether updates available or not for all devices that use images of imageSet.

func (*ImageService) SetErrorStatusOnImage

func (s *ImageService) SetErrorStatusOnImage(err error, image *models.Image)

SetErrorStatusOnImage is a helper function that sets the error status on images

func (*ImageService) SetFinalImageStatus

func (s *ImageService) SetFinalImageStatus(i *models.Image)

SetFinalImageStatus sets the final image status

func (*ImageService) SetImageContentSourcesRepositories

func (s *ImageService) SetImageContentSourcesRepositories(image *models.Image) error

SetImageContentSourcesRepositories rebuild the image.ThirdPartyRepositories from content-sources repositories, we get each repository from content-sources and check if it exists locally by its url, if exists locally update its fields, if not create a new record, add the existing/created record to image.ThirdPartyRepositories the image is not saved, letting this responsibility to the caller function.

func (*ImageService) UpdateImage

func (s *ImageService) UpdateImage(image *models.Image, previousImage *models.Image) error

UpdateImage updates an image, adding a new version of this image to an imageset

func (*ImageService) UpdateImageStatus

func (s *ImageService) UpdateImageStatus(image *models.Image) (*models.Image, error)

UpdateImageStatus updates the status of an commit and/or installer based on Image Builder's status

func (*ImageService) ValidateImageCustomPackage

func (s *ImageService) ValidateImageCustomPackage(image *models.Image) error

ValidateImageCustomPackage validate package name on Image Builder

func (*ImageService) ValidateImagePackage

func (s *ImageService) ValidateImagePackage(packageName string, image *models.Image) error

ValidateImagePackage validate package name on Image Builder

type ImageServiceInterface

type ImageServiceInterface interface {
	CreateImage(image *models.Image) error
	ProcessImage(ctx context.Context, img *models.Image, handleInterruptSignal bool) error
	UpdateImage(image *models.Image, previousImage *models.Image) error
	AddUserInfo(image *models.Image) error
	UpdateImageStatus(image *models.Image) (*models.Image, error)
	SetErrorStatusOnImage(err error, i *models.Image)
	CreateRepoForImage(context.Context, *models.Image) (*models.Repo, error)
	CreateInstallerForImage(context.Context, *models.Image) (*models.Image, chan error, error)
	SetImageContentSourcesRepositories(image *models.Image) error
	GetImageByID(id string) (*models.Image, error)
	GetImageByIDExtended(imageID uint, gormDB *gorm.DB) (*models.Image, error)
	GetImageDevicesCount(imageId uint) (int64, error)
	GetUpdateInfo(image models.Image) (*models.ImageUpdateAvailable, error)
	AddPackageInfo(image *models.Image) (ImageDetail, error)
	GetImageByOSTreeCommitHash(commitHash string) (*models.Image, error)
	CheckImageName(name, orgID string) (bool, error)
	RetryCreateImage(context.Context, *models.Image) error
	ResumeCreateImage(context.Context, *models.Image) error
	GetMetadata(image *models.Image) (*models.Image, error)
	SetFinalImageStatus(i *models.Image)
	CheckIfIsLatestVersion(previousImage *models.Image) error
	SetBuildingStatusOnImageToRetryBuild(image *models.Image) error
	GetRollbackImage(image *models.Image) (*models.Image, error)
	SendImageNotification(image *models.Image) (ImageNotification, error)
	SetDevicesUpdateAvailabilityFromImageSet(orgID string, ImageSetID uint) error
	ValidateImagePackage(pack string, image *models.Image) error
	GetImagesViewCount(tx *gorm.DB) (int64, error)
	GetImagesView(limit int, offset int, tx *gorm.DB) (*[]models.ImageView, error)
	SetLog(log.FieldLogger)
	DeleteImage(image *models.Image) error
}

ImageServiceInterface defines the interface that helps handle the business logic of creating RHEL For Edge Images. This interface is used for mock generation.

func NewImageService

func NewImageService(ctx context.Context, log log.FieldLogger) ImageServiceInterface

NewImageService gives a instance of the main implementation of a ImageServiceInterface

type ImageSetAlreadyExists

type ImageSetAlreadyExists struct{}

ImageSetAlreadyExists indicates the ImageSet attempting to be created already exists

func (*ImageSetAlreadyExists) Error

func (e *ImageSetAlreadyExists) Error() string

type ImageSetIDView

type ImageSetIDView struct {
	ImageBuildIsoURL string          `json:"ImageBuildIsoURL"`
	ImageSet         models.ImageSet `json:"ImageSet"`
	LastImageDetails ImageDetail     `json:"LastImageDetails"`
}

ImageSetIDView is the image set details view returned for ui image-set display

type ImageSetImageIDView

type ImageSetImageIDView struct {
	ImageBuildIsoURL string          `json:"ImageBuildIsoURL"`
	ImageSet         models.ImageSet `json:"ImageSet"`
	ImageDetails     ImageDetail     `json:"ImageDetails"`
}

ImageSetImageIDView is the image set image view returned for ui image-set / version display

type ImageSetInUse

type ImageSetInUse struct{}

ImageSetInUse indicates unable to delete an image set

func (*ImageSetInUse) Error

func (e *ImageSetInUse) Error() string

type ImageSetNotFoundError

type ImageSetNotFoundError struct{}

ImageSetNotFoundError indicates the image-set was not found

func (*ImageSetNotFoundError) Error

func (e *ImageSetNotFoundError) Error() string

type ImageSetUnDefined

type ImageSetUnDefined struct{}

ImageSetUnDefined indicates the image has no imageSetDefined

func (*ImageSetUnDefined) Error

func (e *ImageSetUnDefined) Error() string

type ImageSetsService

type ImageSetsService struct {
	Service
}

ImageSetsService is the main implementation of a ImageSetsServiceInterface

func (*ImageSetsService) DeleteImageSet

func (s *ImageSetsService) DeleteImageSet(imageSetID uint) error

func (*ImageSetsService) GetDeviceIdsByImageSetID

func (s *ImageSetsService) GetDeviceIdsByImageSetID(imageSetID uint) (int, []string, error)

func (*ImageSetsService) GetImageSetImageViewByID

func (s *ImageSetsService) GetImageSetImageViewByID(imageSetID uint, imageID uint) (*ImageSetImageIDView, error)

GetImageSetImageViewByID return image-set image view details info, the image set data, the build iso url and the image detailsInfo

func (*ImageSetsService) GetImageSetViewByID

func (s *ImageSetsService) GetImageSetViewByID(imageSetID uint) (*ImageSetIDView, error)

GetImageSetViewByID return the data related to image set, data, build iso url, last image and images view.

func (*ImageSetsService) GetImageSetsBuildIsoURL

func (s *ImageSetsService) GetImageSetsBuildIsoURL(orgID string, imageSetIDS []uint) (map[uint]uint, error)

GetImageSetsBuildIsoURL return a map of image-set id and the latest successfully built installer id

func (*ImageSetsService) GetImageSetsByID

func (s *ImageSetsService) GetImageSetsByID(imageSetID int) (*models.ImageSet, error)

GetImageSetsByID to get image set by id

func (*ImageSetsService) GetImageSetsView

func (s *ImageSetsService) GetImageSetsView(limit int, offset int, tx *gorm.DB) (*[]models.ImageSetView, error)

GetImageSetsView returns a list of ImageSets.

func (*ImageSetsService) GetImageSetsViewCount

func (s *ImageSetsService) GetImageSetsViewCount(tx *gorm.DB) (int64, error)

GetImageSetsViewCount get the ImageSets view records count

func (*ImageSetsService) GetImagesViewData

func (s *ImageSetsService) GetImagesViewData(imageSetID uint, imagesLimit int, imagesOffSet int, imagesDBFilter *gorm.DB) (*ImagesViewData, error)

GetImagesViewData return images view count and images view data of the supplied image-set

type ImageSetsServiceInterface

type ImageSetsServiceInterface interface {
	GetImageSetsByID(imageSetID int) (*models.ImageSet, error)
	GetImageSetsViewCount(tx *gorm.DB) (int64, error)
	GetImageSetsView(limit int, offset int, tx *gorm.DB) (*[]models.ImageSetView, error)
	GetImageSetViewByID(imageSetID uint) (*ImageSetIDView, error)
	GetImageSetsBuildIsoURL(orgID string, imageSetIDS []uint) (map[uint]uint, error)
	GetImagesViewData(imageSetID uint, imagesLimit int, imagesOffSet int, tx *gorm.DB) (*ImagesViewData, error)
	GetImageSetImageViewByID(imageSetID uint, imageID uint) (*ImageSetImageIDView, error)
	GetDeviceIdsByImageSetID(imageSetID uint) (int, []string, error)
	DeleteImageSet(imageSetID uint) error
}

ImageSetsServiceInterface defines the interface that helps handle the business logic of ImageSets

func NewImageSetsService

func NewImageSetsService(ctx context.Context, log log.FieldLogger) ImageSetsServiceInterface

NewImageSetsService gives an instance of the main implementation of a ImageSetsServiceInterface

type ImageUnDefined

type ImageUnDefined struct{}

ImageUnDefined indicates the image is undefined in the db

func (*ImageUnDefined) Error

func (e *ImageUnDefined) Error() string

type ImageVersionAlreadyExists

type ImageVersionAlreadyExists struct{}

ImageVersionAlreadyExists indicates the updated image version was already present

func (*ImageVersionAlreadyExists) Error

func (e *ImageVersionAlreadyExists) Error() string

type ImagesViewData

type ImagesViewData struct {
	Count int64              `json:"count"`
	Data  []models.ImageView `json:"data"`
}

ImagesViewData is the images view data return for images view with filters , limit, offSet

type InvalidURLForCustomRepo

type InvalidURLForCustomRepo struct{}

InvalidURLForCustomRepo indicates the Third Party Repository url is invalid

func (*InvalidURLForCustomRepo) Error

func (e *InvalidURLForCustomRepo) Error() string

type KafkaAllBrokersDown

type KafkaAllBrokersDown struct{}

KafkaAllBrokersDown indicates that the error has occured due to kafka broker issue

func (*KafkaAllBrokersDown) Error

func (e *KafkaAllBrokersDown) Error() string

type KafkaConsumerService

type KafkaConsumerService struct {
	Reader        *kafka.Consumer
	UpdateService UpdateServiceInterface
	DeviceService DeviceServiceInterface
	ImageService  ImageServiceInterface
	RetryMinutes  uint
	// contains filtered or unexported fields
}

KafkaConsumerService is the implementation of a consumer service based on Kafka topics

func (*KafkaConsumerService) Close

func (s *KafkaConsumerService) Close()

Close wraps up reader work

func (*KafkaConsumerService) ConsumePlatformInventoryEvents

func (s *KafkaConsumerService) ConsumePlatformInventoryEvents() error

ConsumePlatformInventoryEvents parses create events from platform.inventory.events kafka topic and save them as devices in the DB

func (*KafkaConsumerService) ConsumePlaybookDispatcherRuns

func (s *KafkaConsumerService) ConsumePlaybookDispatcherRuns() error

ConsumePlaybookDispatcherRuns is the method that consumes from the topic that gives us the execution of playbook from playbook dispatcher service

func (*KafkaConsumerService) Start

func (s *KafkaConsumerService) Start()

Start consumers for this application

type KafkaProducerInstanceUndefined

type KafkaProducerInstanceUndefined struct{}

KafkaProducerInstanceUndefined indicates that we were not able to get a kafka producer instance

func (*KafkaProducerInstanceUndefined) Error

type LocalFilesService

type LocalFilesService struct {
	BasicFileService
}

LocalFilesService only handles local uploads

func (*LocalFilesService) GetFile

func (s *LocalFilesService) GetFile(path string) (io.ReadCloser, error)

GetFile returns the file given a path

func (*LocalFilesService) GetSignedURL

func (s *LocalFilesService) GetSignedURL(path string) (string, error)

GetSignedURL return a signed URL

type OrgIDNotSet

type OrgIDNotSet struct{}

OrgIDNotSet indicates the account was nil

func (*OrgIDNotSet) Error

func (e *OrgIDNotSet) Error() string

type OstreeNotFound

type OstreeNotFound struct{}

OstreeNotFound was not found

func (*OstreeNotFound) Error

func (e *OstreeNotFound) Error() string

type OwnershipVoucherServiceInterface

type OwnershipVoucherServiceInterface interface{}

OwnershipVoucherServiceInterface is empty for non-fdo builds

func NewOwnershipVoucherService

func NewOwnershipVoucherService(ctx context.Context, log log.FieldLogger) OwnershipVoucherServiceInterface

NewOwnershipVoucherService returns nil for non-fdo builds

type PackageNameDoesNotExist

type PackageNameDoesNotExist struct{}

PackageNameDoesNotExist indicates that package name doesn't exist

func (*PackageNameDoesNotExist) Error

func (e *PackageNameDoesNotExist) Error() string

type ParsingISODateError

type ParsingISODateError struct{}

ParsingISODateError occurs when parsing a string for iso date fails

func (*ParsingISODateError) Error

func (e *ParsingISODateError) Error() string

type PlatformInsightsCreateUpdateEventPayload

type PlatformInsightsCreateUpdateEventPayload struct {
	Type string `json:"type"`
	Host host   `json:"host"`
}

PlatformInsightsCreateUpdateEventPayload is the body of the create event found on the platform.inventory.events kafka topic.

type PlatformInsightsDeleteEventPayload

type PlatformInsightsDeleteEventPayload struct {
	Type  string `json:"type"`
	ID    string `json:"id"`
	OrgID string `json:"org_id"`
}

PlatformInsightsDeleteEventPayload is the body of the delete event found on the platform.inventory.events kafka topic.

type PlatformInsightsGroup

type PlatformInsightsGroup struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type PlaybookDispatcherEvent

type PlaybookDispatcherEvent struct {
	EventType string                         `json:"event_type"`
	Payload   PlaybookDispatcherEventPayload `json:"payload"`
}

PlaybookDispatcherEvent is the event that gets sent to the Kafka broker when an update finishes

type PlaybookDispatcherEventPayload

type PlaybookDispatcherEventPayload struct {
	ID            string `json:"id"`
	OrgID         string `json:"org_id"`
	Recipient     string `json:"recipient"`
	CorrelationID string `json:"correlation_id"`
	Service       string `json:"service"`
	URL           string `json:"url"`
	Labels        struct {
		ID      string `json:"id"`
		StateID string `json:"state_id"`
	} `json:"labels"`
	Status    string    `json:"status"`
	Timeout   int       `json:"timeout"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

PlaybookDispatcherEventPayload belongs to PlaybookDispatcherEvent

type RecipientNotification

type RecipientNotification struct {
	OnlyAdmins            bool     `json:"only_admins"`
	IgnoreUserPreferences bool     `json:"ignore_user_preferences"`
	Users                 []string `json:"users"`
}

RecipientNotification is used to track recipients to notification

type RepoBuilder

type RepoBuilder struct {
	Service
	FilesService FilesService

	Log log.FieldLogger
	// contains filtered or unexported fields
}

RepoBuilder is the implementation of a RepoBuilderInterface

func (*RepoBuilder) BuildUpdateRepo

func (rb *RepoBuilder) BuildUpdateRepo(id uint) (*models.UpdateTransaction, error)

BuildUpdateRepo build an update repo with the set of commits all merged into a single repo with static deltas generated between them all

func (*RepoBuilder) DownloadVersionRepo

func (rb *RepoBuilder) DownloadVersionRepo(c *models.Commit, dest string) (string, error)

DownloadVersionRepo Download and Extract the repo tarball to dest dir

func (*RepoBuilder) ExtractVersionRepo

func (rb *RepoBuilder) ExtractVersionRepo(c *models.Commit, tarFileName string, dest string) error

ExtractVersionRepo Download and Extract the repo tarball to dest dir

func (*RepoBuilder) ImportRepo

func (rb *RepoBuilder) ImportRepo(r *models.Repo) (*models.Repo, error)

ImportRepo (unpack and upload) a single repo

func (*RepoBuilder) RepoPullLocalStaticDeltas

func (rb *RepoBuilder) RepoPullLocalStaticDeltas(u *models.Commit, o *models.Commit, uprepo string, oldrepo string) error

RepoPullLocalStaticDeltas pull local repo into the new update repo and compute static deltas uprepo should be where the update commit lives, u is the update commit oldrepo should be where the old commit lives, o is the commit to be merged

func (*RepoBuilder) UploadVersionRepo

func (rb *RepoBuilder) UploadVersionRepo(c *models.Commit, tarFileName string) error

UploadVersionRepo uploads the repo tarball to the repository storage

type RepoBuilderInterface

type RepoBuilderInterface interface {
	BuildUpdateRepo(id uint) (*models.UpdateTransaction, error)
	ImportRepo(r *models.Repo) (*models.Repo, error)
	DownloadVersionRepo(c *models.Commit, dest string) (string, error)
	ExtractVersionRepo(c *models.Commit, tarFileName string, dest string) error
	UploadVersionRepo(c *models.Commit, tarFileName string) error
	RepoPullLocalStaticDeltas(u *models.Commit, o *models.Commit, uprepo string, oldrepo string) error
}

RepoBuilderInterface defines the interface of a repository builder

func NewRepoBuilder

func NewRepoBuilder(ctx context.Context, log log.FieldLogger) RepoBuilderInterface

NewRepoBuilder initializes the repository builder in this package

type RepoService

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

RepoService is the main implementation of a RepoServiceInterface

func (*RepoService) GetRepoByID

func (s *RepoService) GetRepoByID(repoID *uint) (*models.Repo, error)

GetRepoByID receives RepoID uint and get a *models.Repo back

type RepoServiceInterface

type RepoServiceInterface interface {
	GetRepoByID(repoID *uint) (*models.Repo, error)
}

RepoServiceInterface defines the interface to handle the business logic of RHEL for Edge Devices

func NewRepoService

func NewRepoService(ctx context.Context, log log.FieldLogger) RepoServiceInterface

NewRepoService gives a instance of the main implementation of RepoServiceInterface

type RetryCreateImageJob

type RetryCreateImageJob struct {
	ImageID uint
}

type RpmOSTreeDeployment

type RpmOSTreeDeployment struct {
	Booted   bool   `json:"booted"`
	Checksum string `json:"checksum"`
}

RpmOSTreeDeployment is the member of PlatformInsightsCreateUpdateEventPayload host system profile rpm ostree deployments list

type S3FilesService

type S3FilesService struct {
	Client files.S3ClientInterface
	Bucket string
	BasicFileService
}

S3FilesService contains S3 files-related information

func (*S3FilesService) GetFile

func (s *S3FilesService) GetFile(path string) (io.ReadCloser, error)

GetFile returns the file given a path

func (*S3FilesService) GetSignedURL

func (s *S3FilesService) GetSignedURL(path string) (string, error)

GetSignedURL return and aws s3 bucket signed url

type Service

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

Service is a blueprint for a service

func NewService

func NewService(ctx context.Context, log log.FieldLogger) Service

NewService creates a new service

func (*Service) SetLog

func (s *Service) SetLog(log log.FieldLogger)

SetLog sets a new log on the struct

type ServiceInterface

type ServiceInterface interface{}

ServiceInterface defines the interface for a service

type SomeDevicesDoesNotExists

type SomeDevicesDoesNotExists struct{}

SomeDevicesDoesNotExists indicates that device record no image

func (*SomeDevicesDoesNotExists) Error

func (e *SomeDevicesDoesNotExists) Error() string

type TemplateRemoteInfo

type TemplateRemoteInfo struct {
	RemoteName          string
	RemoteURL           string
	ContentURL          string
	GpgVerify           string
	UpdateTransactionID uint
	RemoteOstreeUpdate  string
	OSTreeRef           string
}

TemplateRemoteInfo the values to playbook

func NewTemplateRemoteInfo

func NewTemplateRemoteInfo(update *models.UpdateTransaction) TemplateRemoteInfo

NewTemplateRemoteInfo contains the info for the ostree remote file to be written to the system

type ThirdPartyRepoService

type ThirdPartyRepoService struct {
	Service
}

ThirdPartyRepoService is the main implementation of a ThirdPartyRepoServiceInterface

func (*ThirdPartyRepoService) CreateThirdPartyRepo

func (s *ThirdPartyRepoService) CreateThirdPartyRepo(thirdPartyRepo *models.ThirdPartyRepo, orgID string) (*models.ThirdPartyRepo, error)

CreateThirdPartyRepo creates the ThirdPartyRepo for an Org on our database

func (*ThirdPartyRepoService) DeleteThirdPartyRepoByID

func (s *ThirdPartyRepoService) DeleteThirdPartyRepoByID(ID string) (*models.ThirdPartyRepo, error)

DeleteThirdPartyRepoByID deletes the third party repository using ID

func (*ThirdPartyRepoService) GetThirdPartyRepoByID

func (s *ThirdPartyRepoService) GetThirdPartyRepoByID(ID string) (*models.ThirdPartyRepo, error)

GetThirdPartyRepoByID gets the Third Party Repository by ID from the database

func (*ThirdPartyRepoService) ThirdPartyRepoNameExists

func (s *ThirdPartyRepoService) ThirdPartyRepoNameExists(orgID string, name string) (bool, error)

ThirdPartyRepoNameExists check if a repo with the requested name exists

func (*ThirdPartyRepoService) ThirdPartyRepoURLExists

func (s *ThirdPartyRepoService) ThirdPartyRepoURLExists(orgID string, url string) (bool, error)

ThirdPartyRepoURLExists check if a repo with the requested url exist

func (*ThirdPartyRepoService) UpdateThirdPartyRepo

func (s *ThirdPartyRepoService) UpdateThirdPartyRepo(tprepo *models.ThirdPartyRepo, orgID string, ID string) error

UpdateThirdPartyRepo updates the existing third party repository

type ThirdPartyRepoServiceInterface

type ThirdPartyRepoServiceInterface interface {
	CreateThirdPartyRepo(tprepo *models.ThirdPartyRepo, orgID string) (*models.ThirdPartyRepo, error)
	GetThirdPartyRepoByID(ID string) (*models.ThirdPartyRepo, error)
	UpdateThirdPartyRepo(tprepo *models.ThirdPartyRepo, orgID string, ID string) error
	DeleteThirdPartyRepoByID(ID string) (*models.ThirdPartyRepo, error)
	ThirdPartyRepoNameExists(orgID string, name string) (bool, error)
	ThirdPartyRepoURLExists(orgID string, url string) (bool, error)
}

ThirdPartyRepoServiceInterface defines the interface that helps handles the business logic of creating Third Party Repository

func NewThirdPartyRepoService

func NewThirdPartyRepoService(ctx context.Context, log log.FieldLogger) ThirdPartyRepoServiceInterface

NewThirdPartyRepoService gives a instance of the main implementation of a ThirdPartyRepoServiceInterface

type ThirdPartyRepositoryAlreadyExists

type ThirdPartyRepositoryAlreadyExists struct{}

ThirdPartyRepositoryAlreadyExists indicates the Third Party Repository already exists

func (*ThirdPartyRepositoryAlreadyExists) Error

type ThirdPartyRepositoryImagesExists

type ThirdPartyRepositoryImagesExists struct{}

ThirdPartyRepositoryImagesExists indicates the Third Party Repository has been used in some images

func (*ThirdPartyRepositoryImagesExists) Error

type ThirdPartyRepositoryInfoIsInvalid

type ThirdPartyRepositoryInfoIsInvalid struct{}

ThirdPartyRepositoryInfoIsInvalid indicates the Third Party Repository info is not valid

func (*ThirdPartyRepositoryInfoIsInvalid) Error

type ThirdPartyRepositoryNameIsEmpty

type ThirdPartyRepositoryNameIsEmpty struct{}

ThirdPartyRepositoryNameIsEmpty indicates the Third Party Repository name is empty

func (*ThirdPartyRepositoryNameIsEmpty) Error

type ThirdPartyRepositoryNotFound

type ThirdPartyRepositoryNotFound struct{}

ThirdPartyRepositoryNotFound indicates the Third Party Repository was not found

func (*ThirdPartyRepositoryNotFound) Error

type ThirdPartyRepositoryURLIsEmpty

type ThirdPartyRepositoryURLIsEmpty struct{}

ThirdPartyRepositoryURLIsEmpty indicates the Third Party Repository url is empty

func (*ThirdPartyRepositoryURLIsEmpty) Error

type ThirdPartyRepositoryWithURLAlreadyExists

type ThirdPartyRepositoryWithURLAlreadyExists struct{}

ThirdPartyRepositoryWithURLAlreadyExists indicates the Third Party Repository already exists with the requested url

func (*ThirdPartyRepositoryWithURLAlreadyExists) Error

type TypeEnum

type TypeEnum string

TypeEnum define type for groups

type UnameSSH

type UnameSSH struct {
	Sshkey   string
	Username string
}

UnameSSH is the template struct for username and ssh key

type UpdateNotFoundError

type UpdateNotFoundError struct{}

UpdateNotFoundError indicates the update was not found

func (*UpdateNotFoundError) Error

func (e *UpdateNotFoundError) Error() string

type UpdateService

type UpdateService struct {
	Service
	ImageService    ImageServiceInterface
	RepoBuilder     RepoBuilderInterface
	FilesService    FilesService
	DeviceService   DeviceServiceInterface
	Inventory       inventory.ClientInterface
	PlaybookClient  playbookdispatcher.ClientInterface
	ProducerService kafkacommon.ProducerServiceInterface
	TopicService    kafkacommon.TopicServiceInterface
	WaitForReboot   time.Duration
}

UpdateService is the main implementation of a UpdateServiceInterface

func (*UpdateService) BuildUpdateRepo

func (s *UpdateService) BuildUpdateRepo(orgID string, updateID uint) (*models.UpdateTransaction, error)

BuildUpdateRepo determines if a static delta is necessary and calls the repo builder

func (*UpdateService) BuildUpdateTransactions

func (s *UpdateService) BuildUpdateTransactions(devicesUpdate *models.DevicesUpdate,
	orgID string, commit *models.Commit) (*[]models.UpdateTransaction, error)

BuildUpdateTransactions creates the update transaction to be sent to Playbook Dispatcher

func (*UpdateService) CreateUpdate

func (s *UpdateService) CreateUpdate(id uint) (*models.UpdateTransaction, error)

CreateUpdate is the function that creates an update transaction

func (*UpdateService) CreateUpdateAsync

func (s *UpdateService) CreateUpdateAsync(id uint)

CreateUpdateAsync is the function that creates an update transaction asynchronously

func (*UpdateService) GetUpdatePlaybook

func (s *UpdateService) GetUpdatePlaybook(update *models.UpdateTransaction) (io.ReadCloser, error)

GetUpdatePlaybook is the function that returns the path to an update playbook

func (*UpdateService) GetUpdateTransactionsForDevice

func (s *UpdateService) GetUpdateTransactionsForDevice(device *models.Device) (*[]models.UpdateTransaction, error)

GetUpdateTransactionsForDevice returns all update transactions for a given device

func (*UpdateService) InventoryGroupDevicesUpdateInfo

func (s *UpdateService) InventoryGroupDevicesUpdateInfo(orgID string, inventoryGroupUUID string) (*models.InventoryGroupDevicesUpdateInfo, error)

InventoryGroupDevicesUpdateInfo return the inventory group update info

func (*UpdateService) ProcessPlaybookDispatcherRunEvent

func (s *UpdateService) ProcessPlaybookDispatcherRunEvent(message []byte) error

ProcessPlaybookDispatcherRunEvent is the method that processes messages from playbook dispatcher to set update statuses

func (*UpdateService) SendDeviceNotification

func (s *UpdateService) SendDeviceNotification(i *models.UpdateTransaction) (ImageNotification, error)

SendDeviceNotification connects to platform.notifications.ingress on image topic

func (*UpdateService) SetUpdateErrorStatusWhenInterrupted

func (s *UpdateService) SetUpdateErrorStatusWhenInterrupted(intCtx context.Context, update models.UpdateTransaction, sigint chan os.Signal, intCancel context.CancelFunc)

SetUpdateErrorStatusWhenInterrupted set the update to error status when instance is interrupted

func (*UpdateService) SetUpdateStatus

func (s *UpdateService) SetUpdateStatus(update *models.UpdateTransaction) error

SetUpdateStatus is the function to set the update status from an UpdateTransaction

func (*UpdateService) SetUpdateStatusBasedOnDispatchRecord

func (s *UpdateService) SetUpdateStatusBasedOnDispatchRecord(dispatchRecord models.DispatchRecord) error

SetUpdateStatusBasedOnDispatchRecord is the function that, given a dispatch record, finds the update transaction related to and update its status if necessary

func (*UpdateService) UpdateDevicesFromUpdateTransaction

func (s *UpdateService) UpdateDevicesFromUpdateTransaction(update models.UpdateTransaction) error

UpdateDevicesFromUpdateTransaction update device with new image and update availability

func (*UpdateService) ValidateUpdateDeviceGroup

func (s *UpdateService) ValidateUpdateDeviceGroup(orgID string, deviceGroupID uint) (bool, error)

ValidateUpdateDeviceGroup validate the devices on device group for update

func (*UpdateService) ValidateUpdateSelection

func (s *UpdateService) ValidateUpdateSelection(orgID string, imageIds []uint) (bool, error)

ValidateUpdateSelection validate the images for update

func (*UpdateService) WriteTemplate

func (s *UpdateService) WriteTemplate(templateInfo TemplateRemoteInfo, orgID string) (string, error)

WriteTemplate is the function that writes the template to a file

type UpdateServiceInterface

type UpdateServiceInterface interface {
	BuildUpdateTransactions(devicesUpdate *models.DevicesUpdate, orgID string, commit *models.Commit) (*[]models.UpdateTransaction, error)
	BuildUpdateRepo(orgID string, updateID uint) (*models.UpdateTransaction, error)
	CreateUpdate(id uint) (*models.UpdateTransaction, error)
	CreateUpdateAsync(id uint)
	GetUpdatePlaybook(update *models.UpdateTransaction) (io.ReadCloser, error)
	GetUpdateTransactionsForDevice(device *models.Device) (*[]models.UpdateTransaction, error)
	ProcessPlaybookDispatcherRunEvent(message []byte) error
	WriteTemplate(templateInfo TemplateRemoteInfo, orgID string) (string, error)
	SetUpdateStatusBasedOnDispatchRecord(dispatchRecord models.DispatchRecord) error
	SetUpdateStatus(update *models.UpdateTransaction) error
	SendDeviceNotification(update *models.UpdateTransaction) (ImageNotification, error)
	UpdateDevicesFromUpdateTransaction(update models.UpdateTransaction) error
	ValidateUpdateSelection(orgID string, imageIds []uint) (bool, error) // nolint:revive
	ValidateUpdateDeviceGroup(orgID string, deviceGroupID uint) (bool, error)
	InventoryGroupDevicesUpdateInfo(orgID string, inventoryGroupUUID string) (*models.InventoryGroupDevicesUpdateInfo, error)
}

UpdateServiceInterface defines the interface that helps handle the business logic of sending updates to an edge device

func NewUpdateService

func NewUpdateService(ctx context.Context, log log.FieldLogger) UpdateServiceInterface

NewUpdateService gives an instance of the main implementation of a UpdateServiceInterface

Directories

Path Synopsis
nolint:revive,typecheck
nolint:revive,typecheck
FIXME: golangci-lint nolint:govet,revive
FIXME: golangci-lint nolint:govet,revive
Package mock_files is a generated GoMock package.
Package mock_files is a generated GoMock package.
Package mock_services is a generated GoMock package.
Package mock_services is a generated GoMock package.
nolint:revive,typecheck
nolint:revive,typecheck
FIXME: golangci-lint nolint:revive
FIXME: golangci-lint nolint:revive

Jump to

Keyboard shortcuts

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