testutils

package
v1.18.0-beta16 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecuteCommandWithArgs added in v1.17.0

func ExecuteCommandWithArgs(command *cobra.Command, args ...string) error

ExecuteCommandWithArgs executes the provided cobra.Command with the defined arguments If an error was encountered it will be returned, nil otherwise

func ExecuteCommandWithArgsOut added in v1.17.0

func ExecuteCommandWithArgsOut(command *cobra.Command, args ...string) (string, error)

ExecuteCommandWithArgsOut executes the provided cobra.Command with the defined arguments Any output to Stdout or Stderr will be returned in a string, and if an error was encountered an error will be returned optionally

NOTE:

cobra.Command's support configuring an alternative to using stdout and stderr
However, glooctl does not rely on this functionality and uses os.Stdout directly
We opt to bake this complexity directly into this tool, instead of forcing developers to
be aware of it. As a result, we do the following:
	1. Capture the stdout and stderr Files
	2. Update them to point to a writer of our choosing
	3. Execute the command
	4. Undo the change to stdout and stderr
	5. Return the output string

Update May 7th: @sam-heilbron tried to call this function within a struct following our cmdutils.Cmd interface. However, even with no functional changes, it was triggering a data-race when updating os.Stdout

func GetTestSettings added in v0.18.42

func GetTestSettings() *v1.Settings

func Glooctl

func Glooctl(argStr string) error

Glooctl executes a glooctl command, passing the provided string as the arguments No output is expected or returned, and if an error was encountered, it will be returned otherwise nill will be returned

Example:

argStr = "install gateway --dry-run"
This will result in the following command being executed: `glooctl install gateway --dry-run`

func GlooctlOut

func GlooctlOut(argStr string) (string, error)

GlooctlOut executes a glooctl command, passing the provided string as the arguments Any output to Stdout or Stderr will be returned in a string, and if an error was encountered an error will be returned optionally

Example:

argStr = "install gateway --dry-run"
This will result in the following command being executed: `glooctl install gateway --dry-run`

func Make

func Make(dir, args string) error

Types

type GlooCli added in v1.17.0

type GlooCli struct{}

GlooCli is way to execute glooctl commands consistently It has the benefit of invoking the underlying *cobra.Command directly, meaning that we do not rely on any generating binaries

func NewGlooCli added in v1.17.0

func NewGlooCli() *GlooCli

NewGlooCli returns an implementation of the GlooCli

func (*GlooCli) Check added in v1.17.0

func (c *GlooCli) Check(ctx context.Context, extraArgs ...string) (string, error)

Check attempts to check the installation It returns a string containing the output that a user would see if they invoked `glooctl check` It optionally returns an error if one was encountered

func (*GlooCli) CheckCrds added in v1.17.0

func (c *GlooCli) CheckCrds(ctx context.Context, extraArgs ...string) error

CheckCrds attempts to check the CRDs in the cluster, and returns an error if one was encountered

func (*GlooCli) DebugLogs added in v1.17.0

func (c *GlooCli) DebugLogs(ctx context.Context, extraArgs ...string) error

DebugLogs attempts to output the logs to a specified file, and returns an error if one was encountered

func (*GlooCli) Execute added in v1.17.0

func (c *GlooCli) Execute(ctx context.Context, argStr string) error

Execute executes an arbitrary glooctl command

func (*GlooCli) ExecuteOut added in v1.17.0

func (c *GlooCli) ExecuteOut(ctx context.Context, argStr string) (string, error)

ExecuteOut executes an arbitrary glooctl command It returns a string containing the output that is piped to stdout and stdrr It optionally returns an error if one was encountered

func (*GlooCli) GetProxy added in v1.17.0

func (c *GlooCli) GetProxy(ctx context.Context, extraArgs ...string) (string, error)

GetProxy attempts to get a proxy or list of proxies with the given args. It returns a string containing the output that a user would see if they invoked `glooctl get proxy <args>`. It optionally returns an error if one was encountered.

func (*GlooCli) IstioInject added in v1.17.0

func (c *GlooCli) IstioInject(ctx context.Context, installNamespace, kubeContext string, extraArgs ...string) (string, error)

IstioInject inject istio-proxy and sds

func (*GlooCli) IstioUninject added in v1.17.0

func (c *GlooCli) IstioUninject(ctx context.Context, installNamespace, kubeContext string, extraArgs ...string) (string, error)

IstioUninject uninjects istio-proxy and sds

func (*GlooCli) NewCommand added in v1.17.0

func (c *GlooCli) NewCommand(ctx context.Context) *cobra.Command

NewCommand returns a fresh cobra.Command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL