service_repo

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateServiceInput

type CreateServiceInput struct {
	KubernetesName       string
	Name                 string
	ServiceType          schema.ServiceType
	Description          string
	EnvironmentID        uuid.UUID
	GitHubInstallationID *int64
	GitRepository        *string
	GitRepositoryOwner   *string
	KubernetesSecret     string
	Database             *string
	DatabaseVersion      *string
	TemplateID           *uuid.UUID
	TemplateInstanceID   *uuid.UUID
	ServiceGroupID       *uuid.UUID
	DetectedPorts        []schema.PortSpec // This is used to store detected ports, not for creation
}

type MutateConfigInput

type MutateConfigInput struct {
	ServiceID                     uuid.UUID
	Builder                       *schema.ServiceBuilder
	Provider                      *enum.Provider
	Framework                     *enum.Framework
	GitBranch                     *string
	GitTag                        *string
	Icon                          *string
	OverwritePorts                []schema.PortSpec
	AddPorts                      []schema.PortSpec
	RemovePorts                   []schema.PortSpec
	OverwriteHosts                []schema.HostSpec
	AddHosts                      []schema.HostSpec
	RemoveHosts                   []schema.HostSpec
	Replicas                      *int32
	AutoDeploy                    *bool
	RailpackBuilderInstallCommand *string
	RailpackBuilderBuildCommand   *string
	RunCommand                    *string
	Public                        *bool
	Image                         *string
	DockerBuilderDockerfilePath   *string
	DockerBuilderBuildContext     *string
	CustomDefinitionVersion       *string
	DatabaseConfig                *schema.DatabaseConfig
	S3BackupSourceID              *uuid.UUID
	S3BackupBucket                *string
	BackupSchedule                *string
	BackupRetentionCount          *int
	SecurityContext               *schema.SecurityContext
	HealthCheck                   *schema.HealthCheck
	OverwriteVariableMounts       []*schema.VariableMount
	AddVariableMounts             []*schema.VariableMount
	RemoveVariableMounts          []*schema.VariableMount
	ProtectedVariables            *[]string
	OverwriteVolumes              []schema.ServiceVolume
	AddVolumes                    []schema.ServiceVolume
	RemoveVolumes                 []schema.ServiceVolume
	InitContainers                []*schema.InitContainer
	Resources                     *schema.Resources
}

Create the service config

type NeedsDeploymentResponse

type NeedsDeploymentResponse string

See if a service needs a new deployment

const (
	NeedsBuildAndDeployment NeedsDeploymentResponse = "needs_build_and_deployment"
	NeedsDeployment         NeedsDeploymentResponse = "needs_deployment"
	NoDeploymentNeeded      NeedsDeploymentResponse = "no_deployment_needed"
)

type ServiceRepository

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

ServiceRepository handles service database operations

func NewServiceRepository

func NewServiceRepository(db *ent.Client, deploymentRepo deployment_repo.DeploymentRepositoryInterface) *ServiceRepository

NewServiceRepository creates a new repository

func (*ServiceRepository) CountDomainCollisons

func (self *ServiceRepository) CountDomainCollisons(ctx context.Context, tx repository.TxInterface, domain string) (int, error)

func (*ServiceRepository) Create

Create the service

func (*ServiceRepository) CreateConfig

func (self *ServiceRepository) CreateConfig(
	ctx context.Context,
	tx repository.TxInterface,
	input *MutateConfigInput,
) (*ent.ServiceConfig, error)

func (*ServiceRepository) Delete

func (self *ServiceRepository) Delete(ctx context.Context, tx repository.TxInterface, serviceID uuid.UUID) error

func (*ServiceRepository) GetByEnvironmentID

func (self *ServiceRepository) GetByEnvironmentID(ctx context.Context, environmentID uuid.UUID, authPredicate predicate.Service, withLatestDeployment bool) ([]*ent.Service, error)

func (*ServiceRepository) GetByID

func (self *ServiceRepository) GetByID(ctx context.Context, serviceID uuid.UUID) (svc *ent.Service, err error)

func (*ServiceRepository) GetByIDsAndEnvironment

func (self *ServiceRepository) GetByIDsAndEnvironment(ctx context.Context, serviceIDs []uuid.UUID, environmentID uuid.UUID) ([]*ent.Service, error)

func (*ServiceRepository) GetByInstallationIDAndRepoName

func (self *ServiceRepository) GetByInstallationIDAndRepoName(ctx context.Context, installationID int64, repoName string) ([]*ent.Service, error)

func (*ServiceRepository) GetByName

func (self *ServiceRepository) GetByName(ctx context.Context, name string) (*ent.Service, error)

func (*ServiceRepository) GetDatabaseConfig

func (self *ServiceRepository) GetDatabaseConfig(ctx context.Context, serviceID uuid.UUID) (*schema.DatabaseConfig, error)

Get database config for a service

func (*ServiceRepository) GetDatabaseType

func (self *ServiceRepository) GetDatabaseType(ctx context.Context, serviceID uuid.UUID) (string, error)

func (*ServiceRepository) GetDatabases

func (self *ServiceRepository) GetDatabases(ctx context.Context) ([]*ent.Service, error)

func (*ServiceRepository) GetDeploymentNamespace

func (self *ServiceRepository) GetDeploymentNamespace(ctx context.Context, serviceID uuid.UUID) (string, error)

func (*ServiceRepository) GetGithubPrivateKey

func (self *ServiceRepository) GetGithubPrivateKey(ctx context.Context, serviceID uuid.UUID) (string, error)

func (*ServiceRepository) GetPVCMountPaths

func (self *ServiceRepository) GetPVCMountPaths(ctx context.Context, pvcs []*models.PVCInfo) (map[string]string, error)

Get PVC mount paths by IDs

func (*ServiceRepository) GetServicesUsingPVC

func (self *ServiceRepository) GetServicesUsingPVC(ctx context.Context, pvcID string) ([]*ent.Service, error)

Get services using a PVC

func (*ServiceRepository) IsVolumeInUse

func (self *ServiceRepository) IsVolumeInUse(ctx context.Context, volumeName string) (bool, error)

See if volume is in use

func (*ServiceRepository) NeedsDeployment

func (self *ServiceRepository) NeedsDeployment(ctx context.Context, service *ent.Service) (NeedsDeploymentResponse, error)

func (*ServiceRepository) SetCurrentDeployment

func (self *ServiceRepository) SetCurrentDeployment(ctx context.Context, tx repository.TxInterface, serviceID uuid.UUID, deploymentID uuid.UUID) error

func (*ServiceRepository) SummarizeServices

func (self *ServiceRepository) SummarizeServices(ctx context.Context, environmentIDs []uuid.UUID) (counts map[uuid.UUID]int, icons map[uuid.UUID][]string, err error)

Summarize services in environment

func (*ServiceRepository) Update

func (self *ServiceRepository) Update(
	ctx context.Context,
	tx repository.TxInterface,
	serviceID uuid.UUID,
	name *string,
	description *string,
) error

Update the service

func (*ServiceRepository) UpdateConfig

func (self *ServiceRepository) UpdateConfig(
	ctx context.Context,
	tx repository.TxInterface,
	existingConfig *ent.ServiceConfig,
	input *MutateConfigInput,
) error

Update service config

func (*ServiceRepository) UpdateDatabaseStorageSize

func (self *ServiceRepository) UpdateDatabaseStorageSize(
	ctx context.Context,
	tx repository.TxInterface,
	serviceID uuid.UUID,
	newSize string,
) (*schema.DatabaseConfig, error)

func (*ServiceRepository) UpdateVariableMounts

func (self *ServiceRepository) UpdateVariableMounts(ctx context.Context, tx repository.TxInterface, serviceID uuid.UUID, variableMounts []*schema.VariableMount) error

type ServiceRepositoryInterface

type ServiceRepositoryInterface interface {
	// Create the service
	Create(ctx context.Context, tx repository.TxInterface, input *CreateServiceInput) (*ent.Service, error)
	CreateConfig(ctx context.Context, tx repository.TxInterface, input *MutateConfigInput) (*ent.ServiceConfig, error)
	// Update the service
	Update(ctx context.Context, tx repository.TxInterface, serviceID uuid.UUID, name *string, description *string) error
	// Update service config
	UpdateConfig(ctx context.Context, tx repository.TxInterface, existingConfig *ent.ServiceConfig, input *MutateConfigInput) error
	Delete(ctx context.Context, tx repository.TxInterface, serviceID uuid.UUID) error
	SetCurrentDeployment(ctx context.Context, tx repository.TxInterface, serviceID uuid.UUID, deploymentID uuid.UUID) error
	UpdateVariableMounts(ctx context.Context, tx repository.TxInterface, serviceID uuid.UUID, variableMounts []*schema.VariableMount) error
	UpdateDatabaseStorageSize(ctx context.Context, tx repository.TxInterface, serviceID uuid.UUID, newSize string) (*schema.DatabaseConfig, error)
	GetByID(ctx context.Context, serviceID uuid.UUID) (svc *ent.Service, err error)
	GetByIDsAndEnvironment(ctx context.Context, serviceIDs []uuid.UUID, environmentID uuid.UUID) ([]*ent.Service, error)
	GetByName(ctx context.Context, name string) (*ent.Service, error)
	GetDatabaseType(ctx context.Context, serviceID uuid.UUID) (string, error)
	GetDatabases(ctx context.Context) ([]*ent.Service, error)
	GetByInstallationIDAndRepoName(ctx context.Context, installationID int64, repoName string) ([]*ent.Service, error)
	GetByEnvironmentID(ctx context.Context, environmentID uuid.UUID, authPredicate predicate.Service, withLatestDeployment bool) ([]*ent.Service, error)
	GetGithubPrivateKey(ctx context.Context, serviceID uuid.UUID) (string, error)
	CountDomainCollisons(ctx context.Context, tx repository.TxInterface, domain string) (int, error)
	GetDeploymentNamespace(ctx context.Context, serviceID uuid.UUID) (string, error)
	// Summarize services in environment
	SummarizeServices(ctx context.Context, environmentIDs []uuid.UUID) (counts map[uuid.UUID]int, icons map[uuid.UUID][]string, err error)
	NeedsDeployment(ctx context.Context, service *ent.Service) (NeedsDeploymentResponse, error)
	// See if volume is in use
	IsVolumeInUse(ctx context.Context, volumeName string) (bool, error)
	// Get services using a PVC
	GetServicesUsingPVC(ctx context.Context, pvcID string) ([]*ent.Service, error)
	// Get PVC mount paths by IDs
	GetPVCMountPaths(ctx context.Context, pvcs []*models.PVCInfo) (map[string]string, error)
	// Get database config for a service
	GetDatabaseConfig(ctx context.Context, serviceID uuid.UUID) (*schema.DatabaseConfig, error)
}

ServiceRepositoryInterface ...

Jump to

Keyboard shortcuts

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