daemon

package
v2.21.1 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewUserClientFunc = NewUserClient //nolint:gochecknoglobals // extension point

Functions

func CancelWhenRmFromCache added in v2.16.0

func CancelWhenRmFromCache(ctx context.Context, cancel context.CancelFunc, filename string) error

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

func DeleteAllInfos added in v2.16.0

func DeleteAllInfos(ctx context.Context) error

func DeleteInfo added in v2.16.0

func DeleteInfo(ctx context.Context, file string) error

func GetCommandKubeConfig added in v2.21.0

func GetCommandKubeConfig(cmd *cobra.Command) (context.Context, *client.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 InfoExists added in v2.16.0

func InfoExists(ctx context.Context, file string) (bool, error)

func KeepInfoAlive added in v2.16.0

func KeepInfoAlive(ctx context.Context, file string) error

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

The alive poll ends and the Info is deleted when the context is cancelled.

func SaveInfo added in v2.16.0

func SaveInfo(ctx context.Context, object *Info, file string) error

func WaitUntilAllVanishes added in v2.16.0

func WaitUntilAllVanishes(ctx context.Context, ttw time.Duration) error

func WatchInfos added in v2.16.0

func WatchInfos(ctx context.Context, onChange func(context.Context) error, files ...string) error

func WithDefaultRequest

func WithDefaultRequest(ctx context.Context, 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, error)

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 {
	Options      map[string]string `json:"options,omitempty"`
	InDocker     bool              `json:"in_docker,omitempty"`
	Name         string            `json:"name,omitempty"`
	KubeContext  string            `json:"kube_context,omitempty"`
	Namespace    string            `json:"namespace,omitempty"`
	DaemonPort   int               `json:"daemon_port,omitempty"`
	ExposedPorts []string          `json:"exposed_ports,omitempty"`
	Hostname     string            `json:"hostname,omitempty"`
}

func LoadInfo added in v2.16.0

func LoadInfo(ctx context.Context, file string) (*Info, error)

func LoadInfos added in v2.16.0

func LoadInfos(ctx context.Context) ([]*Info, error)

func LoadMatchingInfo added in v2.16.0

func LoadMatchingInfo(ctx context.Context, match *regexp.Regexp) (*Info, error)

func (*Info) DaemonID added in v2.16.0

func (info *Info) DaemonID() *Identifier

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
	// contains filtered or unexported fields
}

func GetRequest

func GetRequest(ctx context.Context) *Request

func NewDefaultRequest added in v2.16.0

func NewDefaultRequest() *Request

func (*Request) Commit added in v2.19.0

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

type Session

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

func GetSession

func GetSession(ctx context.Context) *Session

func (*Session) GetAgentConfig added in v2.21.0

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

type UserClient

type UserClient interface {
	connector.ConnectorClient
	io.Closer
	Conn() *grpc.ClientConn
	Containerized() bool
	DaemonPort() int
	DaemonID() *Identifier
	Executable() string
	Name() string
	Semver() semver.Version
	SetDaemonID(*Identifier)
	AddHandler(ctx context.Context, id string, cmd *dexec.Cmd, containerName string) error
}

func GetUserClient

func GetUserClient(ctx context.Context) UserClient

func NewUserClient added in v2.19.1

func NewUserClient(conn *grpc.ClientConn, daemonID *Identifier, 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