extensions

package
Version: v2.4.3 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2021 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 ExtensionsState

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

func LoadExtensions

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

LoadExtensions loads any extension YAML files, and adds the appropriate flags to existingFlags.

Extension YAML files are loaded from the 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.

func (*ExtensionsState) AgentImage

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

AgentImage returns the repository/name combination that will be assigned to the container image attribute.

func (*ExtensionsState) Mechanism

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

func (*ExtensionsState) MechanismArgs

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

func (*ExtensionsState) RequiresAPIKeyOrLicense added in v2.2.0

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

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 charater being used to identify metavariables.  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 TypeEnum `json:"type"`
	// Default is the default value for this flag.  This field is optional; if it isn't
	// specitified then the zero value is used.
	Default json.RawMessage `json:"default,omitempty"`
}

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"`
}

MechanismInfo is the information about a mechanism in ExtensionInfo.

type TypeEnum

type TypeEnum string

TypeEnum is an enum-string that identifies the datatype to use both for (1) parsing the default value of a flag, 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 listing of valid values.

func (TypeEnum) NewFlagValue

func (t TypeEnum) NewFlagValue(untypedDefault interface{}) (Value, error)

func (*TypeEnum) UnmarshalJSON

func (t *TypeEnum) UnmarshalJSON(dat []byte) error

type Value

type Value interface {
	pflag.Value
	AsArgs(flagname string) []string
}

Jump to

Keyboard shortcuts

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