extensions

package
v2.7.3-rc.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeArgsCompatible added in v2.7.0

func MakeArgsCompatible(ctx context.Context, mech, image string, args []string) ([]string, error)

Types

type CLIFlagState added in v2.7.0

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

func (*CLIFlagState) AgentImage added in v2.7.0

func (es *CLIFlagState) AgentImage(ctx context.Context) (string, error)

AgentImage returns the repository/name combination that will be assigned to the container image attribute. Deprecated: The image to use is determined by the traffic-manager

func (*CLIFlagState) Mechanism added in v2.7.0

func (es *CLIFlagState) Mechanism() (string, error)

func (*CLIFlagState) MechanismArgs added in v2.7.0

func (es *CLIFlagState) MechanismArgs() ([]string, error)

func (*CLIFlagState) RequiresAPIKeyOrLicense added in v2.7.0

func (es *CLIFlagState) RequiresAPIKeyOrLicense() (bool, error)

type ExtensionInfo

type ExtensionInfo struct {
	// Image is the agent image name to install as a sidecar in order to use this extension.
	//
	// Alternatively, instead of a Docker image name, you may give an "http://", https://", or
	// "grpc+https://" URL.  For an "http://" or "https://" URL, the URL must return an HTTP 200
	// response where the response body will be used as the Docker image name.  For a
	// "grpc+https://" url, it will make a `/telepresence.systema/PreferredAgentResponse`
	// request to the server specified in the URL.  This is done recursively.
	//
	// The initial string has environment variables expanded via os.Expand.  Strings returned
	// from HTTP or gRPC requests do not have environment variables expanded.
	Image string `json:"image"`
	// RequiresAPIKeyOrLicense identifies whether the agent sidecar image requires a SystemA API key (via
	// `telepresence login`) or a license in the cluster in order to function.
	RequiresAPIKeyOrLicense bool `json:"requiresAPIKeyOrLicense,omitempty"`
	// Mechanisms describes the mechanisms that the agent sidecar image supports.  The keys in
	// the map are the mechanism names.
	Mechanisms map[string]MechanismInfo `json:"mechanisms"`
}

ExtensionInfo is the type that the data in an extension YAML file must be.

type FlagInfo

type FlagInfo struct {
	// Usage is the usage text for the flag to include in `--help` output.  It follows pflag
	// semantics around the backtick character being used to identify meta-variables.  Strictly
	// speaking, this field is optional, but you should probably include it.
	Usage string `json:"usage"`
	// Type identifies the type identifies the datatype to use both for (1) parsing the default
	// value of a flag (below), and for (2) validating and normalizing the flag value that the
	// user passes on the CLI.  See the `flagTypes` variable in `flagtypes.go` for a list of
	// possible values.  This field is required.
	Type cliutil.TypeEnum `json:"type"`
	// Default is the default value for this flag.  This field is optional; if it isn't
	// specified then the zero value is used.
	Default json.RawMessage `json:"default,omitempty"`

	// Deprecated is set if the flag is deprecated in favor of something else. Deprecation
	// means that the flag retains its original function, is hidden from help, and that using it will
	// display this field as a warning.
	Deprecated string `json:"deprecated,omitempty"`
}

type LoadedExtensions added in v2.7.0

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

func LoadExtensions

func LoadExtensions(ctx context.Context, existingFlags *pflag.FlagSet) (es *LoadedExtensions, err error)

LoadExtensions loads any extension YAML files.

Extension YAML files are loaded from the "extensions/" subdirectories in filelocation.AppUserConfigDir and filelocation.AppSystemConfigDirs (eg: on GNU/Linux: "~/.config/telepresence/extensions/" and "/etc/xdg/telepresence/extensions/"). Files are ignored if they begin with "." or if they don't end with ".yml". Files with the same name in multiple directories will mask eachother (eg: "~/.config/telepresence/extensions/foo.yml" will mask "/etc/xdg/telepresence/extensions/foo.yml").

The basename of the extension YAML filename (i.e. the non-directory part, with the ".yml" suffix removed) identifies the name of the extension. The content of the extension YAML file must be an ExtensionInfo object serialized as YAML. See the docs for ExtensionInfo for more information.

The list of existingFlags is used to detect when a mechanism's flags clash with a built-in flag.

func (*LoadedExtensions) AddToFlagSet added in v2.7.0

func (ls *LoadedExtensions) AddToFlagSet(ctx context.Context, flagset *pflag.FlagSet) (es *CLIFlagState, err error)

AddToFlagSet adds all of the mechanism-related flags from LoadedExtensions to a FlagSet, and returns an object used to get extension/mechanism information out of the FlagSet.

type MechanismInfo

type MechanismInfo struct {
	// Preference identifies an ordering of preference for choosing the default mechanism if not
	// told explicitly via a flag.  The highest preference mechanism will be used as the
	// default; with the exception that the mechanism(s) of a requiresAPIKeyOrLicense extension will not
	// be considered if not logged in or if you cannot access the cloud and use a license.
	// Ties are decided by lexicographic ordering.
	Preference int `json:"preference,omitempty"`

	// Flags describes which CLI flags this mechanism introduces to `telepresence intercept`.
	// The flag will be exposed to the user as `--{{mechname}}-{{mapkey}}`, and will be passed
	// to the agent sidecar gRPC responses as `--{{mapkey}}`.
	Flags map[string]FlagInfo `json:"flags"`

	// MakeArgsCompatible is an optional callback function that may mutate the mechanism
	// arguments (`args`) to be compatible with a particular agent image (`image`).
	//
	// While the Mechanism belongs to an Extension with a known agent `ExtensionInfo.Image`, if
	// the agent is not managed by the auto-install, then the *version* of the agent that is
	// actually installed might not match ExtensionInfo.Image.  This callback allows handling
	// flag compatibility concerns between different versions of the agent.
	//
	// It is permissible to mutate the input `args` and return that.
	//
	// FIXME(lukeshu): MakeArgsCompatible isn't expressable in an external YAML file.
	MakeArgsCompatible func(args *pflag.FlagSet, image string) (*pflag.FlagSet, error) `json:"-"`
}

MechanismInfo is the information about a mechanism in ExtensionInfo.

type SystemACredentials added in v2.5.0

type SystemACredentials string

func (SystemACredentials) GetRequestMetadata added in v2.5.0

func (c SystemACredentials) GetRequestMetadata(_ context.Context, _ ...string) (map[string]string, error)

GetRequestMetadata implements credentials.PerRPCCredentials.

func (SystemACredentials) RequireTransportSecurity added in v2.5.0

func (c SystemACredentials) RequireTransportSecurity() bool

RequireTransportSecurity implements credentials.PerRPCCredentials.

Jump to

Keyboard shortcuts

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