options

package
v0.8.0-alpha Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
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
)
View Source
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

View Source
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

func BytesSize

func BytesSize(size float64) string

BytesSize returns a human-readable size in bytes, kibibytes, mebibytes, gibibytes, or tebibytes (eg. "44kiB", "17MiB").

func CustomSize

func CustomSize(format string, size float64, base float64, _map []string) string

CustomSize returns a human-readable approximation of a size using custom format.

Types

type Quantity

type Quantity struct {
	resource.Quantity
}

Quantity warps resource.Quantity to implement cli.Generic interface

func MustParseCPU

func MustParseCPU(value float64) *Quantity

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

func MustParseMemory(value float64) *Quantity

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

func NewBinaryQuantity(value int) *Quantity

NewBinaryQuantity creates a new Quantity with resource.BinarySI Format

func NewDecimalQuantity

func NewDecimalQuantity(value int) *Quantity

NewDecimalQuantity creates a new Quantity with resource.DecimalSI Format

func NewQuantity

func NewQuantity(value int64, format resource.Format) *Quantity

NewQuantity creates a new Quantity

func NewQuantityFor

func NewQuantityFor(q resource.Quantity) *Quantity

NewQuantityFor reates a new Quantity from resource.Quantity

func (Quantity) DeepCopy

func (q Quantity) DeepCopy() Quantity

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.

func (*Quantity) Set

func (q *Quantity) Set(value string) error

Set implements cli.Generic interface

func (Quantity) String

func (q Quantity) String() string

type Quota

type Quota map[string]*Quantity

Quota ...

func (Quota) Add

func (q Quota) Add(y Quota)

Add adds the provide y Quota to the current value.

func (Quota) DeepCopy

func (q Quota) DeepCopy() Quota

DeepCopy returns a deep-copy of the Quota value.

func (Quota) Enough

func (q Quota) Enough(y Quota, z Quota) bool

Enough returns true if the Quota is greater than y plus z.

func (Quota) IsZero

func (q Quota) IsZero() bool

IsZero returns true if the all Quantities in Quota are equal to zero.

func (Quota) SetDefault

func (q Quota) SetDefault()

SetDefault fills quota with default quantity

func (Quota) Sub

func (q Quota) Sub(y Quota)

Sub subtracts the provided y Quota from the current value in place.

func (Quota) ToDockerQuota

func (q Quota) ToDockerQuota() container.Resources

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

func NewResource

func NewResource() *Resource

NewResource returns a new Resource

func (*Resource) Add

func (r *Resource) Add(y *Resource)

Add adds the provided Resource y to current Resource

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

Jump to

Keyboard shortcuts

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