Documentation ¶
Index ¶
Constants ¶
const ( CycloneServer = "CYCLONE_SERVER" ConsoleWebEndpoint = "CONSOLE_WEB_ENDPOINT" // CallbackURL ... CallbackURL = "CALLBACK_URL" // Registry RegistryLocation = "REGISTRY_LOCATION" RegistryUsername = "REGISTRY_USERNAME" RegistryPassword = "REGISTRY_PASSWORD" WorkerImage = "WORKER_IMAGE" // Github GithubClient = "GITHUB_CLIENT" GithubSecret = "GITHUB_SECRET" //Gitlab GitlabURL = "GITLAB_URL" GitlabClient = "GITLAB_CLIENT" GitlabSecret = "GITLAB_SECRET" // Resource LimitMemory = "LIMIT_MEMORY" LimitCPU = "LIMIT_CPU" RequestMemory = "REQUEST_MEMORY" RequestCPU = "REQUEST_CPU" WorkingDir = "/root/code" // EventID for worker to get the event. EventID = "EVENT_ID" DockerHost = "DOCKER_HOST" // WorkerTimeout ... WorkerTimeout = 2 * time.Hour )
const ( // ResourceCPU in cores. (500m = .5 cores) ResourceCPU = "cpu" // ResourceMemory in bytes. (500Gi = 500GiB = 500 * 1024 * 1024 * 1024) ResourceMemory = "memory" // ResourceRequestsCPU CPU request, in cores. (500m = .5 cores) ResourceRequestsCPU = "requests.cpu" // ResourceRequestsMemory Memory request, in bytes. (500Gi = 500GiB = 500 * 1024 * 1024 * 1024) ResourceRequestsMemory = "requests.memory" // ResourceLimitsCPU CPU limit, in cores. (500m = .5 cores) ResourceLimitsCPU = "limits.cpu" // ResourceLimitsMemory Memory limit, in bytes. (500Gi = 500GiB = 500 * 1024 * 1024 * 1024) ResourceLimitsMemory = "limits.memory" )
Variables ¶
var ( // ZeroQuantity ... ZeroQuantity = NewDecimalQuantity(0) // ZeroQuota ... ZeroQuota = Quota{ ResourceLimitsCPU: ZeroQuantity, ResourceLimitsMemory: ZeroQuantity, } // DefaultLimitCPU 1000m = 1 core = 1000 * 100 * 100 DefaultLimitCPU = MustParseCPU(1) // DefaultLimitMemory 1G = 1024MiB = 1024 * 1024 * 1024 DefaultLimitMemory = NewBinaryQuantity(1024 * 1024 * 1024) // DefaultRequestCPU 500m = 0.5 core = 500 * 100 * 100 DefaultRequestCPU = MustParseCPU(0.5) // DefaultRequestMemory 500Mi = 500MiB = 500 * 1024 * 1024 DefaultRequestMemory = NewBinaryQuantity(500 * 1024 * 1024) // DefaultQuota ... DefaultQuota = Quota{ ResourceLimitsCPU: DefaultLimitCPU, ResourceLimitsMemory: DefaultLimitMemory, ResourceRequestsCPU: DefaultRequestCPU, ResourceRequestsMemory: DefaultRequestMemory, } )
Functions ¶
Types ¶
type Quantity ¶
Quantity warps resource.Quantity to implement cli.Generic interface
func MustParseCPU ¶
MustParseCPU turns the given float(in cores, such as 1.5 cores) into a quantity or panics; for tests or others cases where you know the value is valid.
func MustParseMemory ¶
MustParseMemory turns the given float(in Bytes, such as 500*1024*1024 bytes) into a quantity or panics; for tests or others cases where you know the value is valid.
func NewBinaryQuantity ¶
NewBinaryQuantity creates a new Quantity with resource.BinarySI Format
func NewDecimalQuantity ¶
NewDecimalQuantity creates a new Quantity with resource.DecimalSI Format
func NewQuantity ¶
NewQuantity creates a new Quantity
func NewQuantityFor ¶
NewQuantityFor reates a new Quantity from resource.Quantity
func (Quantity) DeepCopy ¶
DeepCopy returns a deep-copy of the Quantity value. Note that the method receiver is a value, so we can mutate it in-place and return it.
type Quota ¶
Quota ...
func (Quota) ToDockerQuota ¶
ToDockerQuota converts Quota to docker resource quota type
func (Quota) ToK8SQuota ¶
func (q Quota) ToK8SQuota() apiv1.ResourceRequirements
ToK8SQuota converts Quota to k8s resource quota type
type Resource ¶
type Resource struct { Limit Quota `json:"limit,omitempty" bson:"limit,omitempty"` Used Quota `json:"used,omitempty" bson:"used,omitempty"` }
Resource describes cloud resource include limit and used quota
type WorkerOptions ¶
type WorkerOptions struct { // for worker env CycloneServer string ConsoleWebEndpoint string // Registry RegistryLocation string `json:"registryLocation,omitempty"` RegistryUsername string `json:"registryUsername,omitempty"` RegistryPassword string `json:"registryPassword,omitempty"` // github GithubClient string GithubSecret string // gitlab GitlabURL string GitlabClient string GitlabSecret string WorkerImage string EventID string ProjectName string PipelineName string DockerHost string Quota Quota }
WorkerOptions ...
func NewWorkerOptions ¶
func NewWorkerOptions() *WorkerOptions
NewWorkerOptions creates a new WorkerOptions
func (*WorkerOptions) AddFlags ¶
func (opts *WorkerOptions) AddFlags(app *cli.App)
AddFlags adds flags to app.Flags