Documentation
¶
Overview ¶
Package clientutil provides some util functions to set client
Index ¶
- Constants
- Variables
- func ListAcrossNamespaces[T any](ctx context.Context, cli *client.Client, ...) ([]T, error)
- func ListAgentFully(ctx context.Context, cli *client.Client, namespace string) ([]v1.Agent, error)
- func ListAgentFullyByAgentGroup(ctx context.Context, cli *client.Client, namespace string, ...) ([]v1.Agent, error)
- func ListAgentGroupFully(ctx context.Context, cli *client.Client, namespace string, ...) ([]v1.AgentGroup, error)
- func ListAgentPackageFully(ctx context.Context, cli *client.Client, namespace string) ([]v1.AgentPackage, error)
- func ListAgentRemoteConfigFully(ctx context.Context, cli *client.Client, namespace string) ([]v1.AgentRemoteConfig, error)
- func ListCertificateFully(ctx context.Context, cli *client.Client, namespace string) ([]v1.Certificate, error)
- func ListConnectionFully(ctx context.Context, cli *client.Client, namespace string) ([]v1.Connection, error)
- func ListNamespaceFully(ctx context.Context, cli *client.Client) ([]v1.Namespace, error)
- func ListRoleFully(ctx context.Context, cli *client.Client) ([]v1.Role, error)
- func ListUserFully(ctx context.Context, cli *client.Client) ([]v1.User, 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") // ErrNoEndpoint is returned when no endpoint is configured for the current context. ErrNoEndpoint = errors.New("no endpoint configured for current context: " + "run 'opampctl context use <name>' or set a cluster endpoint in your config") )
Functions ¶
func ListAcrossNamespaces ¶ added in v0.1.35
func ListAcrossNamespaces[T any]( ctx context.Context, cli *client.Client, listFn func(ctx context.Context, namespace string) ([]T, error), ) ([]T, error)
ListAcrossNamespaces lists resources across all namespaces by iterating over each namespace and calling the provided list function.
func ListAgentFully ¶ added in v0.1.18
ListAgentFully lists all agents in a namespace and applies the provided function to each agent. It continues to fetch agents until there are no more agents to fetch.
func ListAgentFullyByAgentGroup ¶ added in v0.1.22
func ListAgentFullyByAgentGroup( ctx context.Context, cli *client.Client, namespace string, agentGroupName string, ) ([]v1.Agent, error)
ListAgentFullyByAgentGroup lists all agents in a specific agent group and applies the provided function to each agent. It continues to fetch agents until there are no more agents to fetch.
func ListAgentGroupFully ¶ added in v0.1.20
func ListAgentGroupFully( ctx context.Context, cli *client.Client, namespace string, opts ...client.ListOption, ) ([]v1.AgentGroup, error)
ListAgentGroupFully lists all agent groups and applies the provided function to each agent group. It continues to fetch agent groups until there are no more agent groups to fetch.
func ListAgentPackageFully ¶ added in v0.1.28
func ListAgentPackageFully( ctx context.Context, cli *client.Client, namespace string, ) ([]v1.AgentPackage, error)
ListAgentPackageFully lists all agent packages and applies the provided function to each agent package. It continues to fetch agent packages until there are no more agent packages to fetch.
func ListAgentRemoteConfigFully ¶ added in v0.1.28
func ListAgentRemoteConfigFully( ctx context.Context, cli *client.Client, namespace string, ) ([]v1.AgentRemoteConfig, error)
ListAgentRemoteConfigFully lists all agent remote configs in a namespace. It continues to fetch agent remote configs until there are no more to fetch.
func ListCertificateFully ¶ added in v0.1.28
func ListCertificateFully( ctx context.Context, cli *client.Client, namespace string, ) ([]v1.Certificate, error)
ListCertificateFully lists all certificates in a namespace. It continues to fetch certificates until there are no more to fetch.
func ListConnectionFully ¶ added in v0.1.18
func ListConnectionFully( ctx context.Context, cli *client.Client, namespace string, ) ([]v1.Connection, error)
ListConnectionFully lists all connections in a namespace. It continues to fetch connections until there are no more connections to fetch.
func ListNamespaceFully ¶ added in v0.1.35
ListNamespaceFully lists all namespaces. It continues to fetch namespaces until there are no more namespaces to fetch.
func ListRoleFully ¶ added in v0.1.35
ListRoleFully lists all roles. It continues to fetch roles until there are no more roles to fetch.
func ListUserFully ¶ added in v0.1.35
ListUserFully lists all users. It continues to fetch users until there are no more users 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. Returns nil if no endpoint is configured for the current context.
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.