server

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: Apache-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHostname

func GetHostname(hostnameOverride string) (string, error)

GetHostname returns OS's hostname if 'hostnameOverride' is empty; otherwise, return 'hostnameOverride'. Copied from Kubernetes' nodeutil to avoid a dependency to kubernetes/kubernetes.

Types

type AuthFlags

type AuthFlags struct {
	ClientCAFile string
	Anonymous    bool
}

AuthFlags are options for configuring server.Options.AuthFlags.

func (*AuthFlags) AuthOptions

func (o *AuthFlags) AuthOptions(machinePoolName string) AuthOptions

AuthOptions produces the server.AuthOptions.

func (*AuthFlags) BindFlags

func (o *AuthFlags) BindFlags(fs *pflag.FlagSet)

BindFlags adds the flags to the pflag.FlagSet.

type AuthOptions

type AuthOptions struct {
	MachinePoolName string
	Authentication  AuthenticationOptions
	Authorization   AuthorizationOptions
}

type AuthenticationOptions

type AuthenticationOptions struct {
	ClientCAFile string
}

type AuthorizationOptions

type AuthorizationOptions struct {
	Anonymous bool
}

type Flags

type Flags struct {
	Serving ServingFlags
	Auth    AuthFlags
}

Flags couples together all options required to create server.Options.

func NewServerFlags

func NewServerFlags() *Flags

func (*Flags) BindFlags

func (o *Flags) BindFlags(fs *pflag.FlagSet)

BindFlags adds the flags to the pflag.FlagSet.

func (*Flags) ServerOptions

func (o *Flags) ServerOptions(machinePoolName string, machineRuntime orimachine.RuntimeService, log logr.Logger) Options

ServerOptions produces server.Options.

type MachinePoolRequestAttr

type MachinePoolRequestAttr struct {
	MachinePoolName string
}

func (MachinePoolRequestAttr) GetRequestAttributes

func (m MachinePoolRequestAttr) GetRequestAttributes(u user.Info, req *http.Request) authorizer.Attributes

type Options

type Options struct {
	// MachineRuntime is the ori-machine runtime service.
	MachineRuntime orimachine.RuntimeService

	// Log is the logger to use in the server.
	// If unset, a package-global router will be used.
	Log logr.Logger

	// HostnameOverride is an optional hostname override to supply for self-signed certificate generation.
	HostnameOverride string

	// Address is the address to listen on.
	// Leave empty to auto-determine host / ephemeral port.
	Address string

	// CertDir is the directory that contains the server key and certificate.
	// If not set, the server would look up the key and certificate in
	// {TempDir}/onmetal-api-machinepool-server/serving-certs. The key and certificate
	// must be named tls.key and tls.crt, respectively.
	// If the files don't exist, a self-signed certificate is generated.
	CertDir string

	// Auth are options for authentication.
	Auth AuthOptions
	// DisableAuth will turn off authN/Z.
	DisableAuth bool

	StreamCreationTimeout time.Duration
	StreamIdleTimeout     time.Duration
	ShutdownTimeout       time.Duration
	CacheTTL              time.Duration
}

type Server

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

func New

func New(cfg *rest.Config, opts Options) (*Server, error)

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

type ServingFlags

type ServingFlags struct {
	DisableAuth      bool
	HostnameOverride string
	Address          string
	CertDir          string

	StreamCreationTimeout time.Duration
	StreamIdleTimeout     time.Duration
	ShutdownTimeout       time.Duration
}

ServingFlags are options for configuring the serving part of server.Options.

func NewServingOptions

func NewServingOptions() *ServingFlags

func (*ServingFlags) BindFlags

func (o *ServingFlags) BindFlags(fs *pflag.FlagSet)

BindFlags adds the flags to the pflag.FlagSet.

func (*ServingFlags) ServerOptions

func (o *ServingFlags) ServerOptions(machineRuntime orimachine.RuntimeService, log logr.Logger, authOpts AuthOptions) Options

ServerOptions produces server.Options.

Jump to

Keyboard shortcuts

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