api

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Prefix   = "/elemental"
	PrefixV1 = "/v1"
)

Prefixes.

Variables

View Source
var (
	ErrUnauthorized              = errors.New("unauthorized")
	ErrForbidden                 = errors.New("forbidden")
	ErrMissingRegistrationSecret = errors.New("registration secret is missing")
	ErrNoSigningKey              = errors.New("registration signing key is missing")
	ErrUnparsableSigningKey      = errors.New("registration signing key is not in the expected format")
)
View Source
var ErrBootstrapSecretNoConfig = errors.New("CAPI bootstrap secret does not contain any config")

Functions

func WithDecoration

func WithDecoration(description string, contentType string, httpStatus int) func(cu *openapi.ContentUnit)

func WriteResponse

func WriteResponse(logger logr.Logger, writer http.ResponseWriter, response string)

WriteResponse is the same wrapper as WriteResponseBytes, but accepts []byte as input.

func WriteResponseBytes

func WriteResponseBytes(logger logr.Logger, writer http.ResponseWriter, response []byte)

WriteResponseBytes is a wrapper to handle HTTP response writing errors with logging.

Types

type Authenticator added in v0.2.0

type Authenticator interface {
	ValidateHostRequest(*http.Request, http.ResponseWriter, *v1beta1.ElementalHost, *v1beta1.ElementalRegistration) error
	ValidateRegistrationRequest(*http.Request, http.ResponseWriter, *v1beta1.ElementalRegistration) error
}

func NewAuthenticator added in v0.2.0

func NewAuthenticator(k8sClient client.Client, logger logr.Logger) Authenticator

type BootstrapGetRequest

type BootstrapGetRequest struct {
	Auth string `header:"Authorization"`

	Namespace        string `path:"namespace"`
	RegistrationName string `path:"registrationName"`
	HostName         string `path:"hostName"`
}

type BootstrapResponse

type BootstrapResponse struct {
	Format string `json:"format"`
	Config string `json:"config"`
}

type DeleteElementalHostHandler

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

func NewDeleteElementalHostHandler

func NewDeleteElementalHostHandler(logger logr.Logger, k8sClient client.Client) *DeleteElementalHostHandler

func (*DeleteElementalHostHandler) ServeHTTP

func (h *DeleteElementalHostHandler) ServeHTTP(response http.ResponseWriter, request *http.Request)

func (*DeleteElementalHostHandler) SetupOpenAPIOperation

func (h *DeleteElementalHostHandler) SetupOpenAPIOperation(oc openapi.OperationContext) error

type GetElementalHostBootstrapHandler

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

func NewGetElementalHostBootstrapHandler

func NewGetElementalHostBootstrapHandler(logger logr.Logger, k8sClient client.Client) *GetElementalHostBootstrapHandler

func (*GetElementalHostBootstrapHandler) ServeHTTP

func (h *GetElementalHostBootstrapHandler) ServeHTTP(response http.ResponseWriter, request *http.Request)

func (*GetElementalHostBootstrapHandler) SetupOpenAPIOperation

func (h *GetElementalHostBootstrapHandler) SetupOpenAPIOperation(oc openapi.OperationContext) error

type GetElementalRegistrationHandler

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

func NewGetElementalRegistrationHandler

func NewGetElementalRegistrationHandler(logger logr.Logger, k8sClient client.Client) *GetElementalRegistrationHandler

func (*GetElementalRegistrationHandler) ServeHTTP

func (h *GetElementalRegistrationHandler) ServeHTTP(response http.ResponseWriter, request *http.Request)

func (*GetElementalRegistrationHandler) SetupOpenAPIOperation

func (h *GetElementalRegistrationHandler) SetupOpenAPIOperation(oc openapi.OperationContext) error

type HostCreateRequest

type HostCreateRequest struct {
	Auth    string `header:"Authorization"`
	RegAuth string `header:"Registration-Authorization"`

	Namespace        string `path:"namespace"`
	RegistrationName string `path:"registrationName"`

	Name        string            `json:"name,omitempty"`
	Annotations map[string]string `json:"annotations,omitempty"`
	Labels      map[string]string `json:"labels,omitempty"`
	PubKey      string            `json:"pubKey,omitempty"`
}

type HostDeleteRequest

type HostDeleteRequest struct {
	Auth string `header:"Authorization"`

	Namespace        string `path:"namespace"`
	RegistrationName string `path:"registrationName"`
	HostName         string `path:"hostName"`
}

type HostPatchRequest

type HostPatchRequest struct {
	Auth string `header:"Authorization"`

	Namespace        string `path:"namespace"`
	RegistrationName string `path:"registrationName"`
	HostName         string `path:"hostName"`

	Annotations  map[string]string `json:"annotations,omitempty"`
	Labels       map[string]string `json:"labels,omitempty"`
	Bootstrapped *bool             `json:"bootstrapped,omitempty"`
	Installed    *bool             `json:"installed,omitempty"`
	Reset        *bool             `json:"reset,omitempty"`

	Condition *clusterv1.Condition `json:"condition,omitempty"`
}

func (*HostPatchRequest) SetCondition added in v0.4.0

func (h *HostPatchRequest) SetCondition(conditionType clusterv1.ConditionType, status corev1.ConditionStatus, severity clusterv1.ConditionSeverity, reason string, message string)

type HostResponse

type HostResponse struct {
	Name           string            `json:"name,omitempty"`
	Annotations    map[string]string `json:"annotations,omitempty"`
	Labels         map[string]string `json:"labels,omitempty"`
	BootstrapReady bool              `json:"bootstrapReady,omitempty"`
	Bootstrapped   bool              `json:"bootstrapped,omitempty"`
	Installed      bool              `json:"installed,omitempty"`
	NeedsReset     bool              `json:"needsReset,omitempty"`
}

type OpenAPIDecoratedHandler

type OpenAPIDecoratedHandler interface {
	SetupOpenAPIOperation(oc openapi.OperationContext) error
	ServeHTTP(w http.ResponseWriter, r *http.Request)
}

type PatchElementalHostHandler

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

func NewPatchElementalHostHandler

func NewPatchElementalHostHandler(logger logr.Logger, k8sClient client.Client) *PatchElementalHostHandler

func (*PatchElementalHostHandler) ServeHTTP

func (h *PatchElementalHostHandler) ServeHTTP(response http.ResponseWriter, request *http.Request)

func (*PatchElementalHostHandler) SetupOpenAPIOperation

func (h *PatchElementalHostHandler) SetupOpenAPIOperation(oc openapi.OperationContext) error

type PostElementalHostHandler

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

func NewPostElementalHostHandler

func NewPostElementalHostHandler(logger logr.Logger, k8sClient client.Client) *PostElementalHostHandler

func (*PostElementalHostHandler) ServeHTTP

func (h *PostElementalHostHandler) ServeHTTP(response http.ResponseWriter, request *http.Request)

func (*PostElementalHostHandler) SetupOpenAPIOperation

func (h *PostElementalHostHandler) SetupOpenAPIOperation(oc openapi.OperationContext) error

type RegistrationGetRequest

type RegistrationGetRequest struct {
	RegAuth string `header:"Registration-Authorization"`

	Namespace        string `path:"namespace"`
	RegistrationName string `path:"registrationName"`
}

type RegistrationResponse

type RegistrationResponse struct {
	// HostLabels are labels propagated to each ElementalHost object linked to this registration.
	// +optional
	HostLabels map[string]string `json:"hostLabels,omitempty"`
	// HostAnnotations are labels propagated to each ElementalHost object linked to this registration.
	// +optional
	HostAnnotations map[string]string `json:"hostAnnotations,omitempty"`
	// Config points to Elemental machine configuration.
	// +optional
	Config infrastructurev1beta1.Config `json:"config,omitempty"`
}

type Server

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

func NewServer

func NewServer(ctx context.Context, k8sClient client.Client, port uint, useTLS bool, privKey string, certificate string) *Server

func (*Server) NewRouter

func (s *Server) NewRouter() *mux.Router

func (*Server) Start

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

Jump to

Keyboard shortcuts

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