Documentation
¶
Overview ¶
Package experiment enables construction of an experiment object with handler/task lists within it.
Index ¶
- Variables
- func FindVariableInVersionDetail(v *v2alpha2.VersionDetail, name string) (string, error)
- func GetTypedObject(nn *client.ObjectKey, obj client.Object) error
- func Resource(resource string) schema.GroupResource
- func UpdateInClusterExperiment(e *Experiment) (err error)
- func UpdateInClusterExperimentStatus(e *Experiment) (err error)
- func UpdateVariable(v *v2alpha2.VersionDetail, name string, value string) error
- type Builder
- type Experiment
- func (e *Experiment) GetActionSpec(name string) (v2alpha2.Action, error)
- func (e *Experiment) GetVersionDetail(versionName string) (*iter8.VersionDetail, error)
- func (e *Experiment) GetVersionRecommendedForPromotion() (string, error)
- func (exp *Experiment) Interpolate(inputArgs []string) ([]string, error)
- func (e *Experiment) SetAggregatedBuiltinHists(fortioData v1.JSON)
Constants ¶
This section is empty.
Variables ¶
var GetClient = func() (rc client.Client, err error) { var restConf *rest.Config restConf, err = GetConfig() if err != nil { return nil, err } var addKnownTypes = func(scheme *runtime.Scheme) error { metav1.AddToGroupVersion(scheme, iter8.GroupVersion) scheme.AddKnownTypes(iter8.GroupVersion, &Experiment{}) var gvk schema.GroupVersionKind var gv schema.GroupVersion gvk = schema.GroupVersionKind{ Group: "", Version: "v1", Kind: "Secret", } gv = schema.GroupVersion{ Group: gvk.Group, Version: gvk.Version, } metav1.AddToGroupVersion(scheme, schema.GroupVersion{ Group: gvk.Group, Version: gvk.Version, }) scheme.AddKnownTypes(gv, &corev1.Secret{}) ksvc := &servingv1.Service{} gvk = ksvc.GetGroupVersionKind() gv = schema.GroupVersion{ Group: gvk.Group, Version: gvk.Version, } metav1.AddToGroupVersion(scheme, gv) scheme.AddKnownTypes(gv, ksvc) return nil } var schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) scheme := runtime.NewScheme() err = schemeBuilder.AddToScheme(scheme) if err == nil { rc, err = client.New(restConf, client.Options{ Scheme: scheme, }) if err == nil { return rc, nil } } return nil, errors.New("cannot get client using rest config") }
GetClient constructs and returns a K8s client. The returned client has experiment.Experiment type registered.
GetConfig variable is useful for test mocks.
var NumAttempt = 10
NumAttempt is the number of times to attempt Get operation for a k8s resource
var Period = 18 * time.Second
Period is the time duration between between each attempt
Functions ¶
func FindVariableInVersionDetail ¶
func FindVariableInVersionDetail(v *v2alpha2.VersionDetail, name string) (string, error)
FindVariableInVersionDetail scans the variables slice in the given version detail and returns the value of the given variable.
func GetTypedObject ¶
GetTypedObject gets a typed object from the k8s cluster. Types of such objects include experiment, knative service, etc. This function attempts to get the object `numAttempts` times, with the interval between attempts equal to `period`.
func Resource ¶
func Resource(resource string) schema.GroupResource
Resource takes an unqualified resource and returns a Group qualified GroupResource
func UpdateInClusterExperiment ¶
func UpdateInClusterExperiment(e *Experiment) (err error)
UpdateInClusterExperiment updates the experiment within cluster.
func UpdateInClusterExperimentStatus ¶ added in v0.1.16
func UpdateInClusterExperimentStatus(e *Experiment) (err error)
UpdateInClusterExperimentStatus updates the experiment status within cluster.
func UpdateVariable ¶
func UpdateVariable(v *v2alpha2.VersionDetail, name string, value string) error
UpdateVariable updates a variable within the given VersionDetail. If the variable is already present in the VersionDetail object, the pre-existing value takes precedence and is retained; if not, the new value is inserted.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder helps in construction of an experiment.
func (*Builder) Build ¶
func (b *Builder) Build() (*Experiment, error)
Build returns the built experiment or error. Must call FromFile or FromCluster on b prior to invoking Build.
func (*Builder) FromCluster ¶
FromCluster fetches an experiment from k8s cluster.
type Experiment ¶
type Experiment struct {
v2alpha2.Experiment
}
Experiment is an enhancement of v2alpha2.Experiment struct with useful methods.
func GetExperimentFromContext ¶
func GetExperimentFromContext(ctx context.Context) (*Experiment, error)
GetExperimentFromContext gets the experiment object from given context.
func (*Experiment) GetActionSpec ¶
func (e *Experiment) GetActionSpec(name string) (v2alpha2.Action, error)
GetActionSpec gets a named action spec from an experiment.
func (*Experiment) GetVersionDetail ¶
func (e *Experiment) GetVersionDetail(versionName string) (*iter8.VersionDetail, error)
GetVersionDetail from the experiment for a named version.
func (*Experiment) GetVersionRecommendedForPromotion ¶ added in v0.1.13
func (e *Experiment) GetVersionRecommendedForPromotion() (string, error)
GetVersionRecommendedForPromotion from the experiment.
func (*Experiment) Interpolate ¶ added in v0.1.10
func (exp *Experiment) Interpolate(inputArgs []string) ([]string, error)
Interpolate interpolates input arguments based on tags of the version recommended for promotion in the experiment.
func (*Experiment) SetAggregatedBuiltinHists ¶ added in v0.1.16
func (e *Experiment) SetAggregatedBuiltinHists(fortioData v1.JSON)
SetAggregatedBuiltinHists sets the experiment status field corresponding to aggregated built in hists