v.io: v.io/x/ref/lib/exec Index | Files

package exec

import "v.io/x/ref/lib/exec"

Package exec implements configuration and secret-sharing between parent and child processes via anoymous pipes. Anonymous pipes are used since they are the most secure communication channel available.

Once a parent starts a child process it can use WaitForReady to wait for the child to reach its 'Ready' state. Operations are provided to wait for the child to terminate, and to terminate the child, cleaning up any state associated with it.

A child process uses the GetChildHandle function to complete the initial authentication handshake. The child must call SetReady to indicate that it is fully initialized and ready for whatever purpose it is intended to fulfill. This handshake is referred as the 'exec protocol'.


Package Files

config.go consts.go doc.go exec.go


const V23_EXEC_CONFIG = "V23_EXEC_CONFIG" //nolint:golint

The V23_EXEC_CONFIG environment variable is used to share a base64 encoded JSON dictionary containing an instance of Config between a parent and child process.

func DecodeFromEnvVar Uses

func DecodeFromEnvVar(value string, config Config) error

DecodeFromEnvVar decodes a base64 encoded JSON representation into the supplied config. See EncodeForEnvVar.

func EncodeForEnvVar Uses

func EncodeForEnvVar(config Config) (string, error)

EncodeForEnvVar encodes the supplued config using JSON and base64 so that it can be passed as a value for an environment variable. JSON is used to allow for the greatest level of interoperability.

func WriteConfigToEnv Uses

func WriteConfigToEnv(config Config, env []string) ([]string, error)

WriteConfigToEnv serializes the supplied Config to the environment variable V23_EXEC_CONFIG and appends it to the supplied environment slice.

type Config Uses

type Config interface {
    // Set sets the value for the key.  If the key already exists in the
    // config, its value is overwritten.
    Set(key, value string)
    // Get returns the value for the key. If the key doesn't exist
    // in the config, Get returns an error.
    Get(key string) (string, error)
    // Clear removes the specified key from the config.
    Clear(key string)
    // Serialize serializes the config to a string.
    Serialize() (string, error)
    // MergeFrom deserializes config information from a string created using
    // Serialize(), and merges this information into the config, updating
    // values for keys that already exist and creating new key-value pairs
    // for keys that don't.
    MergeFrom(string) error
    // Dump returns the config information as a map from ket to value.
    Dump() map[string]string

Config defines a simple key-value configuration. Keys and values are strings, and a key can have exactly one value. The client is responsible for encoding structured values, or multiple values, in the provided string.

Config data can come from several sources: - passed from parent process to child process through pipe; - using environment variables or flags; - via the neighborhood-based config service; - by RPCs using the Config idl; - manually, by calling the Set method.

This interface makes no assumptions about the source of the configuration, but provides a unified API for accessing it.

func NewConfig Uses

func NewConfig() Config

New creates a new empty config.

func ReadConfigFromOSEnv Uses

func ReadConfigFromOSEnv() (Config, error)

ReadConfigFromOSEnv deserializes a Config from the environment variable V23_EXEC_CONFIG and returns that Config.

Package exec imports 7 packages (graph) and is imported by 15 packages. Updated 2020-10-22. Refresh now. Tools for package owners.