hsic

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: BSD-3-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultConfigEnv

func DefaultConfigEnv() map[string]string

func DefaultConfigYAML

func DefaultConfigYAML() string

TODO: Reuse the actual configuration object above. Deprecated: use env function instead as it is easier to override.

func MinimumConfigYAML

func MinimumConfigYAML() string

Types

type HeadscaleInContainer

type HeadscaleInContainer struct {
	// contains filtered or unexported fields
}

HeadscaleInContainer is an implementation of ControlServer which sets up a Headscale instance inside a container.

func New

func New(
	pool *dockertest.Pool,
	network *dockertest.Network,
	opts ...Option,
) (*HeadscaleInContainer, error)

New returns a new HeadscaleInContainer instance.

func (*HeadscaleInContainer) CreateAuthKey

func (t *HeadscaleInContainer) CreateAuthKey(
	user string,
	reusable bool,
	ephemeral bool,
) (*v1.PreAuthKey, error)

CreateAuthKey creates a new "authorisation key" for a User that can be used to authorise a TailscaleClient with the Headscale instance.

func (*HeadscaleInContainer) CreateUser

func (t *HeadscaleInContainer) CreateUser(
	user string,
) error

CreateUser adds a new user to the Headscale instance.

func (*HeadscaleInContainer) Execute

func (t *HeadscaleInContainer) Execute(
	command []string,
) (string, error)

Execute runs a command inside the Headscale container and returns the result of stdout as a string.

func (*HeadscaleInContainer) GetCert

func (t *HeadscaleInContainer) GetCert() []byte

GetCert returns the public certificate of the HeadscaleInContainer.

func (*HeadscaleInContainer) GetEndpoint

func (t *HeadscaleInContainer) GetEndpoint() string

GetEndpoint returns the Headscale endpoint for the HeadscaleInContainer.

func (*HeadscaleInContainer) GetHealthEndpoint

func (t *HeadscaleInContainer) GetHealthEndpoint() string

GetHealthEndpoint returns a health endpoint for the HeadscaleInContainer instance.

func (*HeadscaleInContainer) GetHostname

func (t *HeadscaleInContainer) GetHostname() string

GetHostname returns the hostname of the HeadscaleInContainer.

func (*HeadscaleInContainer) GetIP

func (t *HeadscaleInContainer) GetIP() string

GetIP returns the docker container IP as a string.

func (*HeadscaleInContainer) GetPort

func (t *HeadscaleInContainer) GetPort() string

GetPort returns the docker container port as a string.

func (*HeadscaleInContainer) ListMachinesInUser

func (t *HeadscaleInContainer) ListMachinesInUser(
	user string,
) ([]*v1.Machine, error)

ListMachinesInUser list the TailscaleClients (Machine, Headscale internal representation) associated with a user.

func (*HeadscaleInContainer) SaveLog

func (t *HeadscaleInContainer) SaveLog(path string) error

SaveLog saves the current stdout log of the container to a path on the host system.

func (*HeadscaleInContainer) Shutdown

func (t *HeadscaleInContainer) Shutdown() error

Shutdown stops and cleans up the Headscale container.

func (*HeadscaleInContainer) WaitForReady

func (t *HeadscaleInContainer) WaitForReady() error

WaitForReady blocks until the Headscale instance is ready to serve clients.

func (*HeadscaleInContainer) WriteFile

func (t *HeadscaleInContainer) WriteFile(path string, data []byte) error

WriteFile save file inside the Headscale container.

type Option

type Option = func(c *HeadscaleInContainer)

Option represent optional settings that can be given to a Headscale instance.

func WithACLPolicy

func WithACLPolicy(acl *headscale.ACLPolicy) Option

WithACLPolicy adds a headscale.ACLPolicy policy to the HeadscaleInContainer instance.

func WithConfigEnv

func WithConfigEnv(configEnv map[string]string) Option

WithConfigEnv takes a map of environment variables that can be used to override Headscale configuration.

func WithFileInContainer

func WithFileInContainer(path string, contents []byte) Option

WithFileInContainer adds a file to the container at the given path.

func WithHostnameAsServerURL

func WithHostnameAsServerURL() Option

WithHostnameAsServerURL sets the Headscale ServerURL based on the Hostname.

func WithPort

func WithPort(port int) Option

WithPort sets the port on where to run Headscale.

func WithTLS

func WithTLS() Option

WithTLS creates certificates and enables HTTPS.

func WithTestName

func WithTestName(testName string) Option

WithTestName sets a name for the test, this will be reflected in the Docker container name.

Jump to

Keyboard shortcuts

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