services

package
v0.53.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTargetAlreadyExists = errors.New("target already exists")
	ErrInvalidTargetName   = errors.New("name is not a valid alphanumeric string")
	ErrTargetDeleted       = errors.New("target is deleted")
	ErrAgentlessTarget     = errors.New("provider uses an agentless target")
)
View Source
var (
	ErrWorkspaceAlreadyExists   = errors.New("workspace already exists")
	ErrWorkspaceDeleted         = errors.New("workspace is deleted")
	ErrInvalidWorkspaceName     = errors.New("workspace name is not valid. Only [a-zA-Z0-9-_.] are allowed")
	ErrInvalidWorkspaceTemplate = errors.New("workspace template is invalid")
)
View Source
var (
	ErrBuildDeleted = errors.New("build is deleted")
)
View Source
var (
	ErrInvalidResourceJobAction = errors.New("invalid job action for resource")
)
View Source
var (
	ErrRunnerAlreadyExists = errors.New("runner already exists")
)

Functions

func IsBuildDeleted

func IsBuildDeleted(err error) bool

func IsInvalidResourceJobAction

func IsInvalidResourceJobAction(err error) bool

func IsTargetDeleted

func IsTargetDeleted(err error) bool

func IsWorkspaceDeleted

func IsWorkspaceDeleted(err error) bool

Types

type ApiKeyDTO

type ApiKeyDTO struct {
	Type models.ApiKeyType `json:"type" validate:"required"`
	Name string            `json:"name" validate:"required"`

} // @name	ApiKeyDTO

type BuildDTO

type BuildDTO struct {
	models.Build
	State models.ResourceState `json:"state" validate:"required"`

} //	@name	BuildDTO

type BuildFilter

type BuildFilter struct {
	StateNames  *[]models.ResourceStateName
	ShowDeleted bool
	StoreFilter stores.BuildFilter
}

type CreateBuildDTO

type CreateBuildDTO struct {
	WorkspaceTemplateName string            `json:"workspaceTemplateName" validate:"required"`
	Branch                string            `json:"branch" validate:"required"`
	PrebuildId            *string           `json:"prebuildId" validate:"optional"`
	EnvVars               map[string]string `json:"envVars" validate:"required"`

} // @name CreateBuildDTO

type CreatePrebuildDTO

type CreatePrebuildDTO struct {
	Id             *string  `json:"id" validate:"optional"`
	Branch         string   `json:"branch" validate:"optional"`
	CommitInterval *int     `json:"commitInterval" validate:"optional"`
	TriggerFiles   []string `json:"triggerFiles" validate:"optional"`
	Retention      int      `json:"retention" validate:"required"`

} // @name CreatePrebuildDTO

type CreateRunnerDTO

type CreateRunnerDTO struct {
	Id   string `json:"id" validate:"required"`
	Name string `json:"name" validate:"required"`

} // @name CreateRunnerDTO

type CreateRunnerResultDTO

type CreateRunnerResultDTO struct {
	models.Runner
	ApiKey string `json:"apiKey" validate:"required"`

} // @name CreateRunnerResultDTO

type CreateTargetConfigDTO

type CreateTargetConfigDTO struct {
	Name         string              `json:"name" validate:"required"`
	ProviderInfo models.ProviderInfo `json:"providerInfo" validate:"required"`
	Options      string              `json:"options" validate:"required"`

} // @name CreateTargetConfigDTO

type CreateTargetDTO

type CreateTargetDTO struct {
	Id             string `json:"id" validate:"required"`
	Name           string `json:"name" validate:"required"`
	TargetConfigId string `json:"targetConfigId" validate:"required"`

} //	@name	CreateTargetDTO

type CreateWorkspaceDTO

type CreateWorkspaceDTO struct {
	Id                  string                   `json:"id" validate:"required"`
	Name                string                   `json:"name" validate:"required"`
	Image               *string                  `json:"image,omitempty" validate:"optional"`
	User                *string                  `json:"user,omitempty" validate:"optional"`
	BuildConfig         *models.BuildConfig      `json:"buildConfig,omitempty" validate:"optional"`
	Source              CreateWorkspaceSourceDTO `json:"source" validate:"required"`
	EnvVars             map[string]string        `json:"envVars" validate:"required"`
	Labels              map[string]string        `json:"labels" validate:"required"`
	TargetId            string                   `json:"targetId" validate:"required"`
	GitProviderConfigId *string                  `json:"gitProviderConfigId,omitempty" validate:"optional"`

} //	@name	CreateWorkspaceDTO

func (*CreateWorkspaceDTO) ToWorkspace

func (c *CreateWorkspaceDTO) ToWorkspace() *models.Workspace

type CreateWorkspaceSourceDTO

type CreateWorkspaceSourceDTO struct {
	Repository *gitprovider.GitRepository `json:"repository" validate:"required"`

} // @name CreateWorkspaceSourceDTO

type CreateWorkspaceTemplateDTO

type CreateWorkspaceTemplateDTO struct {
	Name                string              `json:"name" validate:"required"`
	Image               *string             `json:"image,omitempty" validate:"optional"`
	User                *string             `json:"user,omitempty" validate:"optional"`
	BuildConfig         *models.BuildConfig `json:"buildConfig,omitempty" validate:"optional"`
	RepositoryUrl       string              `json:"repositoryUrl" validate:"required"`
	EnvVars             map[string]string   `json:"envVars" validate:"required"`
	GitProviderConfigId *string             `json:"gitProviderConfigId" validate:"optional"`

} // @name CreateWorkspaceTemplateDTO

type DownloadUrls

type DownloadUrls map[os.OperatingSystem]string

type EnvironmentVariables

type EnvironmentVariables map[string]string

func (EnvironmentVariables) FindContainerRegistry

func (e EnvironmentVariables) FindContainerRegistry(server string) *models.ContainerRegistry

func (EnvironmentVariables) FindContainerRegistryByImageName

func (e EnvironmentVariables) FindContainerRegistryByImageName(image string) *models.ContainerRegistry

type IApiKeyService

type IApiKeyService interface {
	ListClientKeys(ctx context.Context) ([]*ApiKeyDTO, error)
	Create(ctx context.Context, keyType models.ApiKeyType, name string) (string, error)
	Delete(ctx context.Context, name string) error

	GetApiKeyType(ctx context.Context, apiKey string) (models.ApiKeyType, error)
	GetApiKeyName(ctx context.Context, apiKey string) (string, error)
	IsValidApiKey(ctx context.Context, apiKey string) bool
}

type IBuildService

type IBuildService interface {
	List(ctx context.Context, filter *BuildFilter) ([]*BuildDTO, error)
	Find(ctx context.Context, filter *BuildFilter) (*BuildDTO, error)
	Create(ctx context.Context, createBuildDTO CreateBuildDTO) (string, error)
	Delete(ctx context.Context, filter *BuildFilter, force bool) []error

	UpdateLastJob(ctx context.Context, buildId, jobId string) error
	HandleSuccessfulRemoval(ctx context.Context, id string) error
	GetBuildLogReader(ctx context.Context, buildId string) (io.Reader, error)
	GetBuildLogWriter(ctx context.Context, buildId string) (io.WriteCloser, error)
}

type IEnvironmentVariableService

type IEnvironmentVariableService interface {
	List(ctx context.Context) ([]*models.EnvironmentVariable, error)
	Map(ctx context.Context) (EnvironmentVariables, error)
	Save(ctx context.Context, environmentVariable *models.EnvironmentVariable) error
	Delete(ctx context.Context, key string) error
}

type IGitProviderService

type IGitProviderService interface {
	ListConfigs(ctx context.Context) ([]*models.GitProviderConfig, error)
	ListConfigsForUrl(ctx context.Context, url string) ([]*models.GitProviderConfig, error)
	FindConfig(ctx context.Context, id string) (*models.GitProviderConfig, error)
	SaveConfig(ctx context.Context, providerConfig *models.GitProviderConfig) error
	DeleteConfig(ctx context.Context, id string) error

	GetGitProvider(ctx context.Context, id string) (gitprovider.GitProvider, error)
	GetGitProviderForUrl(ctx context.Context, url string) (gitprovider.GitProvider, string, error)
	GetGitProviderForHttpRequest(ctx context.Context, req *http.Request) (gitprovider.GitProvider, error)
	GetGitUser(ctx context.Context, gitProviderId string) (*gitprovider.GitUser, error)
	GetNamespaces(ctx context.Context, gitProviderId string, options gitprovider.ListOptions) ([]*gitprovider.GitNamespace, error)
	GetRepoBranches(ctx context.Context, gitProviderId string, namespaceId string, repositoryId string, options gitprovider.ListOptions) ([]*gitprovider.GitBranch, error)
	GetRepoPRs(ctx context.Context, gitProviderId string, namespaceId string, repositoryId string, options gitprovider.ListOptions) ([]*gitprovider.GitPullRequest, error)
	GetRepositories(ctx context.Context, gitProviderId string, namespaceId string, options gitprovider.ListOptions) ([]*gitprovider.GitRepository, error)
	GetLastCommitSha(ctx context.Context, repo *gitprovider.GitRepository) (string, error)

	RegisterPrebuildWebhook(ctx context.Context, gitProviderId string, repo *gitprovider.GitRepository, endpointUrl string) (string, error)
	GetPrebuildWebhook(ctx context.Context, gitProviderId string, repo *gitprovider.GitRepository, endpointUrl string) (*string, error)
	UnregisterPrebuildWebhook(ctx context.Context, gitProviderId string, repo *gitprovider.GitRepository, id string) error
}

type IJobService

type IJobService interface {
	List(ctx context.Context, filter *stores.JobFilter) ([]*models.Job, error)
	Find(ctx context.Context, filter *stores.JobFilter) (*models.Job, error)
	Create(ctx context.Context, job *models.Job) error
	UpdateState(ctx context.Context, jobId string, updateJobStateDto UpdateJobStateDTO) error
	Delete(ctx context.Context, job *models.Job) error
}

type IRunnerService

type IRunnerService interface {
	List(ctx context.Context) ([]*RunnerDTO, error)
	Find(ctx context.Context, runnerId string) (*RunnerDTO, error)
	Create(ctx context.Context, req CreateRunnerDTO) (*RunnerDTO, error)
	Delete(ctx context.Context, runnerId string) error

	UpdateMetadata(ctx context.Context, runnerId string, metadata *models.RunnerMetadata) error
	UpdateJobState(ctx context.Context, jobId string, req UpdateJobStateDTO) error
	ListRunnerJobs(ctx context.Context, runnerId string) ([]*models.Job, error)

	ListProviders(ctx context.Context, runnerId *string) ([]models.ProviderInfo, error)
	ListProvidersForInstall(ctx context.Context, serverRegistryUrl string) ([]ProviderDTO, error)
	InstallProvider(ctx context.Context, runnerId, name, version, serverRegistryUrl string) error
	UninstallProvider(ctx context.Context, runnerId string, name string) error
	UpdateProvider(ctx context.Context, runnerId, name, version, serverRegistryUrl string) error

	GetRunnerLogReader(ctx context.Context, runnerId string) (io.Reader, error)
	GetRunnerLogWriter(ctx context.Context, runnerId string) (io.WriteCloser, error)
}

type ITargetConfigService

type ITargetConfigService interface {
	List(ctx context.Context) ([]*models.TargetConfig, error)
	Map(ctx context.Context) (map[string]*models.TargetConfig, error)
	Find(ctx context.Context, idOrName string) (*models.TargetConfig, error)
	Create(ctx context.Context, targetConfig CreateTargetConfigDTO) (*models.TargetConfig, error)
	Delete(ctx context.Context, targetConfigId string) error
}

type ITargetService

type ITargetService interface {
	List(ctx context.Context, filter *stores.TargetFilter, params TargetRetrievalParams) ([]TargetDTO, error)
	Find(ctx context.Context, filter *stores.TargetFilter, params TargetRetrievalParams) (*TargetDTO, error)
	Create(ctx context.Context, req CreateTargetDTO) (*models.Target, error)
	Save(ctx context.Context, target *models.Target) error
	Start(ctx context.Context, targetId string) error
	Stop(ctx context.Context, targetId string) error
	Restart(ctx context.Context, targetId string) error
	SetDefault(ctx context.Context, targetId string) error
	Delete(ctx context.Context, targetId string) error
	ForceDelete(ctx context.Context, targetId string) error

	UpdateMetadata(ctx context.Context, targetId string, metadata *models.TargetMetadata) (*models.TargetMetadata, error)
	UpdateProviderMetadata(ctx context.Context, targetId, metadata string) error
	UpdateLastJob(ctx context.Context, targetId, jobId string) error

	HandleSuccessfulCreation(ctx context.Context, targetId string) error
	GetTargetLogReader(ctx context.Context, targetId string) (io.Reader, error)
	GetTargetLogWriter(ctx context.Context, targetId string) (io.WriteCloser, error)
}

type IWorkspaceService

type IWorkspaceService interface {
	List(ctx context.Context, params WorkspaceRetrievalParams) ([]WorkspaceDTO, error)
	Find(ctx context.Context, workspaceId string, params WorkspaceRetrievalParams) (*WorkspaceDTO, error)
	Create(ctx context.Context, req CreateWorkspaceDTO) (*WorkspaceDTO, error)
	Start(ctx context.Context, workspaceId string) error
	Stop(ctx context.Context, workspaceId string) error
	Delete(ctx context.Context, workspaceId string) error
	ForceDelete(ctx context.Context, workspaceId string) error
	Restart(ctx context.Context, workspaceId string) error

	UpdateMetadata(ctx context.Context, workspaceId string, metadata *models.WorkspaceMetadata) (*models.WorkspaceMetadata, error)
	UpdateProviderMetadata(ctx context.Context, workspaceId, metadata string) error
	UpdateLastJob(ctx context.Context, workspaceId, jobId string) error
	UpdateLabels(ctx context.Context, workspaceId string, labels map[string]string) (*WorkspaceDTO, error)

	GetWorkspaceLogReader(ctx context.Context, workspaceId string) (io.Reader, error)
	GetWorkspaceLogWriter(ctx context.Context, workspaceId string) (io.WriteCloser, error)
}

type IWorkspaceTemplateService

type IWorkspaceTemplateService interface {
	List(ctx context.Context, filter *stores.WorkspaceTemplateFilter) ([]*models.WorkspaceTemplate, error)
	Find(ctx context.Context, filter *stores.WorkspaceTemplateFilter) (*models.WorkspaceTemplate, error)
	Save(ctx context.Context, workspaceTemplate *models.WorkspaceTemplate) error
	SetDefault(ctx context.Context, workspaceTemplateName string) error
	Delete(ctx context.Context, workspaceTemplateName string, force bool) []error

	ListPrebuilds(ctx context.Context, workspaceTemplateFilter *stores.WorkspaceTemplateFilter, prebuildFilter *stores.PrebuildFilter) ([]*PrebuildDTO, error)
	FindPrebuild(ctx context.Context, workspaceTemplateFilter *stores.WorkspaceTemplateFilter, prebuildFilter *stores.PrebuildFilter) (*PrebuildDTO, error)
	SavePrebuild(ctx context.Context, workspaceTemplateName string, createPrebuildDto CreatePrebuildDTO) (*PrebuildDTO, error)
	DeletePrebuild(ctx context.Context, workspaceTemplateName string, id string, force bool) []error

	StartRetentionPoller(ctx context.Context) error
	EnforceRetentionPolicy(ctx context.Context) error
	ProcessGitEvent(ctx context.Context, gitEventData gitprovider.GitEventData) error
}

type PrebuildDTO

type PrebuildDTO struct {
	Id                    string   `json:"id" validate:"required"`
	WorkspaceTemplateName string   `json:"workspaceTemplateName" validate:"required"`
	Branch                string   `json:"branch" validate:"required"`
	CommitInterval        *int     `json:"commitInterval" validate:"optional"`
	TriggerFiles          []string `json:"triggerFiles" validate:"optional"`
	Retention             int      `json:"retention" validate:"required"`

} // @name PrebuildDTO

type ProviderDTO

type ProviderDTO struct {
	Name    string  `json:"name" validate:"required"`
	Label   *string `json:"label" validate:"optional"`
	Version string  `json:"version" validate:"required"`
	Latest  bool    `json:"latest" validate:"required"`

} // @name ProviderDTO

type ProviderMetadata

type ProviderMetadata struct {
	Name         string       `json:"name" validate:"required"`
	Version      string       `json:"version" validate:"required"`
	DownloadUrls DownloadUrls `json:"downloadUrls" validate:"required"`
}

type RunnerDTO

type RunnerDTO struct {
	models.Runner
	State models.ResourceState `json:"state" validate:"required"`

} //	@name	RunnerDTO

type TargetDTO

type TargetDTO struct {
	models.Target
	State models.ResourceState `json:"state" validate:"required"`

} //	@name	TargetDTO

type TargetRetrievalParams

type TargetRetrievalParams struct {
	ShowDeleted bool
}

type UpdateJobStateDTO

type UpdateJobStateDTO struct {
	State        models.JobState `json:"state" validate:"required"`
	ErrorMessage *string         `json:"errorMessage,omitempty" validate:"optional"`

} // @name UpdateJobState

type UpdateTargetProviderMetadataDTO

type UpdateTargetProviderMetadataDTO struct {
	Metadata string `json:"metadata" validate:"required"`

} // @name UpdateTargetProviderMetadataDTO

type WorkspaceDTO

type WorkspaceDTO struct {
	models.Workspace
	State models.ResourceState `json:"state" validate:"required"`

} //	@name	WorkspaceDTO

type WorkspaceRetrievalParams

type WorkspaceRetrievalParams struct {
	ShowDeleted bool
	Labels      map[string]string
}

Jump to

Keyboard shortcuts

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