Documentation ¶
Index ¶
- Constants
- Variables
- func BoolPointer(b bool) *bool
- func FindVariableInVersionDetail(v *v2alpha2.VersionDetail, name string) (string, error)
- func Float32Pointer(f float32) *float32
- func Float64Pointer(f float64) *float64
- func GetActionStringFromContext(ctx context.Context) (string, error)
- func GetIter8LogPrecedence(exp *Experiment, action string) int
- func GetLogger() *logrus.Logger
- func GetPayloadBytes(url string) ([]byte, error)
- func GetSecret(namespacedname string) (*corev1.Secret, error)
- func GetTokenFromSecret(secret *corev1.Secret) (string, error)
- func GetTypedObject(nn *client.ObjectKey, obj client.Object) error
- func Int32Pointer(i int32) *int32
- func IsARun(t *v2alpha2.TaskSpec) bool
- func IsATask(t *v2alpha2.TaskSpec) bool
- func Resource(resource string) schema.GroupResource
- func SetLogLevel(l logrus.Level)
- func StringPointer(s string) *string
- func UInt32Pointer(u uint32) *uint32
- func UpdateInClusterExperiment(e *Experiment) (err error)
- func UpdateInClusterExperimentStatus(e *Experiment) (err error)
- func UpdateVariable(v *v2alpha2.VersionDetail, name string, value string) error
- type Action
- type Builder
- type ContextKey
- type Experiment
- func (exp *Experiment) CandidateWon() bool
- func (e *Experiment) GetActionSpec(name string) (v2alpha2.Action, error)
- func (e *Experiment) GetVersionDetail(versionName string) (*v2alpha2.VersionDetail, error)
- func (e *Experiment) GetVersionRecommendedForPromotion() (string, error)
- func (e *Experiment) SetAggregatedBuiltinHists(fortioData v1.JSON)
- func (exp *Experiment) ToMap() (map[string]interface{}, error)
- func (exp *Experiment) WinnerFound() bool
- type HTTPMethod
- type Iter8Logger
- type Tags
- type Task
- type TaskMeta
- type VersionInfo
Constants ¶
const ( // LeftDelim is the left delimiter used for interpolation in http and run tasks LeftDelim string = "@<" // RightDelim is the right delimiter used for interpolation in http and run tasks RightDelim string = ">@" )
Variables ¶
var CompletePath func(prefix string, suffix string) string = controllers.CompletePath
CompletePath determines complete path of a file
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{}) gv := schema.GroupVersion{ Group: "", Version: "v1", } metav1.AddToGroupVersion(scheme, gv) scheme.AddKnownTypes(gv, &corev1.Secret{}) 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 = 2
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 BoolPointer ¶
BoolPointer takes a bool as input, creates a new variable with the input value, and returns a pointer to the variable
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 Float32Pointer ¶
Float32Pointer takes an float32 as input, creates a new variable with the input value, and returns a pointer to the variable
func Float64Pointer ¶
Float64Pointer takes an float64 as input, creates a new variable with the input value, and returns a pointer to the variable
func GetActionStringFromContext ¶ added in v0.1.34
GetActionStringFromContext gets the action string from given context.
func GetIter8LogPrecedence ¶ added in v0.1.33
func GetIter8LogPrecedence(exp *Experiment, action string) int
GetIter8LogPrecedence returns the precedence value to be used in an Ite8log
func GetPayloadBytes ¶ added in v0.1.34
GetPayloadBytes downloads payload from URL and returns a byte slice
func GetTokenFromSecret ¶
GetTokenFromSecret gets token from k8s secret object can be used in notification, gitops and other tasks that use secret tokens
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 Int32Pointer ¶
Int32Pointer takes an int32 as input, creates a new variable with the input value, and returns a pointer to the variable
func Resource ¶
func Resource(resource string) schema.GroupResource
Resource takes an unqualified resource and returns a Group qualified GroupResource
func StringPointer ¶
StringPointer takes a string as input, creates a new variable with the input value, and returns a pointer to the variable
func UInt32Pointer ¶ added in v0.1.34
UInt32Pointer takes a uint32 as input, creates a new variable with the input value, and returns a pointer to the variable
func UpdateInClusterExperiment ¶
func UpdateInClusterExperiment(e *Experiment) (err error)
UpdateInClusterExperiment updates the experiment within cluster.
func UpdateInClusterExperimentStatus ¶
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 ContextKey ¶
type ContextKey string
ContextKey is the type of key that will be used to index into context.
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) CandidateWon ¶
func (exp *Experiment) CandidateWon() bool
CandidateWon returns true if candidate won in the experiment
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) (*v2alpha2.VersionDetail, error)
GetVersionDetail from the experiment for a named version.
func (*Experiment) GetVersionRecommendedForPromotion ¶
func (e *Experiment) GetVersionRecommendedForPromotion() (string, error)
GetVersionRecommendedForPromotion from the experiment.
func (*Experiment) SetAggregatedBuiltinHists ¶
func (e *Experiment) SetAggregatedBuiltinHists(fortioData v1.JSON)
SetAggregatedBuiltinHists sets the experiment status field corresponding to aggregated built in hists
func (*Experiment) ToMap ¶
func (exp *Experiment) ToMap() (map[string]interface{}, error)
ToMap converts exp.Experiment to a map[string]interface{}
func (*Experiment) WinnerFound ¶
func (exp *Experiment) WinnerFound() bool
WinnerFound returns true if Experiment found a winner
type HTTPMethod ¶
type HTTPMethod string
HTTPMethod is either GET or POST
const ( // GET method GET HTTPMethod = "GET" // POST method POST = "POST" )
func HTTPMethodPointer ¶
func HTTPMethodPointer(h HTTPMethod) *HTTPMethod
HTTPMethodPointer takes an HTTPMethod as input, creates a new variable with the input value, and returns a pointer to the variable
type Iter8Logger ¶ added in v0.1.33
type Iter8Logger func(expName string, expNamespace string, priority controllers.Iter8LogPriority, taskName string, msg string, prec int) string
Iter8Logger type objects are functions that can be used to print Iter8Logs within tasks
type Tags ¶
type Tags struct {
M map[string]interface{}
}
Tags supports string extrapolation using tags.
func GetDefaultTags ¶
GetDefaultTags creates interpolation.Tags from experiment referenced by context
func (*Tags) Interpolate ¶
Interpolate str using tags.
type TaskMeta ¶
type TaskMeta struct { Task *string `json:"task,omitempty" yaml:"task,omitempty"` Run *string `json:"run,omitempty" yaml:"run,omitempty"` If *string `json:"if,omitempty" yaml:"if,omitempty"` }
TaskMeta is common to all Tasks
type VersionInfo ¶
type VersionInfo struct {
Variables []v2alpha2.NamedValue `json:"variables,omitempty" yaml:"variables,omitempty"`
}
VersionInfo contains name value pairs for each version.