dataservices

package
v0.0.0-...-4560a53 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: Zlib Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrStop = errors.New("stop")

ErrStop signals the stop of computation when filtering results

Functions

func AppendFn

func AppendFn[T any](collection *[]T) func(obj interface{}) (interface{}, error)

AppendFn appends elements to the given collection slice

func FilterFn

func FilterFn[T any](collection *[]T, predicate func(T) bool) func(obj interface{}) (interface{}, error)

FilterFn appends elements to the given collection when the predicate is true

func FirstFn

func FirstFn[T any](element *T, predicate func(T) bool) func(obj interface{}) (interface{}, error)

FirstFn sets the element to the first one that satisfies the predicate and stops the computation, returns ErrStop on success

func IsErrObjectNotFound

func IsErrObjectNotFound(e error) bool

Types

type APIKeyRepository

type APIKeyRepository interface {
	BaseCRUD[portainer.APIKey, portainer.APIKeyID]
	GetAPIKeysByUserID(userID portainer.UserID) ([]portainer.APIKey, error)
	GetAPIKeyByDigest(digest []byte) (*portainer.APIKey, error)
}

APIKeyRepositoryService

type BaseCRUD

type BaseCRUD[T any, I constraints.Integer] interface {
	Create(element *T) error
	Read(ID I) (*T, error)
	ReadAll() ([]T, error)
	Update(ID I, element *T) error
	Delete(ID I) error
}

type BaseDataService

type BaseDataService[T any, I constraints.Integer] struct {
	Bucket     string
	Connection portainer.Connection
}

func (*BaseDataService[T, I]) BucketName

func (s *BaseDataService[T, I]) BucketName() string

func (BaseDataService[T, I]) Delete

func (service BaseDataService[T, I]) Delete(ID I) error

func (BaseDataService[T, I]) Read

func (service BaseDataService[T, I]) Read(ID I) (*T, error)

func (BaseDataService[T, I]) ReadAll

func (service BaseDataService[T, I]) ReadAll() ([]T, error)

func (*BaseDataService[T, I]) Tx

func (service *BaseDataService[T, I]) Tx(tx portainer.Transaction) BaseDataServiceTx[T, I]

func (BaseDataService[T, I]) Update

func (service BaseDataService[T, I]) Update(ID I, element *T) error

type BaseDataServiceTx

type BaseDataServiceTx[T any, I constraints.Integer] struct {
	Bucket     string
	Connection portainer.Connection
	Tx         portainer.Transaction
}

func (BaseDataServiceTx[T, I]) BucketName

func (service BaseDataServiceTx[T, I]) BucketName() string

func (BaseDataServiceTx[T, I]) Delete

func (service BaseDataServiceTx[T, I]) Delete(ID I) error

func (BaseDataServiceTx[T, I]) Read

func (service BaseDataServiceTx[T, I]) Read(ID I) (*T, error)

func (BaseDataServiceTx[T, I]) ReadAll

func (service BaseDataServiceTx[T, I]) ReadAll() ([]T, error)

func (BaseDataServiceTx[T, I]) Update

func (service BaseDataServiceTx[T, I]) Update(ID I, element *T) error

type CustomTemplateService

type CustomTemplateService interface {
	BaseCRUD[portainer.CustomTemplate, portainer.CustomTemplateID]
	GetNextIdentifier() int
}

CustomTemplateService represents a service to manage custom templates

type DataStore

type DataStore interface {
	Open() (newStore bool, err error)
	Init() error
	Close() error
	UpdateTx(func(DataStoreTx) error) error
	ViewTx(func(DataStoreTx) error) error
	MigrateData() error
	Rollback(force bool) error
	CheckCurrentEdition() error
	BackupTo(w io.Writer) error
	Export(filename string) (err error)

	DataStoreTx
}

type DataStoreTx

type DataStoreTx interface {
	IsErrObjectNotFound(err error) bool
	CustomTemplate() CustomTemplateService
	EdgeGroup() EdgeGroupService
	EdgeJob() EdgeJobService
	EdgeStack() EdgeStackService
	Endpoint() EndpointService
	EndpointGroup() EndpointGroupService
	EndpointRelation() EndpointRelationService
	FDOProfile() FDOProfileService
	HelmUserRepository() HelmUserRepositoryService
	Registry() RegistryService
	ResourceControl() ResourceControlService
	Role() RoleService
	APIKeyRepository() APIKeyRepository
	Settings() SettingsService
	Snapshot() SnapshotService
	SSLSettings() SSLSettingsService
	Stack() StackService
	Tag() TagService
	TeamMembership() TeamMembershipService
	Team() TeamService
	TunnelServer() TunnelServerService
	User() UserService
	Version() VersionService
	Webhook() WebhookService
}

type EdgeGroupService

type EdgeGroupService interface {
	BaseCRUD[portainer.EdgeGroup, portainer.EdgeGroupID]
	UpdateEdgeGroupFunc(ID portainer.EdgeGroupID, updateFunc func(group *portainer.EdgeGroup)) error
}

EdgeGroupService represents a service to manage Edge groups

type EdgeJobService

type EdgeJobService interface {
	BaseCRUD[portainer.EdgeJob, portainer.EdgeJobID]
	CreateWithID(ID portainer.EdgeJobID, edgeJob *portainer.EdgeJob) error
	UpdateEdgeJobFunc(ID portainer.EdgeJobID, updateFunc func(edgeJob *portainer.EdgeJob)) error
	GetNextIdentifier() int
}

EdgeJobService represents a service to manage Edge jobs

type EdgeStackService

type EdgeStackService interface {
	EdgeStacks() ([]portainer.EdgeStack, error)
	EdgeStack(ID portainer.EdgeStackID) (*portainer.EdgeStack, error)
	EdgeStackVersion(ID portainer.EdgeStackID) (int, bool)
	Create(id portainer.EdgeStackID, edgeStack *portainer.EdgeStack) error
	UpdateEdgeStack(ID portainer.EdgeStackID, edgeStack *portainer.EdgeStack) error
	UpdateEdgeStackFunc(ID portainer.EdgeStackID, updateFunc func(edgeStack *portainer.EdgeStack)) error
	DeleteEdgeStack(ID portainer.EdgeStackID) error
	GetNextIdentifier() int
	BucketName() string
}

EdgeStackService represents a service to manage Edge stacks

type EndpointGroupService

type EndpointGroupService interface {
	BaseCRUD[portainer.EndpointGroup, portainer.EndpointGroupID]
}

EndpointGroupService represents a service for managing environment(endpoint) group data

type EndpointRelationService

type EndpointRelationService interface {
	EndpointRelations() ([]portainer.EndpointRelation, error)
	EndpointRelation(EndpointID portainer.EndpointID) (*portainer.EndpointRelation, error)
	Create(endpointRelation *portainer.EndpointRelation) error
	UpdateEndpointRelation(EndpointID portainer.EndpointID, endpointRelation *portainer.EndpointRelation) error
	DeleteEndpointRelation(EndpointID portainer.EndpointID) error
	BucketName() string
}

EndpointRelationService represents a service for managing environment(endpoint) relations data

type EndpointService

type EndpointService interface {
	Endpoint(ID portainer.EndpointID) (*portainer.Endpoint, error)
	EndpointIDByEdgeID(edgeID string) (portainer.EndpointID, bool)
	Heartbeat(endpointID portainer.EndpointID) (int64, bool)
	UpdateHeartbeat(endpointID portainer.EndpointID)
	Endpoints() ([]portainer.Endpoint, error)
	Create(endpoint *portainer.Endpoint) error
	UpdateEndpoint(ID portainer.EndpointID, endpoint *portainer.Endpoint) error
	DeleteEndpoint(ID portainer.EndpointID) error
	GetNextIdentifier() int
	BucketName() string
}

EndpointService represents a service for managing environment(endpoint) data

type FDOProfileService

type FDOProfileService interface {
	BaseCRUD[portainer.FDOProfile, portainer.FDOProfileID]
	GetNextIdentifier() int
}

FDOProfileService represents a service to manage FDO Profiles

type HelmUserRepositoryService

type HelmUserRepositoryService interface {
	BaseCRUD[portainer.HelmUserRepository, portainer.HelmUserRepositoryID]
	HelmUserRepositoryByUserID(userID portainer.UserID) ([]portainer.HelmUserRepository, error)
}

HelmUserRepositoryService represents a service to manage HelmUserRepositories

type JWTService

type JWTService interface {
	GenerateToken(data *portainer.TokenData) (string, error)
	GenerateTokenForOAuth(data *portainer.TokenData, expiryTime *time.Time) (string, error)
	GenerateTokenForKubeconfig(data *portainer.TokenData) (string, error)
	ParseAndVerifyToken(token string) (*portainer.TokenData, error)
	SetUserSessionDuration(userSessionDuration time.Duration)
}

JWTService represents a service for managing JWT tokens

type RegistryService

type RegistryService interface {
	BaseCRUD[portainer.Registry, portainer.RegistryID]
}

RegistryService represents a service for managing registry data

type ResourceControlService

type ResourceControlService interface {
	BaseCRUD[portainer.ResourceControl, portainer.ResourceControlID]
	ResourceControlByResourceIDAndType(resourceID string, resourceType portainer.ResourceControlType) (*portainer.ResourceControl, error)
}

ResourceControlService represents a service for managing resource control data

type RoleService

type RoleService interface {
	BaseCRUD[portainer.Role, portainer.RoleID]
}

RoleService represents a service for managing user roles

type SSLSettingsService

type SSLSettingsService interface {
	Settings() (*portainer.SSLSettings, error)
	UpdateSettings(settings *portainer.SSLSettings) error
	BucketName() string
}

SSLSettingsService represents a service for managing application settings

type SettingsService

type SettingsService interface {
	Settings() (*portainer.Settings, error)
	UpdateSettings(settings *portainer.Settings) error
	BucketName() string
}

SettingsService represents a service for managing application settings

type SnapshotService

type SnapshotService interface {
	BaseCRUD[portainer.Snapshot, portainer.EndpointID]
}

type StackService

type StackService interface {
	BaseCRUD[portainer.Stack, portainer.StackID]
	StackByName(name string) (*portainer.Stack, error)
	StacksByName(name string) ([]portainer.Stack, error)
	GetNextIdentifier() int
	StackByWebhookID(ID string) (*portainer.Stack, error)
	RefreshableStacks() ([]portainer.Stack, error)
}

StackService represents a service for managing stack data

type TagService

type TagService interface {
	BaseCRUD[portainer.Tag, portainer.TagID]
	UpdateTagFunc(ID portainer.TagID, updateFunc func(tag *portainer.Tag)) error
}

TagService represents a service for managing tag data

type TeamMembershipService

type TeamMembershipService interface {
	BaseCRUD[portainer.TeamMembership, portainer.TeamMembershipID]
	TeamMembershipsByUserID(userID portainer.UserID) ([]portainer.TeamMembership, error)
	TeamMembershipsByTeamID(teamID portainer.TeamID) ([]portainer.TeamMembership, error)
	DeleteTeamMembershipByUserID(userID portainer.UserID) error
	DeleteTeamMembershipByTeamID(teamID portainer.TeamID) error
	DeleteTeamMembershipByTeamIDAndUserID(teamID portainer.TeamID, userID portainer.UserID) error
}

TeamMembershipService represents a service for managing team membership data

type TeamService

type TeamService interface {
	BaseCRUD[portainer.Team, portainer.TeamID]
	TeamByName(name string) (*portainer.Team, error)
}

TeamService represents a service for managing user data

type TunnelServerService

type TunnelServerService interface {
	Info() (*portainer.TunnelServerInfo, error)
	UpdateInfo(info *portainer.TunnelServerInfo) error
	BucketName() string
}

TunnelServerService represents a service for managing data associated to the tunnel server

type UserService

type UserService interface {
	BaseCRUD[portainer.User, portainer.UserID]
	UserByUsername(username string) (*portainer.User, error)
	UsersByRole(role portainer.UserRole) ([]portainer.User, error)
}

UserService represents a service for managing user data

type VersionService

type VersionService interface {
	InstanceID() (string, error)
	UpdateInstanceID(ID string) error
	Edition() (portainer.SoftwareEdition, error)
	Version() (*models.Version, error)
	UpdateVersion(*models.Version) error
}

VersionService represents a service for managing version data

type WebhookService

type WebhookService interface {
	BaseCRUD[portainer.Webhook, portainer.WebhookID]
	WebhookByResourceID(resourceID string) (*portainer.Webhook, error)
	WebhookByToken(token string) (*portainer.Webhook, error)
}

WebhookService represents a service for managing webhook data.

Jump to

Keyboard shortcuts

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