Documentation
¶
Overview ¶
Package client provides Talos API client.
Index ¶
- func AddrFromPeer(remote *peer.Peer) (peerHost string)
- func FilterMessages(resp interface{}, err error) (interface{}, error)
- func ReadStream(stream MachineStream) (io.ReadCloser, <-chan error, error)
- func RemotePeer(ctx context.Context) (peerHost string)
- func WithNodes(ctx context.Context, nodes ...string) context.Context
- type Client
- func (c *Client) Bootstrap(ctx context.Context) (err error)
- func (c *Client) Close() error
- func (c *Client) ClusterHealthCheck(ctx context.Context, waitTimeout time.Duration, ...) (clusterapi.ClusterService_HealthCheckClient, error)
- func (c *Client) Containers(ctx context.Context, namespace string, driver common.ContainerDriver, ...) (resp *machineapi.ContainersResponse, err error)
- func (c *Client) Copy(ctx context.Context, rootPath string) (io.ReadCloser, <-chan error, error)
- func (c *Client) Dmesg(ctx context.Context, follow, tail bool) (machineapi.MachineService_DmesgClient, error)
- func (c *Client) Events(ctx context.Context, opts ...EventsOptionFunc) (stream machineapi.MachineService_EventsClient, err error)
- func (c *Client) EventsWatch(ctx context.Context, watchFunc func(<-chan Event), opts ...EventsOptionFunc) error
- func (c *Client) GetConfigContext() *config.Context
- func (c *Client) Interfaces(ctx context.Context, callOptions ...grpc.CallOption) (resp *networkapi.InterfacesResponse, err error)
- func (c *Client) Kubeconfig(ctx context.Context) ([]byte, error)
- func (c *Client) KubeconfigRaw(ctx context.Context) (io.ReadCloser, <-chan error, error)
- func (c *Client) LS(ctx context.Context, req *machineapi.ListRequest) (stream machineapi.MachineService_ListClient, err error)
- func (c *Client) Logs(ctx context.Context, namespace string, driver common.ContainerDriver, ...) (stream machineapi.MachineService_LogsClient, err error)
- func (c *Client) Memory(ctx context.Context, callOptions ...grpc.CallOption) (resp *machineapi.MemoryResponse, err error)
- func (c *Client) Mounts(ctx context.Context, callOptions ...grpc.CallOption) (resp *machineapi.MountsResponse, err error)
- func (c *Client) Processes(ctx context.Context, callOptions ...grpc.CallOption) (resp *machineapi.ProcessesResponse, err error)
- func (c *Client) Read(ctx context.Context, path string) (io.ReadCloser, <-chan error, error)
- func (c *Client) Reboot(ctx context.Context) (err error)
- func (c *Client) Recover(ctx context.Context, source machineapi.RecoverRequest_Source) (err error)
- func (c *Client) Reset(ctx context.Context, graceful, reboot bool) (err error)
- func (c *Client) Restart(ctx context.Context, namespace string, driver common.ContainerDriver, ...) (err error)
- func (c *Client) Rollback(ctx context.Context) (err error)
- func (c *Client) Routes(ctx context.Context, callOptions ...grpc.CallOption) (resp *networkapi.RoutesResponse, err error)
- func (c *Client) ServiceInfo(ctx context.Context, id string, callOptions ...grpc.CallOption) (services []ServiceInfo, err error)
- func (c *Client) ServiceList(ctx context.Context, callOptions ...grpc.CallOption) (resp *machineapi.ServiceListResponse, err error)
- func (c *Client) ServiceRestart(ctx context.Context, id string, callOptions ...grpc.CallOption) (resp *machineapi.ServiceRestartResponse, err error)
- func (c *Client) ServiceStart(ctx context.Context, id string, callOptions ...grpc.CallOption) (resp *machineapi.ServiceStartResponse, err error)
- func (c *Client) ServiceStop(ctx context.Context, id string, callOptions ...grpc.CallOption) (resp *machineapi.ServiceStopResponse, err error)
- func (c *Client) Shutdown(ctx context.Context) (err error)
- func (c *Client) Stats(ctx context.Context, namespace string, driver common.ContainerDriver, ...) (resp *machineapi.StatsResponse, err error)
- func (c *Client) Time(ctx context.Context, callOptions ...grpc.CallOption) (resp *timeapi.TimeResponse, err error)
- func (c *Client) TimeCheck(ctx context.Context, server string, callOptions ...grpc.CallOption) (resp *timeapi.TimeResponse, err error)
- func (c *Client) Upgrade(ctx context.Context, image string, preserve bool, ...) (resp *machineapi.UpgradeResponse, err error)
- func (c *Client) Version(ctx context.Context, callOptions ...grpc.CallOption) (resp *machineapi.VersionResponse, err error)
- type Credentials
- func CredentialsFromConfigContext(context *config.Context) (*Credentials, error)
- func NewClientContextAndCredentialsFromConfig(p, ctx string) (context *config.Context, creds *Credentials, err error)deprecated
- func NewClientContextAndCredentialsFromParsedConfig(c *config.Config, ctx string) (context *config.Context, creds *Credentials, err error)deprecated
- type Event
- type EventsOptionFunc
- type MachineStream
- type NodeError
- type OptionFunc
- func WithConfig(cfg *config.Config) OptionFunc
- func WithConfigContext(cfg *config.Context) OptionFunc
- func WithConfigFromFile(fn string) OptionFunc
- func WithContextName(name string) OptionFunc
- func WithDefaultConfig() OptionFunc
- func WithEndpoints(endpoints ...string) OptionFunc
- func WithGRPCDialOptions(opts ...grpc.DialOption) OptionFunc
- func WithTLSConfig(tlsConfig *tls.Config) OptionFunc
- func WithUnixSocket(path string) OptionFunc
- type Options
- type ServiceInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddrFromPeer ¶ added in v0.6.0
AddrFromPeer extracts peer address from grpc Peer.
func FilterMessages ¶
FilterMessages removes error Messagess from resp and builds multierror.
nolint: gocyclo
func ReadStream ¶
func ReadStream(stream MachineStream) (io.ReadCloser, <-chan error, error)
ReadStream converts grpc stream into io.Reader.
func RemotePeer ¶ added in v0.6.0
RemotePeer parses remote peer address from grpc stream context.
Types ¶
type Client ¶
type Client struct { MachineClient machineapi.MachineServiceClient TimeClient timeapi.TimeServiceClient NetworkClient networkapi.NetworkServiceClient ClusterClient clusterapi.ClusterServiceClient // contains filtered or unexported fields }
Client implements the proto.OSClient interface. It serves as the concrete type with the required methods.
func New ¶ added in v0.5.0
func New(ctx context.Context, opts ...OptionFunc) (c *Client, err error)
New returns a new Client.
func (*Client) ClusterHealthCheck ¶ added in v0.6.0
func (c *Client) ClusterHealthCheck(ctx context.Context, waitTimeout time.Duration, clusterInfo *clusterapi.ClusterInfo) (clusterapi.ClusterService_HealthCheckClient, error)
ClusterHealthCheck runs a Talos cluster health check.
func (*Client) Containers ¶
func (c *Client) Containers(ctx context.Context, namespace string, driver common.ContainerDriver, callOptions ...grpc.CallOption) (resp *machineapi.ContainersResponse, err error)
Containers implements the proto.OSClient interface.
func (*Client) Dmesg ¶
func (c *Client) Dmesg(ctx context.Context, follow, tail bool) (machineapi.MachineService_DmesgClient, error)
Dmesg implements the proto.OSClient interface.
func (*Client) Events ¶ added in v0.5.0
func (c *Client) Events(ctx context.Context, opts ...EventsOptionFunc) (stream machineapi.MachineService_EventsClient, err error)
Events implements the proto.OSClient interface.
func (*Client) EventsWatch ¶ added in v0.6.0
func (c *Client) EventsWatch(ctx context.Context, watchFunc func(<-chan Event), opts ...EventsOptionFunc) error
EventsWatch wraps Events by providing more simple interface.
nolint: gocyclo
func (*Client) GetConfigContext ¶ added in v0.6.0
GetConfigContext returns resolved config context.
func (*Client) Interfaces ¶
func (c *Client) Interfaces(ctx context.Context, callOptions ...grpc.CallOption) (resp *networkapi.InterfacesResponse, err error)
Interfaces implements the proto.OSClient interface.
func (*Client) Kubeconfig ¶
Kubeconfig returns K8s client config (kubeconfig).
func (*Client) KubeconfigRaw ¶
KubeconfigRaw returns K8s client config (kubeconfig).
func (*Client) LS ¶
func (c *Client) LS(ctx context.Context, req *machineapi.ListRequest) (stream machineapi.MachineService_ListClient, err error)
LS implements the proto.OSClient interface.
func (*Client) Logs ¶
func (c *Client) Logs(ctx context.Context, namespace string, driver common.ContainerDriver, id string, follow bool, tailLines int32) (stream machineapi.MachineService_LogsClient, err error)
Logs implements the proto.OSClient interface.
func (*Client) Memory ¶
func (c *Client) Memory(ctx context.Context, callOptions ...grpc.CallOption) (resp *machineapi.MemoryResponse, err error)
Memory implements the proto.OSClient interface.
func (*Client) Mounts ¶
func (c *Client) Mounts(ctx context.Context, callOptions ...grpc.CallOption) (resp *machineapi.MountsResponse, err error)
Mounts implements the proto.OSClient interface.
func (*Client) Processes ¶
func (c *Client) Processes(ctx context.Context, callOptions ...grpc.CallOption) (resp *machineapi.ProcessesResponse, err error)
Processes implements the proto.OSClient interface.
func (*Client) Recover ¶ added in v0.5.0
func (c *Client) Recover(ctx context.Context, source machineapi.RecoverRequest_Source) (err error)
Recover implements the proto.OSClient interface.
func (*Client) Restart ¶
func (c *Client) Restart(ctx context.Context, namespace string, driver common.ContainerDriver, id string, callOptions ...grpc.CallOption) (err error)
Restart implements the proto.OSClient interface.
func (*Client) Routes ¶
func (c *Client) Routes(ctx context.Context, callOptions ...grpc.CallOption) (resp *networkapi.RoutesResponse, err error)
Routes implements the networkdproto.NetworkClient interface.
func (*Client) ServiceInfo ¶
func (c *Client) ServiceInfo(ctx context.Context, id string, callOptions ...grpc.CallOption) (services []ServiceInfo, err error)
ServiceInfo returns info about a single service
This is implemented via service list API, as we don't have many services If service with given id is not registered, function returns nil.
func (*Client) ServiceList ¶
func (c *Client) ServiceList(ctx context.Context, callOptions ...grpc.CallOption) (resp *machineapi.ServiceListResponse, err error)
ServiceList returns list of services with their state.
func (*Client) ServiceRestart ¶
func (c *Client) ServiceRestart(ctx context.Context, id string, callOptions ...grpc.CallOption) (resp *machineapi.ServiceRestartResponse, err error)
ServiceRestart restarts a service.
func (*Client) ServiceStart ¶
func (c *Client) ServiceStart(ctx context.Context, id string, callOptions ...grpc.CallOption) (resp *machineapi.ServiceStartResponse, err error)
ServiceStart starts a service.
func (*Client) ServiceStop ¶
func (c *Client) ServiceStop(ctx context.Context, id string, callOptions ...grpc.CallOption) (resp *machineapi.ServiceStopResponse, err error)
ServiceStop stops a service.
func (*Client) Stats ¶
func (c *Client) Stats(ctx context.Context, namespace string, driver common.ContainerDriver, callOptions ...grpc.CallOption) (resp *machineapi.StatsResponse, err error)
Stats implements the proto.OSClient interface.
func (*Client) Time ¶
func (c *Client) Time(ctx context.Context, callOptions ...grpc.CallOption) (resp *timeapi.TimeResponse, err error)
Time returns the time.
func (*Client) TimeCheck ¶
func (c *Client) TimeCheck(ctx context.Context, server string, callOptions ...grpc.CallOption) (resp *timeapi.TimeResponse, err error)
TimeCheck returns the time compared to the specified ntp server.
func (*Client) Upgrade ¶
func (c *Client) Upgrade(ctx context.Context, image string, preserve bool, callOptions ...grpc.CallOption) (resp *machineapi.UpgradeResponse, err error)
Upgrade initiates a Talos upgrade ... and implements the proto.OSClient interface.
func (*Client) Version ¶
func (c *Client) Version(ctx context.Context, callOptions ...grpc.CallOption) (resp *machineapi.VersionResponse, err error)
Version implements the proto.OSClient interface.
type Credentials ¶
type Credentials struct { CA []byte Crt tls.Certificate }
Credentials represents the set of values required to initialize a valid Client.
func CredentialsFromConfigContext ¶ added in v0.5.0
func CredentialsFromConfigContext(context *config.Context) (*Credentials, error)
CredentialsFromConfigContext constructs the client Credentials from the given configuration Context.
func NewClientContextAndCredentialsFromConfig
deprecated
func NewClientContextAndCredentialsFromConfig(p, ctx string) (context *config.Context, creds *Credentials, err error)
NewClientContextAndCredentialsFromConfig initializes Credentials from config file.
Deprecated: use Option-based methods for client creation.
func NewClientContextAndCredentialsFromParsedConfig
deprecated
type EventsOptionFunc ¶ added in v0.6.0
type EventsOptionFunc func(opts *machineapi.EventsRequest)
EventsOptionFunc defines the options for the Events API.
func WithTailDuration ¶ added in v0.6.0
func WithTailDuration(dur time.Duration) EventsOptionFunc
WithTailDuration sets up Watcher to return events with timestamp >= (now - tailDuration).
func WithTailEvents ¶ added in v0.6.0
func WithTailEvents(number int32) EventsOptionFunc
WithTailEvents sets up Events API to return specified number of past events.
If number is negative, all the available past events are returned.
func WithTailID ¶ added in v0.6.0
func WithTailID(id string) EventsOptionFunc
WithTailID sets up Events API to return events with ID > TailID.
type MachineStream ¶
type MachineStream interface { Recv() (*common.Data, error) grpc.ClientStream }
MachineStream is a common interface for streams returned by streaming APIs.
type OptionFunc ¶ added in v0.5.0
OptionFunc sets an option for the creation of the Client.
func WithConfig ¶ added in v0.5.0
func WithConfig(cfg *config.Config) OptionFunc
WithConfig configures the Client with the configuration provided. Additionally use WithContextName to override the default context in the Config.
func WithConfigContext ¶ added in v0.5.0
func WithConfigContext(cfg *config.Context) OptionFunc
WithConfigContext configures the Client with the configuration context provided.
func WithConfigFromFile ¶ added in v0.5.0
func WithConfigFromFile(fn string) OptionFunc
WithConfigFromFile creates a Client with its configuration extracted from the given file. Additionally use WithContextName to select a context other than the default.
func WithContextName ¶ added in v0.5.0
func WithContextName(name string) OptionFunc
WithContextName overrides the default context inside a provided client Config.
func WithDefaultConfig ¶ added in v0.5.0
func WithDefaultConfig() OptionFunc
WithDefaultConfig creates a Client with its configuration sourced from the default config file location. Additionally use WithContextName to select a context other than the default.
func WithEndpoints ¶ added in v0.5.0
func WithEndpoints(endpoints ...string) OptionFunc
WithEndpoints overrides the default endpoints with the provided list.
func WithGRPCDialOptions ¶ added in v0.5.0
func WithGRPCDialOptions(opts ...grpc.DialOption) OptionFunc
WithGRPCDialOptions adds the given grpc.DialOptions to a Client.
func WithTLSConfig ¶ added in v0.5.0
func WithTLSConfig(tlsConfig *tls.Config) OptionFunc
WithTLSConfig overrides the default TLS configuration with the one provided.
func WithUnixSocket ¶ added in v0.6.0
func WithUnixSocket(path string) OptionFunc
WithUnixSocket creates a Client which connects to apid over local file socket.
This option disables config parsing and TLS.
Connection over unix socket is only used within the Talos node.
type Options ¶ added in v0.5.0
type Options struct {
// contains filtered or unexported fields
}
Options contains the set of client configuration options.
type ServiceInfo ¶
type ServiceInfo struct { Metadata *common.Metadata Service *machineapi.ServiceInfo }
ServiceInfo provides info about a service and node metadata.