context

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const RequestIDKey = "csi.requestid"

RequestIDKey is the key used to put/get a CSI request ID in/fromt a Go context.

Variables

This section is empty.

Functions

func GetRequestID

func GetRequestID(ctx context.Context) (uint64, bool)

GetRequestID inspects the context for gRPC metadata and returns its request ID if available.

func Getenv

func Getenv(ctx context.Context, key string) string

Getenv is an alias for LookupEnv and drops the boolean return value.

func LookupEnv

func LookupEnv(ctx context.Context, key string) (string, bool)

LookupEnv returns the value of the provided environment variable by:

  1. Inspecting the context for a key "os.Environ" with a string slice value. If such a key and value exist then the string slice is searched for the specified key and if found its value is returned.

  2. Inspecting the context for a key "os.LookupEnv" with a value of func(string) (string, bool). If such a key and value exist then the function is used to attempt to discover the key's value. If the key and value are found they are returned.

  3. Returning the result of os.LookupEnv.

func Setenv

func Setenv(ctx context.Context, key, val string) error

Setenv sets the value of the provided environment variable to the specified value by first inspecting the context for a key "os.Setenv" with a value of func(string, string) error. If the context does not contain such a function then os.Setenv is used instead.

func WithEnviron

func WithEnviron(ctx context.Context, v []string) context.Context

WithEnviron returns a new Context with the provided environment variable string slice.

func WithLookupEnv

func WithLookupEnv(ctx context.Context, f lookupEnvFunc) context.Context

WithLookupEnv returns a new Context with the provided function.

func WithSetenv

func WithSetenv(ctx context.Context, f setenvFunc) context.Context

WithSetenv returns a new Context with the provided function.

Types

This section is empty.

Jump to

Keyboard shortcuts

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