genericclioptions

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package genericclioptions contains flags which can be added to you command, bound, completed, and produce useful helper functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandHeaderRoundTripper

type CommandHeaderRoundTripper struct {
	Delegate http.RoundTripper
	Headers  map[string]string
}

CommandHeaderRoundTripper adds a layer around the standard round tripper to add Request headers before delegation. Implements the go standard library "http.RoundTripper" interface.

func (*CommandHeaderRoundTripper) CancelRequest

func (c *CommandHeaderRoundTripper) CancelRequest(req *http.Request)

CancelRequest is propagated to the Delegate RoundTripper within if the wrapped RoundTripper implements this function.

func (*CommandHeaderRoundTripper) ParseCommandHeaders

func (c *CommandHeaderRoundTripper) ParseCommandHeaders(cmd *cobra.Command, args []string)

ParseCommandHeaders fills in a map of custom headers into the CommandHeaderRoundTripper. These headers are then filled into each request. For details on the custom headers see:

https://github.com/kubernetes/enhancements/tree/master/keps/sig-cli/859-kubectl-headers

Each call overwrites the previously parsed command headers (not additive). TODO(seans3): Parse/add flags removing PII from flag values.

func (*CommandHeaderRoundTripper) RoundTrip

func (c *CommandHeaderRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

CommandHeaderRoundTripper adds Request headers before delegating to standard round tripper. These headers are kubectl command headers which detail the kubectl command. See SIG CLI KEP 859:

https://github.com/kubernetes/enhancements/tree/master/keps/sig-cli/859-kubectl-headers

type IOStreams

type IOStreams struct {
	// In think, os.Stdin
	In io.Reader
	// Out think, os.Stdout
	Out io.Writer
	// ErrOut think, os.Stderr
	ErrOut io.Writer
}

IOStreams provides the standard names for iostreams. This is useful for embedding and for unit testing. Inconsistent and different names make it hard to read and review code.

func NewTestIOStreams

func NewTestIOStreams() (IOStreams, *bytes.Buffer, *bytes.Buffer, *bytes.Buffer)

NewTestIOStreams returns a valid IOStreams and in, out, errout buffers for unit tests.

func NewTestIOStreamsDiscard

func NewTestIOStreamsDiscard() IOStreams

NewTestIOStreamsDiscard returns a valid IOStreams that just discards.

Jump to

Keyboard shortcuts

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