client

package
v0.0.0-...-67f9e1d Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2024 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddClusterMember

func AddClusterMember(ctx context.Context, c *Client, args types.ClusterMember) (*internalTypes.TokenResponse, error)

AddClusterMember records a new cluster member in the trust store of each current cluster member.

func AddTrustStoreEntry

func AddTrustStoreEntry(ctx context.Context, c *Client, args types.ClusterMemberLocal) error

AddTrustStoreEntry adds a new record to the truststore on all cluster members.

func DeleteTrustStoreEntry

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

DeleteTrustStoreEntry deletes the record corresponding to the given cluster member from the trust store.

func GetSQL

func GetSQL(ctx context.Context, c *Client, schema bool) (*types.SQLDump, error)

GetSQL gets a SQL dump of the database.

func IsForwardedRequest

func IsForwardedRequest(r *http.Request) bool

IsForwardedRequest determines if this request has been forwarded from another cluster member.

func PostSQL

func PostSQL(ctx context.Context, c *Client, query types.SQLQuery) (*types.SQLBatch, error)

PostSQL executes a SQL query against the database.

func ResetClusterMember

func ResetClusterMember(ctx context.Context, c *Client, name string, force bool) error

ResetClusterMember clears the state directory of the cluster member, and re-execs its daemon.

func RunNewMemberHook

func RunNewMemberHook(ctx context.Context, c *Client, config internalTypes.HookNewMemberOptions) error

RunNewMemberHook executes the OnNewMember hook with the given configuration on the cluster member targeted by this client.

func RunOnDaemonConfigUpdateHook

func RunOnDaemonConfigUpdateHook(ctx context.Context, c *Client, config *types.DaemonConfig) error

RunOnDaemonConfigUpdateHook executes the OnDaemonConfigUpdate hook with the given configuration on the cluster member targeted by this client.

func RunPostRemoveHook

func RunPostRemoveHook(ctx context.Context, c *Client, config internalTypes.HookRemoveMemberOptions) error

RunPostRemoveHook executes the PostRemove hook with the given configuration on the cluster member targeted by this client.

func RunPreRemoveHook

func RunPreRemoveHook(ctx context.Context, c *Client, config internalTypes.HookRemoveMemberOptions) error

RunPreRemoveHook executes the PreRemove hook with the given configuration on the cluster member targeted by this client.

func TLSClientConfig

func TLSClientConfig(clientCert *shared.CertInfo, remoteCert *x509.Certificate) (*tls.Config, error)

TLSClientConfig returns a TLS configuration suitable for establishing horizontal and vertical connections. clientCert contains the private key pair for the client. remoteCert is the public key of the server we are connecting to.

Types

type Client

type Client struct {
	*http.Client
	// contains filtered or unexported fields
}

Client is a rest client for the daemon.

func New

func New(url api.URL, clientCert *shared.CertInfo, remoteCert *x509.Certificate, forwarding bool) (*Client, error)

New returns a new client configured with the given url and certificates.

func (*Client) CheckReady

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

CheckReady returns once the daemon has signalled to the ready channel that it is done setting up.

func (*Client) ControlDaemon

func (c *Client) ControlDaemon(ctx context.Context, args types.Control) error

ControlDaemon posts control data to the daemon.

func (*Client) DeleteClusterMember

func (c *Client) DeleteClusterMember(ctx context.Context, name string, force bool) error

DeleteClusterMember deletes the cluster member with the given name.

func (*Client) DeleteTokenRecord

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

DeleteTokenRecord deletes the toekn record.

func (*Client) GetClusterMembers

func (c *Client) GetClusterMembers(ctx context.Context) ([]types.ClusterMember, error)

GetClusterMembers returns the database record of cluster members.

func (*Client) GetTokenRecords

func (c *Client) GetTokenRecords(ctx context.Context) ([]types.TokenRecord, error)

GetTokenRecords returns the token records.

func (*Client) MakeRequest

func (c *Client) MakeRequest(r *http.Request) (*api.Response, error)

MakeRequest performs a request and parses the response into an api.Response.

func (*Client) QueryStruct

func (c *Client) QueryStruct(ctx context.Context, method string, endpointType types.EndpointPrefix, endpoint *api.URL, data any, target any) error

QueryStruct sends a request of the specified method to the provided endpoint (optional) on the API matching the endpointType. The response gets unpacked into the target struct. POST requests can optionally provide raw data to be sent through.

The final URL is that provided as the endpoint combined with the applicable prefix for the endpointType and the scheme and host from the client.

func (*Client) RequestToken

func (c *Client) RequestToken(ctx context.Context, name string, expireAfter time.Duration) (string, error)

RequestToken requests a join token with the given name.

func (*Client) SetClusterNotification

func (c *Client) SetClusterNotification()

SetClusterNotification sets the client's proxy to apply the forwarding headers to a request.

func (*Client) ShutdownDaemon

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

ShutdownDaemon begins the daemon shutdown sequence.

func (*Client) URL

func (c *Client) URL() api.URL

URL returns the address used for the client.

func (*Client) UpdateCertificate

func (c *Client) UpdateCertificate(ctx context.Context, name types.CertificateName, args types.KeyPair) error

UpdateCertificate sets a new keypair and CA.

func (*Client) UpdateServers

func (c *Client) UpdateServers(ctx context.Context, config map[string]apiTypes.ServerConfig) error

UpdateServers updates the additional servers config.

func (*Client) UseTarget

func (c *Client) UseTarget(name string) *Client

UseTarget returns a new client with the query "?target=name" set.

Jump to

Keyboard shortcuts

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