Documentation
¶
Index ¶
- 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 GetJSONBytes(url string) ([]byte, error)
- func GetLogger() *logrus.Logger
- 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 UpdateInClusterExperiment(e *Experiment) (err error)
- func UpdateInClusterExperimentStatus(e *Experiment) (err error)
- func UpdateVariable(v *v2alpha2.VersionDetail, name string, value string) error
- func WaitTimeoutOrError(wg *sync.WaitGroup, timeout time.Duration, errCh chan error) 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 (exp *Experiment) Interpolate(inputArgs []string) ([]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 Tags
- func (tags *Tags) Interpolate(str *string) (string, error)
- func (tags Tags) With(label string, obj interface{}) Tags
- func (tags Tags) WithRecommendedVersionForPromotion(exp *v2alpha2.Experiment, versions []VersionInfo) Tags
- func (tags Tags) WithRecommendedVersionForPromotionDeprecated(exp *v2alpha2.Experiment) Tags
- func (tags Tags) WithSecret(label string, secret *corev1.Secret) Tags
- type Task
- type TaskMeta
- type VersionInfo
Constants ¶
This section is empty.
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 = 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 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 GetJSONBytes ¶
GetJSONBytes downloads JSON 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 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.
func WaitTimeoutOrError ¶
WaitTimeoutOrError waits for one of the following three events 1) all goroutines in the waitgroup to finish normally -- no error is returned 2) a timeout occurred before all go routines could finish normally -- an error is returned 3) an error in the errCh channel sent by one of the goroutines -- an error is returned See https://stackoverflow.com/questions/32840687/timeout-for-waitgroup-wait
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) Interpolate ¶
func (exp *Experiment) Interpolate(inputArgs []string) ([]string, error)
Interpolate interpolates input arguments based on tags of the version recommended for promotion in the experiment. DEPRECATED. Use tags.Interpolate in base package instead
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 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.
func (Tags) WithRecommendedVersionForPromotion ¶
func (tags Tags) WithRecommendedVersionForPromotion(exp *v2alpha2.Experiment, versions []VersionInfo) Tags
WithRecommendedVersionForPromotion adds variables from versionInfo for version recommended for promotion
func (Tags) WithRecommendedVersionForPromotionDeprecated ¶
func (tags Tags) WithRecommendedVersionForPromotionDeprecated(exp *v2alpha2.Experiment) Tags
WithRecommendedVersionForPromotionDeprecated adds variables from versionDetail of version recommended for promotion
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.