generation

package
v1.12.2 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2021 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsScaledInt added in v1.12.1

func AsScaledInt(q resource.Quantity, scale resource.Scale) int32

AsScaledInt scales the quantity to the appropriate scale, honoring the base as determined by the format of the supplied quantity. For example, AsScaledInt(NewQuantity(1, BinarySI), Milli) returns 1024.

func QuantitySuffix added in v1.12.1

func QuantitySuffix(scale resource.Scale, format resource.Format) string

QuantitySuffix returns the suffix for a quantity or an empty string if it is known. Note that although scale is just an int, you should only use the predefined constants (or variables populated from them) when calling.

func SetExperimentLabel

func SetExperimentLabel(key, value string) yaml.Filter

SetExperimentLabel is a filter that sets a label on an experiment object.

func SetExperimentName

func SetExperimentName(name string) yaml.Filter

SetExperimentName sets the name on the experiment. In addition, the experiment name is set as a suffix on any generated cluster roles or cluster role bindings.

func SetNamespace

func SetNamespace(namespace string) yaml.Filter

SetNamespace sets the namespace on a resource (if necessary).

Types

type ApplicationSelector

type ApplicationSelector struct {
	Application *redskyappsv1alpha1.Application
	Scenario    *redskyappsv1alpha1.Scenario
	Objective   *redskyappsv1alpha1.Objective
}

ApplicationSelector is responsible for "scanning" the application definition itself.

func (*ApplicationSelector) Map

func (s *ApplicationSelector) Map(*yaml.RNode, yaml.ResourceMeta) ([]interface{}, error)

Map ignores inputs (it should just be the null node from select) and produces additional markers for transform.

func (*ApplicationSelector) Select

func (s *ApplicationSelector) Select([]*yaml.RNode) ([]*yaml.RNode, error)

Select only returns an empty node to ensure that map will be called.

type BuiltInPrometheus

type BuiltInPrometheus struct {
	SetupTaskName          string
	ClusterRoleName        string
	ServiceAccountName     string
	ClusterRoleBindingName string

	sfio.ObjectSlice
}

func (*BuiltInPrometheus) Update

type ContainerResourcesSelector

type ContainerResourcesSelector struct {
	scan.GenericSelector
	// Regular expression matching the container name.
	ContainerName string `json:"containerName,omitempty"`
	// Path to the resource requirements.
	Path string `json:"path,omitempty"`
	// Names of the resources to select, defaults to ["cpu", "memory"].
	Resources []corev1.ResourceName `json:"resources,omitempty"`
	// Create container resource requirements even if the original object does not contain them.
	CreateIfNotPresent bool `json:"create,omitempty"`
	// Per-namespace limit ranges for containers.
	ContainerLimitRange map[string]corev1.LimitRangeItem `json:"containerLimitRange,omitempty"`
}

ContainerResourcesSelector scans for container resources specifications (requests/limits).

func (*ContainerResourcesSelector) Default added in v1.12.1

func (s *ContainerResourcesSelector) Default()

Default applies default values to the selector.

func (*ContainerResourcesSelector) Map

func (s *ContainerResourcesSelector) Map(node *yaml.RNode, meta yaml.ResourceMeta) ([]interface{}, error)

Map inspects the supplied resource for container resources specifications.

func (*ContainerResourcesSelector) Select added in v1.11.1

func (s *ContainerResourcesSelector) Select(nodes []*yaml.RNode) ([]*yaml.RNode, error)

Select matches all of the generically match nodes plus any `LimitRange` resources that we can use to collect default values from.

type CustomSource

type CustomSource struct {
	Scenario    *redskyappsv1alpha1.Scenario
	Objective   *redskyappsv1alpha1.Objective
	Application *redskyappsv1alpha1.Application
}

func (*CustomSource) Metrics

func (s *CustomSource) Metrics() ([]redskyv1beta1.Metric, error)

func (*CustomSource) Update

func (s *CustomSource) Update(exp *redskyv1beta1.Experiment) error

type DatadogMetricsSource

type DatadogMetricsSource struct {
	Goal *redskyappsv1alpha1.Goal
}

func (*DatadogMetricsSource) Metrics

func (s *DatadogMetricsSource) Metrics() ([]redskyv1beta1.Metric, error)

type DurationMetricsSource

type DurationMetricsSource struct {
	Goal *redskyappsv1alpha1.Goal
}

func (*DurationMetricsSource) Metrics

func (s *DurationMetricsSource) Metrics() ([]redskyv1beta1.Metric, error)

type EnvironmentVariablesSelector added in v1.12.1

type EnvironmentVariablesSelector struct {
	scan.GenericSelector
	// Regular expression matching the container name.
	ContainerName string `json:"containerName,omitempty"`
	// Name of the environment variable to match.
	VariableName string `json:"variableName,omitempty"`
	// Path to the environment variable's value.
	Path string `json:"path,omitempty"`
	// Prefix that appears before the value.
	ValuePrefix string `json:"valuePrefix,omitempty"`
	// Suffix that appears after the value.
	ValueSuffix string `json:"valueSuffix,omitempty"`
	// Allowed values for categorical parameters.
	Values []string `json:"values,omitempty"`
}

EnvironmentVariablesSelector scans for environment variables.

func (*EnvironmentVariablesSelector) Default added in v1.12.1

func (s *EnvironmentVariablesSelector) Default()

func (*EnvironmentVariablesSelector) Map added in v1.12.1

func (s *EnvironmentVariablesSelector) Map(node *yaml.RNode, meta yaml.ResourceMeta) ([]interface{}, error)

type ExperimentSource

type ExperimentSource interface {
	Update(exp *redskyv1beta1.Experiment) error
}

ExperimentSource allows selectors to modify the experiment directly. Note that for adding parameters, patches, or metrics, the appropriate source should be used instead.

type LocustSource

type LocustSource struct {
	Scenario    *redskyappsv1alpha1.Scenario
	Objective   *redskyappsv1alpha1.Objective
	Application *redskyappsv1alpha1.Application
}

func (*LocustSource) Metrics

func (s *LocustSource) Metrics() ([]redskyv1beta1.Metric, error)

func (*LocustSource) Read

func (s *LocustSource) Read() ([]*yaml.RNode, error)

func (*LocustSource) Update

func (s *LocustSource) Update(exp *redskyv1beta1.Experiment) error

type MetricSource

type MetricSource interface {
	Metrics() ([]redskyv1beta1.Metric, error)
}

MetricSource allows selectors to contribute metrics to an experiment.

type ParameterNamer

type ParameterNamer func(meta yaml.ResourceMeta, path []string, name string) string

ParameterNamer is used to compute the name of an optimization parameter.

type ParameterSource

type ParameterSource interface {
	Parameters(name ParameterNamer) ([]redskyv1beta1.Parameter, error)
}

ParameterSource allows selectors to add parameters to an experiment. In general PatchSources should also be ParameterSources to ensure the parameters used in the generated patches are configured on the experiment.

type PatchSource

type PatchSource interface {
	TargetRef() *corev1.ObjectReference
	Patch(name ParameterNamer) (yaml.Filter, error)
}

PatchSource allows selectors to contribute changes to the patch of a particular resource. In general, ParameterSource should also be implemented to add any parameters referenced by the generated patches.

type PrometheusMetricsSource

type PrometheusMetricsSource struct {
	Goal *redskyappsv1alpha1.Goal
}

func (*PrometheusMetricsSource) Metrics

type ReplicaSelector

type ReplicaSelector struct {
	scan.GenericSelector
	// Path to the replica field.
	Path string `json:"path,omitempty"`
	// Create container resource specifications even if the original object does not contain them.
	CreateIfNotPresent bool `json:"create,omitempty"`
}

ReplicaSelector identifies zero or more replica specifications.

func (*ReplicaSelector) Default added in v1.12.1

func (s *ReplicaSelector) Default()

func (*ReplicaSelector) Map

func (s *ReplicaSelector) Map(node *yaml.RNode, meta yaml.ResourceMeta) ([]interface{}, error)

type RequestsMetricsSource

type RequestsMetricsSource struct {
	Goal *redskyappsv1alpha1.Goal
}

func (*RequestsMetricsSource) Metrics

func (s *RequestsMetricsSource) Metrics() ([]redskyv1beta1.Metric, error)

type StormForgerSource

type StormForgerSource struct {
	Scenario    *redskyappsv1alpha1.Scenario
	Objective   *redskyappsv1alpha1.Objective
	Application *redskyappsv1alpha1.Application
}

func (*StormForgerSource) Metrics

func (s *StormForgerSource) Metrics() ([]redskyv1beta1.Metric, error)

func (*StormForgerSource) Read

func (s *StormForgerSource) Read() ([]*yaml.RNode, error)

func (*StormForgerSource) Update

type Transformer

type Transformer struct {
	// Flag indicating the all of the resources that were scanned should also be included in the output.
	IncludeApplicationResources bool
}

Transformer is used to convert all of the output from the selectors, only selector output matching the "*Source" interfaces are supported.

func (*Transformer) Transform

func (t *Transformer) Transform(nodes []*yaml.RNode, selected []interface{}) ([]*yaml.RNode, error)

Transform converts a scan of the supplied nodes into an experiment definition.

Jump to

Keyboard shortcuts

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