Documentation
¶
Overview ¶
Package clientutil provides some util functions to set client
Index ¶
- Constants
- Variables
- func ListAgentFully(ctx context.Context, cli *client.Client) ([]v1agent.Agent, error)
- func ListConnectionFully(ctx context.Context, cli *client.Client) ([]v1connection.Connection, error)
- func NewAuthedClient(config *config.GlobalConfig) (*client.Client, error)
- func NewAuthedClientByIssuingTokenInCli(conf *config.GlobalConfig) (*client.Client, error)
- func NewClient(config *config.GlobalConfig) (*client.Client, error)
- func NewUnauthenticatedClient(config *config.GlobalConfig) *client.Client
- func TokenPath(username string) string
- type UnsupportedAuthMethodError
Constants ¶
const ( // TokenPrefix is the prefix used for cached tokens in the file system. TokenPrefix = "token" // BearerTokenKey is the key used to store the bearer token in the file cache. BearerTokenKey = "bearer" )
const (
// ChunkSize is the number of agents to fetch in each request.
ChunkSize = 100
)
Variables ¶
var ( ErrUnauthorized = errors.New("unauthorized") )
Functions ¶
func ListAgentFully ¶ added in v0.1.18
ListAgentFully lists all agents and applies the provided function to each agent. It continues to fetch agents until there are no more agents to fetch.
func ListConnectionFully ¶ added in v0.1.18
func ListConnectionFully(ctx context.Context, cli *client.Client) ([]v1connection.Connection, error)
ListConnectionFully lists all connections and applies the provided function to each connection. It continues to fetch connections until there are no more connections to fetch.
func NewAuthedClient ¶
func NewAuthedClient( config *config.GlobalConfig, ) (*client.Client, error)
NewAuthedClient creates a new authenticated OpAMP client using the cached bearer token. It retrieves the token from the file cache and initializes the client with it.
func NewAuthedClientByIssuingTokenInCli ¶
func NewAuthedClientByIssuingTokenInCli( conf *config.GlobalConfig, ) (*client.Client, error)
NewAuthedClientByIssuingTokenInCli creates a new authenticated OpAMP client by issuing a token in the CLI. It supports different authentication methods such as basic auth, manual token input, and GitHub device.
func NewClient ¶
func NewClient( config *config.GlobalConfig, ) (*client.Client, error)
NewClient creates a new authenticated Client.
func NewUnauthenticatedClient ¶ added in v0.1.18
func NewUnauthenticatedClient( config *config.GlobalConfig, ) *client.Client
NewUnauthenticatedClient creates a new unauthenticated Client.
Types ¶
type UnsupportedAuthMethodError ¶
type UnsupportedAuthMethodError struct {
Method string
}
UnsupportedAuthMethodError represents an error for unsupported authentication methods.
func (*UnsupportedAuthMethodError) Error ¶
func (e *UnsupportedAuthMethodError) Error() string
Error implements the error interface for UnsupportedAuthMethodError.