Documentation ¶
Index ¶
- Variables
- func AsScaledInt(q resource.Quantity, scale resource.Scale) int32
- func QuantitySuffix(scale resource.Scale, format resource.Format) string
- func SetExperimentLabel(key, value string) yaml.Filter
- func SetExperimentName(name string) yaml.Filter
- func SetNamespace(namespace string) yaml.Filter
- type ApplicationSelector
- type BuiltInPrometheus
- type ContainerResourcesSelector
- type CustomSource
- type DatadogMetricsSource
- type DurationMetricsSource
- type EnvironmentVariablesSelector
- type ExperimentSource
- type LocustSource
- type MetricSource
- type ParameterNamer
- type ParameterSource
- type PatchSource
- type PrometheusMetricsSource
- type ReplicaSelector
- type RequestsMetricsSource
- type StormForgePerformanceAuthorization
- type StormForgePerformanceSource
- type Transformer
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
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 ¶
SetExperimentLabel is a filter that sets a label on an experiment object.
func SetExperimentName ¶
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 ¶
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.
type BuiltInPrometheus ¶
type BuiltInPrometheus struct { SetupTaskName string ClusterRoleName string ServiceAccountName string ClusterRoleBindingName string sfio.ObjectSlice }
func (*BuiltInPrometheus) Update ¶
func (p *BuiltInPrometheus) Update(exp *optimizev1beta2.Experiment) error
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 ¶
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.
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 ¶
func (s *DatadogMetricsSource) Metrics() ([]optimizev1beta2.Metric, error)
type DurationMetricsSource ¶
type DurationMetricsSource struct {
Goal *optimizeappsv1alpha1.Goal
}
func (*DurationMetricsSource) Metrics ¶
func (s *DurationMetricsSource) Metrics() ([]optimizev1beta2.Metric, error)
type EnvironmentVariablesSelector ¶
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 ¶
func (s *EnvironmentVariablesSelector) Default()
func (*EnvironmentVariablesSelector) Map ¶
func (s *EnvironmentVariablesSelector) Map(node *yaml.RNode, meta yaml.ResourceMeta) ([]interface{}, 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) 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 ¶
func (s *PrometheusMetricsSource) Metrics() ([]optimizev1beta2.Metric, error)
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 ¶
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 *optimizeappsv1alpha1.Goal
}
func (*RequestsMetricsSource) Metrics ¶
func (s *RequestsMetricsSource) Metrics() ([]optimizev1beta2.Metric, error)
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 ¶
func (az *StormForgePerformanceAuthorization) AccessToken(ctx context.Context, org string) (string, error)
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 (s *StormForgePerformanceSource) Metrics() ([]optimizev1beta2.Metric, error)
func (*StormForgePerformanceSource) Read ¶
func (s *StormForgePerformanceSource) Read() ([]*yaml.RNode, error)
func (*StormForgePerformanceSource) Update ¶
func (s *StormForgePerformanceSource) Update(exp *optimizev1beta2.Experiment) error
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.