daemon

package
v2.27.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const InfoFileName = "daemon.json"

Variables

View Source
var ErrNoRootDaemon = errors.New("telepresence root daemon is not running")
View Source
var ErrNoUserDaemon = errors.New("telepresence user daemon is not running")
View Source
var NewUserClientFunc = NewUserClient //nolint:gochecknoglobals // extension point

Functions

func DialRootDaemon added in v2.26.0

func DialRootDaemon(ctx context.Context, waitForConnect bool) (conn *grpc.ClientConn, err error)

func DialUserDaemon added in v2.26.0

func DialUserDaemon(ctx context.Context, waitForConnect bool) (conn *grpc.ClientConn, err error)

func GetCommandKubeConfig added in v2.21.0

func GetCommandKubeConfig(cmd *cobra.Command) (*k8s.Kubeconfig, error)

GetCommandKubeConfig will return the fully resolved client.Kubeconfig for the given command.

func GetKubeStartingConfig added in v2.16.0

func GetKubeStartingConfig(cmd *cobra.Command) (*api.Config, error)

func GetRootClientConfig added in v2.23.0

func GetRootClientConfig(ds *daemon.DaemonStatus) (client.Config, error)

func WithDefaultRequest

func WithDefaultRequest(cmd *cobra.Command) (context.Context, error)

func WithRequest added in v2.16.0

func WithRequest(ctx context.Context, cr *Request) context.Context

func WithSession

func WithSession(ctx context.Context, s *Session) context.Context

func WithUserClient

func WithUserClient(ctx context.Context, ud UserClient) context.Context

Types

type CobraRequest added in v2.19.0

type CobraRequest struct {
	Request
	// contains filtered or unexported fields
}

func InitRequest

func InitRequest(cmd *cobra.Command) *CobraRequest

InitRequest adds the networking flags and Kubernetes flags to the given command and returns a Request and a FlagSet with the Kubernetes flags. The FlagSet is returned here so that a map of flags that gets modified can be extracted using FlagMap once the flag parsing has completed.

func (*CobraRequest) CommitFlags added in v2.19.0

func (cr *CobraRequest) CommitFlags(cmd *cobra.Command) error

func (*CobraRequest) GetAllNamespaces added in v2.19.0

func (cr *CobraRequest) GetAllNamespaces(cmd *cobra.Command) ([]string, error)

func (*CobraRequest) GetConfig added in v2.19.0

func (cr *CobraRequest) GetConfig(cmd *cobra.Command) (*api.Config, error)

type Identifier added in v2.16.0

type Identifier struct {
	Name          string
	KubeContext   string
	Namespace     string
	Containerized bool
}

func IdentifierFromFlags added in v2.16.0

func IdentifierFromFlags(ctx context.Context, name string, flagMap map[string]string, kubeConfigData []byte, containerized bool) (*Identifier, error)

IdentifierFromFlags returns a unique name created from the name of the current context and the active namespace denoted by the given flagMap.

func NewIdentifier added in v2.16.0

func NewIdentifier(name, contextName, namespace string, containerized bool) *Identifier

func (*Identifier) ContainerName added in v2.16.0

func (id *Identifier) ContainerName() string

func (*Identifier) InfoFileName added in v2.16.0

func (id *Identifier) InfoFileName() string

func (*Identifier) String added in v2.16.0

func (id *Identifier) String() string

type Info added in v2.16.0

type Info struct {
	Name         string     `json:"name,omitempty"`
	KubeContext  string     `json:"kube_context,omitempty"`
	Namespace    string     `json:"namespace,omitempty"`
	DaemonPort   uint16     `json:"daemon_port,omitempty"`
	ExposedPorts []string   `json:"exposed_ports,omitempty"`
	Hostname     string     `json:"hostname,omitempty"`
	ContainerPID int        `json:"container_pid,omitempty"`
	ContainerIP  netip.Addr `json:"container_ip,omitempty"`
	ContainerID  string     `json:"container_id,omitempty"`
	ComposeFile  string     `json:"compose_file,omitempty"`
}

func (*Info) DaemonID added in v2.16.0

func (info *Info) DaemonID() *Identifier

func (*Info) InDocker added in v2.16.0

func (info *Info) InDocker() bool

func (*Info) SetConnectionInfo added in v2.23.0

func (info *Info) SetConnectionInfo(name string, clusterContext string, namespace string)

type InfoLoader added in v2.26.0

type InfoLoader[T TCPInfo] struct {
	// contains filtered or unexported fields
}

func NewRootInfoLoader added in v2.26.0

func NewRootInfoLoader(ctx context.Context, managed bool) *InfoLoader[RootInfo]

func NewUserInfoLoader added in v2.26.0

func NewUserInfoLoader(ctx context.Context) *InfoLoader[Info]

func (*InfoLoader[T]) CancelWhenRmFromCache added in v2.26.0

func (il *InfoLoader[T]) CancelWhenRmFromCache(cancel context.CancelFunc, filename string) error

CancelWhenRmFromCache watches for the file to be removed from the cache, then calls cancel.

func (*InfoLoader[T]) DeleteAllInfos added in v2.26.0

func (il *InfoLoader[T]) DeleteAllInfos() error

func (*InfoLoader[T]) DeleteInfo added in v2.26.0

func (il *InfoLoader[T]) DeleteInfo(file string) error

func (*InfoLoader[T]) DialDaemon added in v2.26.0

func (il *InfoLoader[T]) DialDaemon(ctx context.Context, waitForConnect bool) (conn *grpc.ClientConn, err error)

func (*InfoLoader[T]) InfoExists added in v2.26.0

func (il *InfoLoader[T]) InfoExists(file string) (bool, error)

func (*InfoLoader[T]) KeepInfoAlive added in v2.26.0

func (il *InfoLoader[T]) KeepInfoAlive(file string) error

KeepInfoAlive updates the access and modification times of the given file periodically so that it never gets older than keepAliveInterval. This means that any file with a modification time older than the current time minus three keepAliveIntervals can be considered stale and should be removed.

The alive-poll ends, and the file is deleted when the context is canceled.

func (*InfoLoader[T]) LoadInfo added in v2.26.0

func (il *InfoLoader[T]) LoadInfo(file string) (*T, error)

func (*InfoLoader[T]) LoadInfos added in v2.26.0

func (il *InfoLoader[T]) LoadInfos() ([]*T, error)

func (*InfoLoader[T]) LoadMatchingInfo added in v2.26.0

func (il *InfoLoader[T]) LoadMatchingInfo(match *regexp.Regexp) (*T, error)

LoadMatchingInfo loads the daemon info matching the given regexp or returns an error if there is none or more than one.

func (*InfoLoader[T]) SaveInfo added in v2.26.0

func (il *InfoLoader[T]) SaveInfo(object *T, file string) error

func (*InfoLoader[T]) WaitUntilAllVanishes added in v2.26.0

func (il *InfoLoader[T]) WaitUntilAllVanishes(ttw time.Duration) error

func (*InfoLoader[T]) WatchInfos added in v2.26.0

func (il *InfoLoader[T]) WatchInfos(onChange func(context.Context) error, files ...string) error

type InfoMatchError added in v2.16.0

type InfoMatchError string

func (InfoMatchError) Error added in v2.16.0

func (i InfoMatchError) Error() string

type MultipleDaemonsError added in v2.18.0

type MultipleDaemonsError []*Info //nolint:errname // Don't want a plural name just because the type is a slice

func (MultipleDaemonsError) Error added in v2.18.0

func (m MultipleDaemonsError) Error() string

type Request

type Request struct {
	*connector.ConnectRequest

	// If set, then use a containerized daemon for the connection.
	Docker bool

	// Ports exposed by a containerized daemon. Only valid when Docker == true
	ExposedPorts []string

	// Hostname used by a containerized daemon. Only valid when Docker == true
	Hostname string

	// Match expression to use when finding an existing connection by name
	Use *regexp.Regexp

	// Request is created on-demand, not by InitRequest
	Implicit bool

	UserDaemonProfilingPort uint16
	RootDaemonProfilingPort uint16

	// LocalReroutes maps ports on localhost to remote ports.
	LocalReroutes []string

	// RemoteReroutes uses the VIF to reroute remote host ports.
	RemoteReroutes []string

	// Aliases by which this daemon can be referenced (added to the telepresence network).
	NetworkAliases []string
	// contains filtered or unexported fields
}

func GetRequest

func GetRequest(ctx context.Context) *Request

func MustGetRequest added in v2.26.0

func MustGetRequest(ctx context.Context) *Request

func NewDefaultRequest added in v2.16.0

func NewDefaultRequest() *Request

func (*Request) Clone added in v2.23.0

func (cr *Request) Clone() *Request

func (*Request) Commit added in v2.19.0

func (cr *Request) Commit(ctx context.Context) (context.Context, error)

type RootInfo added in v2.26.0

type RootInfo struct {
	DaemonPort uint16 `json:"daemon_port,omitempty"`
}

func LoadRootServiceInfo added in v2.26.0

func LoadRootServiceInfo(ctx context.Context) (*RootInfo, error)

type Session

type Session struct {
	UserClient
	Info    *connector.ConnectInfo
	Started bool
}

func GetSession

func GetSession(ctx context.Context) *Session

func MustGetSession added in v2.24.1

func MustGetSession(ctx context.Context) *Session

func (*Session) GetAgentConfig added in v2.21.0

func (s *Session) GetAgentConfig(ctx context.Context, workload string) (*agentconfig.Sidecar, error)

func (*Session) GetRootClientConfig added in v2.23.0

func (s *Session) GetRootClientConfig() (client.Config, error)

type TCPInfo added in v2.26.0

type TCPInfo interface {
	RootInfo | Info
}

type UserClient

type UserClient interface {
	connector.ConnectorClient
	io.Closer
	Conn() *grpc.ClientConn
	Containerized() bool
	DaemonPort() int
	DaemonID() *Identifier
	Executable() string
	DaemonInfo() *Info
	Lookup(ctx context.Context, addr string) (netip.Addr, error)
	Name() string
	Semver() semver.Version
	AddHandler(ctx context.Context, id string, cmd *exec.Cmd, containerName string) error
	SetConnectionInfo(name string, clusterContext string, namespace string)
}

func GetUserClient

func GetUserClient(ctx context.Context) UserClient

func MustGetUserClient added in v2.24.1

func MustGetUserClient(ctx context.Context) UserClient

func NewUserClient added in v2.19.1

func NewUserClient(conn *grpc.ClientConn, info *Info, version semver.Version, name string, executable string) UserClient

Jump to

Keyboard shortcuts

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