Documentation ¶
Index ¶
- type CurlOption
- type Option
- type PingOption
- type TailscaleInContainer
- func (t *TailscaleInContainer) Curl(url string, opts ...CurlOption) (string, error)
- func (t *TailscaleInContainer) Execute(command []string) (string, string, error)
- func (t *TailscaleInContainer) FQDN() (string, error)
- func (t *TailscaleInContainer) Hostname() string
- func (t *TailscaleInContainer) ID() string
- func (t *TailscaleInContainer) IPs() ([]netip.Addr, error)
- func (t *TailscaleInContainer) Logout() error
- func (t *TailscaleInContainer) Ping(hostnameOrIP string, opts ...PingOption) error
- func (t *TailscaleInContainer) Shutdown() error
- func (t *TailscaleInContainer) Status() (*ipnstate.Status, error)
- func (t *TailscaleInContainer) Up(loginServer, authKey string) error
- func (t *TailscaleInContainer) UpWithLoginURL(loginServer string) (*url.URL, error)
- func (t *TailscaleInContainer) Version() string
- func (t *TailscaleInContainer) WaitForLogout() error
- func (t *TailscaleInContainer) WaitForPeers(expected int) error
- func (t *TailscaleInContainer) WaitForReady() error
- func (t *TailscaleInContainer) WriteFile(path string, data []byte) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CurlOption ¶
type CurlOption = func(args *curlArgs)
CurlOption repreent optional settings that can be given to curl another host.
func WithCurlConnectionTimeout ¶
func WithCurlConnectionTimeout(timeout time.Duration) CurlOption
WithCurlConnectionTimeout sets the timeout for each connection started by curl.
func WithCurlMaxTime ¶
func WithCurlMaxTime(t time.Duration) CurlOption
WithCurlMaxTime sets the max time for a transfer for each connection started by curl.
func WithCurlRetry ¶
func WithCurlRetry(ret int) CurlOption
WithCurlRetry sets the number of retries a connection is attempted by curl.
type Option ¶
type Option = func(c *TailscaleInContainer)
Option represent optional settings that can be given to a Tailscale instance.
func WithDockerEntrypoint ¶
WithDockerEntrypoint allows the docker entrypoint of the container to be overridden. This is a dangerous option which can make the container not work as intended as a typo might prevent tailscaled and other processes from starting. Use with caution.
func WithDockerWorkdir ¶
WithDockerWorkdir allows the docker working directory to be set.
func WithHeadscaleName ¶
WithHeadscaleName set the name of the headscale instance, mostly useful in combination with TLS and WithHeadscaleTLS.
func WithHeadscaleTLS ¶
WithHeadscaleTLS takes the certificate of the Headscale instance and adds it to the trusted surtificate of the Tailscale container.
func WithOrCreateNetwork ¶
func WithOrCreateNetwork(network *dockertest.Network) Option
WithOrCreateNetwork sets the Docker container network to use with the Tailscale instance, if the parameter is nil, a new network, isolating the TailscaleClient, will be created. If a network is passed, the Tailscale instance will join the given network.
type PingOption ¶
type PingOption = func(args *pingArgs)
PingOption repreent optional settings that can be given to ping another host.
func WithPingCount ¶
func WithPingCount(count int) PingOption
WithPingCount sets the count of pings to attempt.
func WithPingTimeout ¶
func WithPingTimeout(timeout time.Duration) PingOption
WithPingTimeout sets the timeout for the ping command.
func WithPingUntilDirect ¶
func WithPingUntilDirect(direct bool) PingOption
WithPingUntilDirect decides if the ping should only succeed if a direct connection is established or if successful DERP ping is sufficient.
type TailscaleInContainer ¶
type TailscaleInContainer struct {
// contains filtered or unexported fields
}
TailscaleInContainer is an implementation of TailscaleClient which sets up a Tailscale instance inside a container.
func New ¶
func New( pool *dockertest.Pool, version string, network *dockertest.Network, opts ...Option, ) (*TailscaleInContainer, error)
New returns a new TailscaleInContainer instance.
func (*TailscaleInContainer) Curl ¶
func (t *TailscaleInContainer) Curl(url string, opts ...CurlOption) (string, error)
Curl executes the Tailscale curl command and curls a hostname or IP. It accepts a series of CurlOption.
func (*TailscaleInContainer) Execute ¶
func (t *TailscaleInContainer) Execute( command []string, ) (string, string, error)
Execute runs a command inside the Tailscale container and returns the result of stdout as a string.
func (*TailscaleInContainer) FQDN ¶
func (t *TailscaleInContainer) FQDN() (string, error)
FQDN returns the FQDN as a string of the Tailscale instance.
func (*TailscaleInContainer) Hostname ¶
func (t *TailscaleInContainer) Hostname() string
Hostname returns the hostname of the Tailscale instance.
func (*TailscaleInContainer) ID ¶
func (t *TailscaleInContainer) ID() string
ID returns the Docker container ID of the TailscaleInContainer instance.
func (*TailscaleInContainer) IPs ¶
func (t *TailscaleInContainer) IPs() ([]netip.Addr, error)
IPs returns the netip.Addr of the Tailscale instance.
func (*TailscaleInContainer) Logout ¶
func (t *TailscaleInContainer) Logout() error
Logout runs the logout routine on the given Tailscale instance.
func (*TailscaleInContainer) Ping ¶
func (t *TailscaleInContainer) Ping(hostnameOrIP string, opts ...PingOption) error
Ping executes the Tailscale ping command and pings a hostname or IP. It accepts a series of PingOption. TODO(kradalby): Make multiping, go routine magic.
func (*TailscaleInContainer) Shutdown ¶
func (t *TailscaleInContainer) Shutdown() error
Shutdown stops and cleans up the Tailscale container.
func (*TailscaleInContainer) Status ¶
func (t *TailscaleInContainer) Status() (*ipnstate.Status, error)
Status returns the ipnstate.Status of the Tailscale instance.
func (*TailscaleInContainer) Up ¶
func (t *TailscaleInContainer) Up( loginServer, authKey string, ) error
Up runs the login routine on the given Tailscale instance. This login mechanism uses the authorised key for authentication.
func (*TailscaleInContainer) UpWithLoginURL ¶
func (t *TailscaleInContainer) UpWithLoginURL( loginServer string, ) (*url.URL, error)
Up runs the login routine on the given Tailscale instance. This login mechanism uses web + command line flow for authentication.
func (*TailscaleInContainer) Version ¶
func (t *TailscaleInContainer) Version() string
Version returns the running Tailscale version of the instance.
func (*TailscaleInContainer) WaitForLogout ¶
func (t *TailscaleInContainer) WaitForLogout() error
WaitForLogout blocks until the Tailscale instance has logged out.
func (*TailscaleInContainer) WaitForPeers ¶
func (t *TailscaleInContainer) WaitForPeers(expected int) error
WaitForPeers blocks until N number of peers is present in the Peer list of the Tailscale instance.
func (*TailscaleInContainer) WaitForReady ¶
func (t *TailscaleInContainer) WaitForReady() error
WaitForReady blocks until the Tailscale (tailscaled) instance is ready to login or be used.