Documentation
¶
Overview ¶
Package service provides business logic for API and UI layers.
Index ¶
- Constants
- func FormatCronSchedule(cronExpr string) string
- func FormatPluginCompatibility(compatible bool) string
- func FormatTime(t time.Time) string
- func FormatTimestamp(t metav1.Time) string
- func FormatVersionWithBuild(version string, build int) string
- func IsValidKubernetesName(name string) bool
- type AvailableUpdateData
- type MaintenanceScheduleData
- type MatchedInstanceData
- type NamespaceService
- type PluginCreateData
- type PluginData
- type PluginService
- func (s *PluginService) CreatePlugin(ctx context.Context, data PluginCreateData) error
- func (s *PluginService) DeletePlugin(ctx context.Context, namespace, name string) error
- func (s *PluginService) GetPlugin(ctx context.Context, namespace, name string) (*PluginData, error)
- func (s *PluginService) GetPluginNamespaces(ctx context.Context) ([]string, error)
- func (s *PluginService) ListPlugins(ctx context.Context, namespace string) ([]PluginData, error)
- func (s *PluginService) TriggerReconciliation(ctx context.Context, namespace, name string) error
- func (s *PluginService) UpdatePlugin(ctx context.Context, data PluginUpdateData) error
- type PluginSourceData
- type PluginUpdateData
- type PluginVersionData
- type ServerCreateData
- type ServerData
- type ServerPluginData
- type ServerService
- func (s *ServerService) ApplyNow(ctx context.Context, namespace, name string) error
- func (s *ServerService) CheckStatefulSetStatus(ctx context.Context, name, namespace string) string
- func (s *ServerService) CreateServer(ctx context.Context, data ServerCreateData) error
- func (s *ServerService) DeleteServer(ctx context.Context, namespace, name string) error
- func (s *ServerService) DetermineStatus(server *mck8slexlav1beta1.PaperMCServer) string
- func (s *ServerService) GetServer(ctx context.Context, namespace, name string) (*ServerData, error)
- func (s *ServerService) GetServerByName(ctx context.Context, name string) (*ServerData, error)
- func (s *ServerService) GetServerNamespaces(ctx context.Context) ([]string, error)
- func (s *ServerService) ListServers(ctx context.Context, namespace string) ([]ServerData, error)
- func (s *ServerService) TriggerReconciliation(ctx context.Context, namespace, name string) error
- func (s *ServerService) UpdateServer(ctx context.Context, data ServerUpdateData) error
- type ServerUpdateData
- type UpdateHistoryData
Constants ¶
const ( // StatusRunning indicates the server is running normally. StatusRunning = "running" // StatusUpdating indicates the server is being updated. StatusUpdating = "updating" // StatusUnknown indicates the server status cannot be determined. StatusUnknown = "unknown" // AnnotationReconcile triggers reconciliation. AnnotationReconcile = "mc.k8s.lex.la/reconcile" // AnnotationApplyNow triggers immediate update application. AnnotationApplyNow = "mc.k8s.lex.la/apply-now" )
Variables ¶
This section is empty.
Functions ¶
func FormatCronSchedule ¶
FormatCronSchedule formats a cron schedule for display.
func FormatPluginCompatibility ¶
FormatPluginCompatibility formats plugin compatibility status.
func FormatTimestamp ¶
FormatTimestamp formats a metav1.Time for display.
func FormatVersionWithBuild ¶
FormatVersionWithBuild formats a version with build number.
func IsValidKubernetesName ¶
IsValidKubernetesName checks if a name is valid for Kubernetes resources.
Types ¶
type AvailableUpdateData ¶
AvailableUpdateData represents an available update.
type MaintenanceScheduleData ¶
type MaintenanceScheduleData struct {
CheckCron string
WindowCron string
NextWindow string
Enabled bool
}
MaintenanceScheduleData represents maintenance schedule information.
type MatchedInstanceData ¶
MatchedInstanceData represents a matched server instance.
type NamespaceService ¶
type NamespaceService struct {
// contains filtered or unexported fields
}
NamespaceService provides operations for namespace-related queries.
func NewNamespaceService ¶
func NewNamespaceService(c client.Client) *NamespaceService
NewNamespaceService creates a new NamespaceService.
func (*NamespaceService) ListNamespaces ¶
func (s *NamespaceService) ListNamespaces(ctx context.Context) ([]string, error)
ListNamespaces returns unique namespaces that have plugins or servers.
type PluginCreateData ¶
type PluginCreateData struct {
Name string
Namespace string
Source PluginSourceData
UpdateStrategy string
Version string
Build int
UpdateDelay string
Port int32
InstanceSelector metav1.LabelSelector
}
PluginCreateData contains data for creating a plugin.
type PluginData ¶
type PluginData struct {
Name string
Namespace string
SourceType string
Project string
URL string
UpdateStrategy string
Version string
Build *int
UpdateDelay *time.Duration
ResolvedVersion string
MatchedServers int
RepositoryStatus string
LastFetched *time.Time
AvailableVersions []PluginVersionData
MatchedInstances []MatchedInstanceData
}
PluginData represents plugin information for API/UI consumption.
type PluginService ¶
type PluginService struct {
// contains filtered or unexported fields
}
PluginService provides operations for Plugin resources.
func NewPluginService ¶
func NewPluginService(c client.Client) *PluginService
NewPluginService creates a new PluginService.
func (*PluginService) CreatePlugin ¶
func (s *PluginService) CreatePlugin(ctx context.Context, data PluginCreateData) error
CreatePlugin creates a new plugin from the provided data.
func (*PluginService) DeletePlugin ¶
func (s *PluginService) DeletePlugin(ctx context.Context, namespace, name string) error
DeletePlugin deletes a plugin.
func (*PluginService) GetPlugin ¶
func (s *PluginService) GetPlugin(ctx context.Context, namespace, name string) (*PluginData, error)
GetPlugin returns a specific plugin by namespace and name.
func (*PluginService) GetPluginNamespaces ¶
func (s *PluginService) GetPluginNamespaces(ctx context.Context) ([]string, error)
GetPluginNamespaces returns unique namespaces that have plugins.
func (*PluginService) ListPlugins ¶
func (s *PluginService) ListPlugins(ctx context.Context, namespace string) ([]PluginData, error)
ListPlugins returns all plugins, optionally filtered by namespace.
func (*PluginService) TriggerReconciliation ¶
func (s *PluginService) TriggerReconciliation(ctx context.Context, namespace, name string) error
TriggerReconciliation sets the reconcile annotation to trigger reconciliation.
func (*PluginService) UpdatePlugin ¶
func (s *PluginService) UpdatePlugin(ctx context.Context, data PluginUpdateData) error
UpdatePlugin updates an existing Plugin with the provided data.
type PluginSourceData ¶
PluginSourceData contains plugin source information.
type PluginUpdateData ¶
type PluginUpdateData struct {
Namespace string
Name string
UpdateStrategy *string
Version *string
Build *int
UpdateDelay *string
Port *int32
InstanceSelector *metav1.LabelSelector
}
PluginUpdateData contains data for updating an existing plugin.
type PluginVersionData ¶
type PluginVersionData struct {
Version string
SupportedVersions []string
DownloadURL string
ReleasedAt time.Time
}
PluginVersionData represents a cached plugin version.
type ServerCreateData ¶
type ServerCreateData struct {
Name string
Namespace string
UpdateStrategy string
Version string
Build int
UpdateDelay string
CheckCron string
MaintenanceEnabled bool
MaintenanceCron string
Labels map[string]string
}
ServerCreateData contains data for creating a new server.
type ServerData ¶
type ServerData struct {
Name string
Namespace string
CurrentVersion string
CurrentBuild int
DesiredVersion string
DesiredBuild int
UpdateStrategy string
Status string
PluginCount int
AvailableUpdate *AvailableUpdateData
NextMaintenance string
Labels map[string]string
Plugins []ServerPluginData
MaintenanceSchedule *MaintenanceScheduleData
UpdateHistory *UpdateHistoryData
}
ServerData represents server information for API/UI consumption.
type ServerPluginData ¶
type ServerPluginData struct {
Name string
Namespace string
ResolvedVersion string
CurrentVersion string
DesiredVersion string
Compatible bool
SourceType string
Project string
}
ServerPluginData represents plugin status on a server.
type ServerService ¶
type ServerService struct {
// contains filtered or unexported fields
}
ServerService provides operations for PaperMCServer resources.
func NewServerService ¶
func NewServerService(c client.Client) *ServerService
NewServerService creates a new ServerService.
func (*ServerService) ApplyNow ¶
func (s *ServerService) ApplyNow(ctx context.Context, namespace, name string) error
ApplyNow sets the apply-now annotation to trigger immediate update.
func (*ServerService) CheckStatefulSetStatus ¶
func (s *ServerService) CheckStatefulSetStatus(ctx context.Context, name, namespace string) string
CheckStatefulSetStatus checks the actual StatefulSet status in real-time.
func (*ServerService) CreateServer ¶
func (s *ServerService) CreateServer(ctx context.Context, data ServerCreateData) error
CreateServer creates a new PaperMCServer from the provided data.
func (*ServerService) DeleteServer ¶
func (s *ServerService) DeleteServer(ctx context.Context, namespace, name string) error
DeleteServer deletes a server.
func (*ServerService) DetermineStatus ¶
func (s *ServerService) DetermineStatus(server *mck8slexlav1beta1.PaperMCServer) string
DetermineStatus determines the display status of a server.
func (*ServerService) GetServer ¶
func (s *ServerService) GetServer(ctx context.Context, namespace, name string) (*ServerData, error)
GetServer returns a specific server by namespace and name.
func (*ServerService) GetServerByName ¶
func (s *ServerService) GetServerByName(ctx context.Context, name string) (*ServerData, error)
GetServerByName finds a server by name across all namespaces.
func (*ServerService) GetServerNamespaces ¶
func (s *ServerService) GetServerNamespaces(ctx context.Context) ([]string, error)
GetServerNamespaces returns unique namespaces that have servers.
func (*ServerService) ListServers ¶
func (s *ServerService) ListServers(ctx context.Context, namespace string) ([]ServerData, error)
ListServers returns all servers, optionally filtered by namespace.
func (*ServerService) TriggerReconciliation ¶
func (s *ServerService) TriggerReconciliation(ctx context.Context, namespace, name string) error
TriggerReconciliation sets the reconcile annotation to trigger reconciliation.
func (*ServerService) UpdateServer ¶
func (s *ServerService) UpdateServer(ctx context.Context, data ServerUpdateData) error
UpdateServer updates an existing PaperMCServer with the provided data.
type ServerUpdateData ¶
type ServerUpdateData struct {
Namespace string
Name string
UpdateStrategy *string
Version *string
Build *int
UpdateDelay *string
CheckCron *string
MaintenanceEnabled *bool
MaintenanceCron *string
Labels *map[string]string
}
ServerUpdateData contains data for updating an existing server.