generation

package
v2.1.7 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2022 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptimizeConfig *config.OptimizeConfig

DefaultOptimizeConfig is the mega-hack-sky-hook used to inject configuration this low into the code. This should not be necessary, as generation should not be accessing the configuration directly.

Functions

func AsScaledInt

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

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 *optimizeappsv1alpha1.Application
	Scenario    *optimizeappsv1alpha1.Scenario
	Objective   *optimizeappsv1alpha1.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 optimizeappsv1alpha1.ContainerResources

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

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

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

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

type CustomSource

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

func (*CustomSource) Metrics

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

func (*CustomSource) Update

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

type DatadogMetricsSource

type DatadogMetricsSource struct {
	Goal *optimizeappsv1alpha1.Goal
}

func (*DatadogMetricsSource) Metrics

type DurationMetricsSource

type DurationMetricsSource struct {
	Goal *optimizeappsv1alpha1.Goal
}

func (*DurationMetricsSource) Metrics

type EnvironmentVariablesSelector

type EnvironmentVariablesSelector optimizeappsv1alpha1.EnvironmentVariable

EnvironmentVariablesSelector scans for environment variables.

func (*EnvironmentVariablesSelector) Map

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

func (*EnvironmentVariablesSelector) Select added in v2.0.9

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

type ExperimentSource

type ExperimentSource interface {
	Update(exp *optimizev1beta2.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    *optimizeappsv1alpha1.Scenario
	Objective   *optimizeappsv1alpha1.Objective
	Application *optimizeappsv1alpha1.Application
}

func (*LocustSource) Metrics

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

func (*LocustSource) Read

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

func (*LocustSource) Update

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

type MetricSource

type MetricSource interface {
	Metrics() ([]optimizev1beta2.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) ([]optimizev1beta2.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 *optimizeappsv1alpha1.Goal
}

func (*PrometheusMetricsSource) Metrics

type ReplicaSelector

type ReplicaSelector optimizeappsv1alpha1.Replicas

ReplicaSelector identifies zero or more replica specifications.

func (*ReplicaSelector) Map

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

func (*ReplicaSelector) Select added in v2.0.9

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

type RequestsMetricsSource

type RequestsMetricsSource struct {
	Goal *optimizeappsv1alpha1.Goal
}

func (*RequestsMetricsSource) Metrics

type StormForgePerformanceAuthorization

type StormForgePerformanceAuthorization struct {
	// The configuration to get authorization information from, leave nil to get the default.
	Config *config.OptimizeConfig
	// The function used to lookup environment variables, leave nil to get the default.
	LookupEnvFunc func(string) (string, bool)
	// The label to use to describe the Performance Service Account (if needed)
	ServiceAccountLabel func() string
}

StormForgePerformanceAuthorization is a helper for obtaining StormForge Performance access tokens (JWTs). Normally, low level code like this does not have access to the application layer configuration so this is a bit of a hack to ensure we can talk to the appropriate APIs.

func (*StormForgePerformanceAuthorization) AccessToken

AccessToken returns a StormForge Performance access token for the optional organization. If the organization is empty, we use the private space that depends on shared authorization between the two products.

type StormForgePerformanceSource

type StormForgePerformanceSource struct {
	Scenario    *optimizeappsv1alpha1.Scenario
	Objective   *optimizeappsv1alpha1.Objective
	Application *optimizeappsv1alpha1.Application
}

func (*StormForgePerformanceSource) Metrics

func (*StormForgePerformanceSource) Read

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

func (*StormForgePerformanceSource) 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