admincli

package
v1.17.0 Latest Latest
Warning

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

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

README

Admincli

Warning This code is not intended to be used within the Control Plane.

Client

This is the Go client that should be used whenever communicating with the Envoy Admin API. Within the Gloo project, it is used inside of tests and our CLI.

Philosophy

We expose methods that return a Command which can be run by the calling code. Any methods that fit this structure, should end in Cmd:

func StatsCmd(ctx context.Context) cmdutils.Cmd {}

There are also methods that the client exposes which are syntactic sugar on top of this command API. These methods tend to follow the naming convention: GetX:

func GetStats(ctx context.Context) (string, error) {}

As a general practice, these methods should return a concrete type, whenever possible.

Documentation

Index

Constants

View Source
const (
	ConfigDumpPath     = "config_dump"
	StatsPath          = "stats"
	ClustersPath       = "clusters"
	ListenersPath      = "listeners"
	ModifyRuntimePath  = "runtime_modify"
	ShutdownServerPath = "quitquitquit"
	HealthCheckPath    = "healthcheck"
	LoggingPath        = "logging"
	ServerInfoPath     = "server_info"

	DefaultAdminPort = 19000
)

Variables

This section is empty.

Functions

func GetStaticClustersByName

func GetStaticClustersByName(configDump *adminv3.ConfigDump) (map[string]*clusterv3.Cluster, error)

GetStaticClustersByName returns a map of static clusters, indexed by their name If there are no static clusters present, an empty map is returned An error is returned if any conversion fails

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a utility for executing requests against the Envoy Admin API The Admin API handlers can be found here: https://github.com/envoyproxy/envoy/blob/63bc9b564b1a76a22a0d029bcac35abeffff2a61/source/server/admin/admin.cc#L127

func NewClient

func NewClient() *Client

NewClient returns an implementation of the admincli.Client

func (*Client) ClustersCmd

func (c *Client) ClustersCmd(ctx context.Context) cmdutils.Cmd

ClustersCmd returns the cmdutils.Cmd that can be run to request data from the clusters endpoint

func (*Client) Command

func (c *Client) Command(ctx context.Context, options ...curl.Option) cmdutils.Cmd

Command returns a curl Command, using the provided curl.Option as well as the client.curlOptions

func (*Client) ConfigDumpCmd

func (c *Client) ConfigDumpCmd(ctx context.Context, queryParams map[string]string) cmdutils.Cmd

ConfigDumpCmd returns the cmdutils.Cmd that can be run to request data from the config_dump endpoint

func (*Client) FailHealthCheck

func (c *Client) FailHealthCheck(ctx context.Context) error

FailHealthCheck calls the endpoint to have the server start failing health checks

func (*Client) GetConfigDump

func (c *Client) GetConfigDump(ctx context.Context, queryParams map[string]string) (*adminv3.ConfigDump, error)

GetConfigDump returns the structured data that is available at the config_dump endpoint

func (*Client) GetServerInfo

func (c *Client) GetServerInfo(ctx context.Context) (*adminv3.ServerInfo, error)

GetServerInfo calls the endpoint to return the info for the server

func (*Client) GetSingleListenerFromDynamicListeners

func (c *Client) GetSingleListenerFromDynamicListeners(
	ctx context.Context,
	listenerNameRegex string,
) (*listenerv3.Listener, error)

GetSingleListenerFromDynamicListeners queries for a single, active dynamic listener in the envoy config dump and returns it as an envoy v3.Listener. This helper will only work if the provided name_regex matches a single dynamic_listener but will always use the first set of configs returned regardless

func (*Client) GetStaticClusters

func (c *Client) GetStaticClusters(ctx context.Context) (map[string]*clusterv3.Cluster, error)

GetStaticClusters returns the map of static clusters available on a ConfigDump, indexed by their name

func (*Client) GetStats

func (c *Client) GetStats(ctx context.Context) (string, error)

GetStats returns the data that is available at the stats endpoint

func (*Client) ListenersCmd

func (c *Client) ListenersCmd(ctx context.Context) cmdutils.Cmd

ListenersCmd returns the cmdutils.Cmd that can be run to request data from the listeners endpoint

func (*Client) ModifyRuntimeConfiguration

func (c *Client) ModifyRuntimeConfiguration(ctx context.Context, queryParameters map[string]string) error

ModifyRuntimeConfiguration passes the queryParameters to the runtime_modify endpoint

func (*Client) PassHealthCheck

func (c *Client) PassHealthCheck(ctx context.Context) error

PassHealthCheck calls the endpoint to have the server start passing health checks

func (*Client) RequestPathCmd

func (c *Client) RequestPathCmd(ctx context.Context, path string) cmdutils.Cmd

RequestPathCmd returns the cmdutils.Cmd that can be run, and will execute a request against the provided path

func (*Client) RunCommand

func (c *Client) RunCommand(ctx context.Context, options ...curl.Option) error

RunCommand executes a curl Command, using the provided curl.Option as well as the client.curlOptions

func (*Client) SetLogLevel

func (c *Client) SetLogLevel(ctx context.Context, logLevel string) error

SetLogLevel calls the endpoint to change the log level for the server

func (*Client) ShutdownServer

func (c *Client) ShutdownServer(ctx context.Context) error

ShutdownServer calls the shutdown server endpoint

func (*Client) StatsCmd

func (c *Client) StatsCmd(ctx context.Context) cmdutils.Cmd

StatsCmd returns the cmdutils.Cmd that can be run to request data from the stats endpoint

func (*Client) WithCurlOptions

func (c *Client) WithCurlOptions(options ...curl.Option) *Client

WithCurlOptions sets the default set of curl.Option that will be used by default with the cmdutils.Cmd created by the Client

func (*Client) WithReceiver

func (c *Client) WithReceiver(receiver io.Writer) *Client

WithReceiver sets the io.Writer that will be used by default for the stdout and stderr of cmdutils.Cmd created by the Client

Jump to

Keyboard shortcuts

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