client

package
v0.0.0-...-5f133c6 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: BSD-3-Clause, BSD-3-Clause Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Connect

func Connect(server string, mods ...GwcOrGrpcOptions) (grpc.ClientConnInterface, error)

func NiceError

func NiceError(err error, formatting string, args ...interface{}) error

NiceError turns a grpc error into a more user friendly message.

func SetCookieStreamInterceptor

func SetCookieStreamInterceptor(cookie *http.Cookie) grpc.StreamClientInterceptor

func SetCookieUnaryInterceptor

func SetCookieUnaryInterceptor(cookie *http.Cookie) grpc.UnaryClientInterceptor

Types

type AuthFlags

type AuthFlags struct {
	// The identity to use.
	*identity.IdentityFlags

	// Flags indicating how to connect to the authentication server.
	*ServerFlags
}

func DefaultAuthFlags

func DefaultAuthFlags() *AuthFlags

func (*AuthFlags) Register

func (af *AuthFlags) Register(flags kflags.FlagSet, prefix string) *AuthFlags

type BaseFlags

type BaseFlags struct {
	*klog.Flags
	*AuthFlags
	*cache.Local
	*provider.ProviderFlags

	// Function capable of opening the config stores.
	// This is not controlled by command line, but useful for tests or
	// other libraries consuming BaseFlags.
	ConfigOpener config.Opener

	// The name used to build the paths to find config files or cached files.
	// For example, if ConfigName is "enkit", config files may be stored in "~/.config/enkit".
	// This name can be shared across multiple CLI tools needing the same configs.
	ConfigName string

	// The prefix to prepend to authentication cookies.
	// This is only useful if you have multiple organizations using different instance of enkit tools.
	CookiePrefix string

	// The name of the command, used in help strings and to load config customizations specific to the command.
	CommandName string

	// Avoid displaying progress bars.
	NoProgress bool

	// Allow to override the security token used, and identity.
	OverrideToken    string
	OverrideIdentity string

	// Logger object. Guaranteed to never be nil, and always be usable.
	Log *logger.Proxy
}

func DefaultBaseFlags

func DefaultBaseFlags(commandName, configName string) *BaseFlags

func (*BaseFlags) Context

func (bf *BaseFlags) Context() *ccontext.Context

Context() creates a new Context object.

func (*BaseFlags) IdentityCookie

func (bf *BaseFlags) IdentityCookie() (string, *http.Cookie, error)

func (*BaseFlags) IdentityErrorHandler

func (bf *BaseFlags) IdentityErrorHandler(message string) kflags.ErrorHandler

Use with kcobra.Run or similar functions to decoarete an IdentityError with the proper error message to guide the user through authentication.

For example, use kcobra.Run(..., WithErrorHandler(

HandleIdentityError("run enkit login to log in")

to make sure the user is told to use enkit login in case of identity related errors.

func (*BaseFlags) IdentityStore

func (bf *BaseFlags) IdentityStore() (identity.IdentityStore, error)

func (*BaseFlags) IdentityToken

func (bf *BaseFlags) IdentityToken() (string, string, error)

func (*BaseFlags) Init

func (bf *BaseFlags) Init() error

Initializes a BaseFlags object after all flags have been parsed.

Invoked automatically by Run once defaults are loaded. Must be invoked every time base flags change value, to refresh the corresponding objects.

func (*BaseFlags) LoadFlagAssets

func (bf *BaseFlags) LoadFlagAssets(populator kflags.Populator, assets map[string][]byte)

func (*BaseFlags) Register

func (bf *BaseFlags) Register(set kflags.FlagSet, prefix string) *BaseFlags

func (*BaseFlags) Run

func (bf *BaseFlags) Run(set kflags.FlagSet, populator kflags.Populator, run kflags.Runner)

func (*BaseFlags) UpdateFlagDefaults

func (bf *BaseFlags) UpdateFlagDefaults(populator kflags.Populator, domain string) error

UpdateFlagDefaults updates the default value of flags by fetching the configuration from an https/astore server.

type GwcOrGrpcOption

type GwcOrGrpcOption interface{}

type GwcOrGrpcOptions

type GwcOrGrpcOptions []GwcOrGrpcOption

func WithCookie

func WithCookie(cookie *http.Cookie) GwcOrGrpcOptions

func WithInsecure

func WithInsecure() GwcOrGrpcOptions

type ServerFlags

type ServerFlags struct {
	Name, Description string
	Server            string
	AllowInsecure     bool
}

func DefaultServerFlags

func DefaultServerFlags(name, description, address string) *ServerFlags

DefaultServerFlags initializes and returns a ServerFlags object with defaults.

name is a string to prepend to the registered flags. For example, an "auth" prefix will result in the flags --auth-server and --auth-allow-insecure to be registerd. This allows to have multiple servers defined by flags in the same binary.

description is a description for the server, which will be used to create the help messages. For example, a name of "Authentication server" will be appended to "allow... connections to the... Authentication server".

address is the default address of the server to connect to, leave it empty if unknown.

func (*ServerFlags) Connect

func (sf *ServerFlags) Connect(mods ...GwcOrGrpcOptions) (grpc.ClientConnInterface, error)

func (*ServerFlags) Register

func (sf *ServerFlags) Register(store kflags.FlagSet, namespace string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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