client

package
v2.1.3-rc.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ConnectorSocketName is the path used when communicating to the connector process
	ConnectorSocketName = "/tmp/telepresence-connector.socket"

	// DaemonSocketName is the path used when communicating to the daemon process
	DaemonSocketName = "/var/run/telepresence-daemon.socket"
)
View Source
const (
	// APIVersion is the API version of the daemon and connector API
	APIVersion = 3
)

Variables

This section is empty.

Functions

func CheckTimeout added in v2.1.2

func CheckTimeout(c context.Context, which *time.Duration, err error) error

func DialSocket

func DialSocket(c context.Context, socketName string) (*grpc.ClientConn, error)

DialSocket dials the given unix socket and returns the resulting connection

func DisplayVersion

func DisplayVersion() string

DisplayVersion returns a printable version for `telepresence`

func GetExe

func GetExe() string

GetExe returns the name of the running executable

func Retry

func Retry(c context.Context, text string, f func(context.Context) error, durations ...time.Duration) error

Retry will run the given function repeatedly with an increasing delay until it returns without error.

The function takes 0 to 3 durations with the following meaning

Delay - initial delay, i.e. the delay between the first and the second call.
MaxDelay - maximum delay between calling the functions (delay will never grow beyond this value)
MaxTime - maximum time before giving up.

func RunError

func RunError(err error) error

RunError checks if the given err is a *exit.ExitError, and if so, extracts Stderr and the ExitCode from it.

func Semver

func Semver() semver.Version

func SetExe

func SetExe(executable string)

SetExe defines the name of the executable (for testing purposes only)

func SocketExists

func SocketExists(path string) bool

SocketExists returns true if a socket is found at the given path

func SocketURL

func SocketURL(socket string) string

SocketURL returns the URL that corresponds to the given unix socket filesystem path.

func Version

func Version() string

Version returns the version of this executable.

func WaitUntilSocketAppears

func WaitUntilSocketAppears(name, path string, ttw time.Duration) (err error)

WaitUntilSocketAppears waits until the socket at the given path comes into existence and returns when that happens. The wait will be max ttw (time to wait) long. An error is returned if that time is exceeded before the socket is removed.

func WaitUntilSocketVanishes

func WaitUntilSocketVanishes(name, path string, ttw time.Duration) (err error)

WaitUntilSocketVanishes waits until the socket at the given path is removed and returns when that happens. The wait will be max ttw (time to wait) long. An error is returned if that time is exceeded before the socket is removed.

func WithEnsuredState

func WithEnsuredState(r EnsuredState, retain bool, f func() error) (err error)

WithEnsuredState ensures the given state, calls the function, and then, if the state was activated, it is deactivated unless the retain flag is true.

Types

type Config added in v2.1.2

type Config struct {
	Timeouts Timeouts `json:"timeouts,omitempty"`
}

func GetConfig added in v2.1.2

func GetConfig(c context.Context) *Config

GetConfig returns the Telepresence configuration as stored in filelocation.AppUserConfigDir or filelocation.AppSystemConfigDirs

func (*Config) UnmarshalYAML added in v2.1.2

func (c *Config) UnmarshalYAML(node *yaml.Node) (err error)

type EnsuredState

type EnsuredState interface {
	// EnsureState will check if the state is active and activate it if that is not the case.
	// The boolean return value indicates if the state was activated or not.
	EnsureState() (bool, error)

	// Deactivate the state (i.e. quit, remove, disconnect)
	DeactivateState() error
}

An EnsuredState represents some state that is needed in order for a function to execute.

type Env

type Env struct {
	// I'd like to set TELEPRESENCE_LOGIN_DOMAIN,default=auth.datawire.io, but
	// sethvargo/go-envconfig doesn't support filling in the default for our later references to
	// it in following settings, so we have to do the hack with maybeSetDefault below.  *sigh* I
	// guess I'm just spoiled by apro/cmd/amb-sidecar/types/internal/envconfig.
	LoginDomain        string `env:"TELEPRESENCE_LOGIN_DOMAIN,required"`
	LoginAuthURL       string `env:"TELEPRESENCE_LOGIN_AUTH_URL,default=https://${TELEPRESENCE_LOGIN_DOMAIN}/auth"`
	LoginTokenURL      string `env:"TELEPRESENCE_LOGIN_TOKEN_URL,default=https://${TELEPRESENCE_LOGIN_DOMAIN}/token"`
	LoginCompletionURL string `env:"TELEPRESENCE_LOGIN_COMPLETION_URL,default=https://${TELEPRESENCE_LOGIN_DOMAIN}/completion"`
	LoginClientID      string `env:"TELEPRESENCE_LOGIN_CLIENT_ID,default=telepresence-cli"`
	UserInfoURL        string `env:"TELEPRESENCE_USER_INFO_URL,default=https://${TELEPRESENCE_LOGIN_DOMAIN}/api/userinfo"`

	Registry   string `env:"TELEPRESENCE_REGISTRY,default=docker.io/datawire"`
	AgentImage string `env:"TELEPRESENCE_AGENT_IMAGE,default="`

	SystemAHost string `env:"SYSTEMA_HOST,default=app.getambassador.io"`
	SystemAPort string `env:"SYSTEMA_PORT,default=443"`
}

func LoadEnv

func LoadEnv(ctx context.Context) (Env, error)

func (Env) Get

func (env Env) Get(key string) string

type Scout

type Scout struct {
	Reporter *metriton.Reporter
	// contains filtered or unexported fields
}

Scout is a Metriton reported

func NewScout

func NewScout(ctx context.Context, mode string) (s *Scout)

NewScout creates a new initialized Scout instance that can be used to send telepresence reports to Metriton

func (*Scout) Report

func (s *Scout) Report(ctx context.Context, action string, meta ...ScoutMeta) error

Report constructs and sends a report. It includes the fixed (growing) set of metadata in the Scout structure and the pairs passed as arguments to this call. It also includes and increments the index, which can be used to determine the correct order of reported events for this installation attempt (correlated by the trace_id set at the start).

func (*Scout) SetMetadatum

func (s *Scout) SetMetadatum(key string, value interface{})

SetMetadatum associates the given key with the given value in the metadata of this instance. It's an error if the key already exists.

type ScoutMeta

type ScoutMeta struct {
	Key   string
	Value interface{}
}

ScoutMeta is a key/value association used when reporting

type Timeouts added in v2.1.2

type Timeouts struct {
	// AgentInstall is how long to wait for an agent to be installed (i.e. apply of service and deploy manifests)
	AgentInstall time.Duration `json:"agentInstall,omitempty"`
	// Apply is how long to wait for a k8s manifest to be applied
	Apply time.Duration `json:"apply,omitempty"`
	// ClusterConnect is the maximum time to wait for a connection to the cluster to be established
	ClusterConnect time.Duration `json:"clusterConnect,omitempty"`
	// Intercept is the time to wait for an intercept after the agents has been installed
	Intercept time.Duration `json:"intercept,omitempty"`
	// ProxyDial is how long to wait for the proxy to establish an outbound connection
	ProxyDial time.Duration `json:"proxyDial,omitempty"`
	// TrafficManagerConnect is how long to wait for the traffic-manager API to connect
	TrafficManagerAPI time.Duration `json:"trafficManagerAPI,omitempty"`
	// TrafficManagerConnect is how long to wait for the initial port-forwards to the traffic-manager
	TrafficManagerConnect time.Duration `json:"trafficManagerConnect,omitempty"`
}

func (*Timeouts) UnmarshalYAML added in v2.1.2

func (d *Timeouts) UnmarshalYAML(node *yaml.Node) (err error)

UnmarshalYAML caters for the unfortunate fact that time.Duration doesn't do YAML or JSON at all.

Directories

Path Synopsis
cli
dns
nat
tun
tun_linux.go: Open a Tunnel (L3 virtual interface) using the Universal TUN/TAP device driver.
tun_linux.go: Open a Tunnel (L3 virtual interface) using the Universal TUN/TAP device driver.

Jump to

Keyboard shortcuts

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