server

package
v0.0.0-...-8d3f935 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDedicatedServerDeployment

func CreateDedicatedServerDeployment(world *model.WorldDetails, kubeService service.KubernetesService, user *model.User) (*model.Server, error)

CreateDedicatedServerDeployment Creates the valheim dedicated src deployment and pvc given the src configuration.

func MakePvc

func MakePvc(name string, deploymentName string, discordId string) *corev1.PersistentVolumeClaim

MakePvc Returns the PVC object from the Kubernetes API for creating a new volume.

func MakeWorldWithDefaults

func MakeWorldWithDefaults(options *CreateServerRequest) *model.WorldDetails

MakeWorldWithDefaults creates a new struct holding WorldDetails like name, port, backup count etc... with default values that can be selectively overridden by provided options

func PatchServerDeployment

func PatchServerDeployment(world *model.WorldDetails, kubeService service.KubernetesService, user *model.User) error

PatchServerDeployment Updates a src deployment with new container args.

func UpdateServerArgs

func UpdateServerArgs(kubeService service.KubernetesService, deploymentName string, server *model.Server) error

UpdateServerArgs Update's a deployment's args to reflect what is in Cognito. This avoids complex argument merging logic by simply having the frontend update cognito with the new src args.

Types

type CreateServerHandler

type CreateServerHandler struct{}

func (*CreateServerHandler) HandleRequest

func (h *CreateServerHandler) HandleRequest(c *gin.Context, ctx context.Context, w *service.Wrapper)

HandleRequest Handles the /api/v1/src/create to create a new Valheim dedicated src container. This route is responsible for creating the initial deployment and pvc which in turn creates the replicaset and pod for the src. Future src management like mod installation, user termination requests, custom world uploads, etc... will use the /api/v1/src/scale route to scale the replicas to 0-1 without removing the deployment or PVC.

type CreateServerRequest

type CreateServerRequest struct {
	Name                  *string          `json:"name"`
	World                 *string          `json:"world"`
	MemoryRequest         *int             `json:"memory_request"`
	CpuRequest            *int             `json:"cpu_request"`
	Password              *string          `json:"password"`
	Port                  *string          `json:"port"`
	EnableCrossplay       *bool            `json:"enable_crossplay,omitempty"`
	Public                *bool            `json:"public,omitempty"`
	Modifiers             []model.Modifier `json:"modifiers,omitempty"`
	SaveIntervalSeconds   *int             `json:"save_interval_seconds,omitempty"`
	BackupCount           *int             `json:"backup_count,omitempty"`
	InitialBackupSeconds  *int             `json:"initial_backup_seconds,omitempty"`
	BackupIntervalSeconds *int             `json:"backup_interval_seconds,omitempty"`
}

func (*CreateServerRequest) Validate

func (c *CreateServerRequest) Validate() error

type DeleteServerHandler

type DeleteServerHandler struct{}

func (*DeleteServerHandler) HandleRequest

func (d *DeleteServerHandler) HandleRequest(c *gin.Context, w *service.Wrapper)

type GetServerHandler

type GetServerHandler struct{}

func (*GetServerHandler) HandleRequest

func (g *GetServerHandler) HandleRequest(c *gin.Context, db *gorm.DB)

type PatchServerHandler

type PatchServerHandler struct{}

func (*PatchServerHandler) HandleRequest

func (p *PatchServerHandler) HandleRequest(c *gin.Context, ctx context.Context, w *service.Wrapper)

HandleRequest Much of this logic overlaps with the /create endpoint. It uses the same request body, validation logic, and method structure. The primary difference is in how it patches the container run args for a deployment rather than creating a new one.

type ScaleServerHandler

type ScaleServerHandler struct{}

func (*ScaleServerHandler) HandleRequest

func (h *ScaleServerHandler) HandleRequest(c *gin.Context, w *service.Wrapper)

type ScaleServerRequest

type ScaleServerRequest struct {
	Replicas *int32 `json:"replicas"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳