describe

package
v0.1.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package describe implements the `iter8ctl describe` subcommand.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmd

type Cmd struct {

	// Usage is a function that is invoked when execution of any `Cmd` method results in an error.
	// The typical behavior of `Cmd` after an error is as follows: Usage() prints an error message to stderr, subsequent Cmd methods turn into no-ops, and the program exits.
	// Note that Usage() is a field and not a method. You can supply your own implementation of Usage() while constructing `Cmd`.
	Usage func()
	// contains filtered or unexported fields
}

Cmd struct contains fields that store flags and intermediate results associated with an invocation of 'iter8ctl describe' subcommand.

func Builder

func Builder(stdin io.Reader, stdout io.Writer, stderr io.Writer) *Cmd

Builder returns an initialized Cmd struct pointer. Builder enables the builder design pattern along with method chaining.

Example
d := Builder(os.Stdin, os.Stdout, os.Stderr)
d.ParseFlags([]string{"-f", "path-to-my-experiment.yaml"})
Output:

Example (Bytebuffers)
a, b, c := bytes.Buffer{}, bytes.Buffer{}, bytes.Buffer{}
d := Builder(&a, &b, &c)
// The following will print the usage message in d's stderr, i.e., byte buffer c.
d.Usage()
Output:

func (*Cmd) Error

func (d *Cmd) Error() error

Error returns any error generated during the invocation of Cmd methods, or nil if there are no errors.

Example
d := Builder(os.Stdin, os.Stdout, os.Stderr)
// "-g" is an invalid flag which will cause ParseFlags invocation to generate an error.
d.ParseFlags([]string{"-g", "golly"})
// This will print the error to d.stderr (= os.Stderr)
fmt.Fprintln(d.stderr, d.Error())
Output:

Example (Bytebuffers)
a, b, c := bytes.Buffer{}, bytes.Buffer{}, bytes.Buffer{}
d := Builder(&a, &b, &c)
// "-g" is an invalid flag which will cause ParseFlags invocation to generate an error.
d.ParseFlags([]string{"-g", "golly"})
// The following will print the error message in d's stderr, i.e., byte buffer c.
fmt.Fprintln(d.stderr, d.Error())
Output:

func (*Cmd) GetExperiment

func (d *Cmd) GetExperiment() *Cmd

GetExperiment populates the Cmd struct with an experiment. The experiment may come from an input file when `iter8ctl describe` subcommand is invoked with the "-f experiment-file-path.yaml" flag. The experiment may also come from console input when `iter8ctl describe` subcommand is invoked with the "-f -" flag. The experiment input needs to be a valid iter8 experiment YAML. Otherwise, GetExperiment will generate an error.

Example
d := Builder(os.Stdin, os.Stdout, os.Stderr)
// Invalid experiment input will cause GetExperiment to generate an error
d.ParseFlags([]string{"-f", "path-to-my-experiment.yaml"}).GetExperiment()
Output:

func (*Cmd) ParseFlags

func (d *Cmd) ParseFlags(args []string) *Cmd

ParseFlags parses the flags supplied to Cmd. The returned Cmd struct contains the parsed result. If invalid flags are supplied, ParseFlags generates an error.

Example
d := Builder(os.Stdin, os.Stdout, os.Stderr)
// "-f" is the only supported flag
d.ParseFlags([]string{"-f", "path-to-my-experiment.yaml"})
Output:

Example (Invalid)
d := Builder(os.Stdin, os.Stdout, os.Stderr)
// Invalid flags will cause ParseFlags to generate an error.
d.ParseFlags([]string{"-g", "golly"})
Output:

func (*Cmd) PrintAnalysis

func (d *Cmd) PrintAnalysis() *Cmd

PrintAnalysis prints the progress of the iter8 experiment, winner assessment, version assessment, and metrics.

Example
d := Builder(os.Stdin, os.Stdout, os.Stderr)
d.ParseFlags([]string{"-f", "path-to-my-experiment.yaml"}).
	GetExperiment().
	PrintAnalysis()
Output:

Example (Bytebuffers)
a, b, c := bytes.Buffer{}, bytes.Buffer{}, bytes.Buffer{}
d := Builder(&a, &b, &c)
// PrintAnalysis call below will print to d.stdout, i.e., to byte buffer b.
d.ParseFlags([]string{"-f", "path-to-my-experiment.yaml"}).
	GetExperiment().
	PrintAnalysis()
Output:

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳