build

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Overview

Copyright 2024 Daytona Platforms Inc. SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const DEFAULT_POLL_INTERVAL = "*/10 * * * * *"

TODO: add lock when running interval func 10 second interval

Variables

View Source
var (
	ErrBuildNotFound = errors.New("build not found")
)

Functions

func GetBuildLogsDir added in v0.26.0

func GetBuildLogsDir() (string, error)

func GetCachedBuild added in v0.26.0

func GetCachedBuild(build *Build, builds []*Build) *buildconfig.CachedBuild

func GetRunnerConfigDir added in v0.26.0

func GetRunnerConfigDir() (string, error)

func IsBuildNotFound

func IsBuildNotFound(err error) bool

func Save added in v0.25.0

func Save(c Config) error

Types

type Build added in v0.25.0

type Build struct {
	Id              string                          `json:"id" validate:"required"`
	State           BuildState                      `json:"state" validate:"required"`
	Image           *string                         `json:"image" validate:"optional"`
	User            *string                         `json:"user" validate:"optional"`
	ContainerConfig containerconfig.ContainerConfig `json:"containerConfig" validate:"required"`
	BuildConfig     *buildconfig.BuildConfig        `json:"buildConfig" validate:"optional"`
	Repository      *gitprovider.GitRepository      `json:"repository" validate:"required"`
	EnvVars         map[string]string               `json:"envVars" validate:"required"`
	PrebuildId      string                          `json:"prebuildId" validate:"required"`
	CreatedAt       time.Time                       `json:"createdAt" validate:"required"`
	UpdatedAt       time.Time                       `json:"updatedAt" validate:"required"`

} // @name Build

func (*Build) Compare added in v0.26.0

func (b *Build) Compare(other *Build) (bool, error)

func (*Build) GetBuildHash added in v0.26.0

func (b *Build) GetBuildHash() (string, error)

GetBuildHash returns a SHA-256 hash of the build's configuration, repository branch and environment variables.

type BuildOutcome

type BuildOutcome struct {
	Outcome               string `json:"outcome"`
	ContainerId           string `json:"containerId"`
	RemoteUser            string `json:"remoteUser"`
	RemoteWorkspaceFolder string `json:"remoteWorkspaceFolder"`
}

type BuildProcessConfig added in v0.26.0

type BuildProcessConfig struct {
	Builder     IBuilder
	BuildLogger logs.Logger
	Build       *Build
	ProjectDir  string
	GitService  git.IGitService
	Wg          *sync.WaitGroup
}

type BuildRunner added in v0.25.0

type BuildRunner struct {
	Id string
	// contains filtered or unexported fields
}

func NewBuildRunner added in v0.25.0

func NewBuildRunner(config BuildRunnerInstanceConfig) *BuildRunner

func (*BuildRunner) DeleteBuilds added in v0.26.0

func (r *BuildRunner) DeleteBuilds()

func (*BuildRunner) RunBuildProcess added in v0.25.0

func (r *BuildRunner) RunBuildProcess(config BuildProcessConfig)

func (*BuildRunner) RunBuilds added in v0.26.0

func (r *BuildRunner) RunBuilds()

func (*BuildRunner) Start added in v0.25.0

func (r *BuildRunner) Start() error

func (*BuildRunner) Stop added in v0.25.0

func (r *BuildRunner) Stop()

type BuildRunnerInstanceConfig added in v0.25.0

type BuildRunnerInstanceConfig struct {
	Interval          string
	Scheduler         scheduler.IScheduler
	BuildRunnerId     string
	ContainerRegistry *containerregistry.ContainerRegistry
	GitProviderStore  GitProviderStore
	BuildStore        Store
	BuilderFactory    IBuilderFactory
	LoggerFactory     logs.LoggerFactory
	BasePath          string
	TelemetryEnabled  bool
	TelemetryService  telemetry.TelemetryService
}

type BuildState added in v0.25.0

type BuildState string
const (
	BuildStatePendingRun          BuildState = "pending-run"
	BuildStateRunning             BuildState = "running"
	BuildStateError               BuildState = "error"
	BuildStateSuccess             BuildState = "success"
	BuildStatePublished           BuildState = "published"
	BuildStatePendingDelete       BuildState = "pending-delete"
	BuildStatePendingForcedDelete BuildState = "pending-forced-delete"
	BuildStateDeleting            BuildState = "deleting"
)

type Builder

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

func (*Builder) GetImageName added in v0.26.0

func (b *Builder) GetImageName(build Build) (string, error)

type BuilderFactory

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

func (*BuilderFactory) CheckExistingBuild

func (f *BuilderFactory) CheckExistingBuild(b Build) (*Build, error)

func (*BuilderFactory) Create

func (f *BuilderFactory) Create(build Build, projectDir string) (IBuilder, error)

type BuilderFactoryConfig

type BuilderFactoryConfig struct {
	Image               string
	ContainerRegistry   *containerregistry.ContainerRegistry
	BuildStore          Store
	BuildImageNamespace string // Namespace to be used when tagging and pushing the build image
	LoggerFactory       logs.LoggerFactory
	DefaultProjectImage string
	DefaultProjectUser  string
}

type Config added in v0.25.0

type Config struct {
	Id               string `json:"id" validate:"required"`
	Interval         string `json:"interval" validate:"required"`
	TelemetryEnabled bool   `json:"telemetryEnabled" validate:"required"`

} // @name BuildRunnerConfig

func GetConfig added in v0.25.0

func GetConfig() (*Config, error)

type CronScheduler added in v0.25.0

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

CronScheduler is a wrapper around the cron library. It implements the IScheduler interface. It is used to schedule tasks at specific intervals. Wrapping the cron library is necessary to enable proper mocking while testing dependent code.

func NewCronScheduler added in v0.25.0

func NewCronScheduler() *CronScheduler

func (*CronScheduler) AddFunc added in v0.25.0

func (s *CronScheduler) AddFunc(interval string, cmd func()) error

func (*CronScheduler) Start added in v0.25.0

func (s *CronScheduler) Start()

func (*CronScheduler) Stop added in v0.25.0

func (s *CronScheduler) Stop()

type DevcontainerBuilder

type DevcontainerBuilder struct {
	*Builder
	// contains filtered or unexported fields
}

func (*DevcontainerBuilder) Build

func (b *DevcontainerBuilder) Build(build Build) (string, string, error)

func (*DevcontainerBuilder) CleanUp

func (b *DevcontainerBuilder) CleanUp() error

func (*DevcontainerBuilder) Publish

func (b *DevcontainerBuilder) Publish(build Build) error

type Filter added in v0.26.0

type Filter struct {
	Id            *string
	States        *[]BuildState
	PrebuildIds   *[]string
	GetNewest     *bool
	BuildConfig   *buildconfig.BuildConfig
	RepositoryUrl *string
	Branch        *string
	EnvVars       *map[string]string
}

func (*Filter) PrebuildIdsToInterface added in v0.26.0

func (f *Filter) PrebuildIdsToInterface() []interface{}

func (*Filter) StatesToInterface added in v0.26.0

func (f *Filter) StatesToInterface() []interface{}

type GitProviderStore added in v0.26.0

type GitProviderStore interface {
	GetConfigForUrl(url string) (*gitprovider.GitProviderConfig, error)
}

type IBuilder

type IBuilder interface {
	Build(build Build) (string, string, error)
	CleanUp() error
	Publish(build Build) error
	GetImageName(build Build) (string, error)
}

type IBuilderFactory

type IBuilderFactory interface {
	Create(build Build, projectDir string) (IBuilder, error)
	CheckExistingBuild(build Build) (*Build, error)
}

func NewBuilderFactory

func NewBuilderFactory(config BuilderFactoryConfig) IBuilderFactory

type Store

type Store interface {
	Find(filter *Filter) (*Build, error)
	List(filter *Filter) ([]*Build, error)
	Save(build *Build) error
	Delete(id string) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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