actuator

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeSpringBootV2 = "application/vnd.spring-boot.actuator.v2+json"
	ContentTypeSpringBootV3 = "application/vnd.spring-boot.actuator.v3+json"
)
View Source
const (
	ManagementPropertiesPrefix = "management"
)

Variables

View Source
var Module = &bootstrap.Module{
	Name:       "actuate",
	Precedence: MaxActuatorPrecedence,
	Options: []fx.Option{
		fx.Provide(NewRegistrar, BindManagementProperties),
		fx.Invoke(initialize),
	},
}

Functions

func SpringBootRespEncoderV2

func SpringBootRespEncoderV2() web.EncodeResponseFunc

func SpringBootRespEncoderV3

func SpringBootRespEncoderV3() web.EncodeResponseFunc

Types

type AccessControlCustomizeFunc

type AccessControlCustomizeFunc func(ac *access.AccessControlFeature, epId string, paths []string)

AccessControlCustomizeFunc convert a function to interface AccessControlCustomizer

func (AccessControlCustomizeFunc) Customize

func (f AccessControlCustomizeFunc) Customize(ac *access.AccessControlFeature, epId string, paths []string)

type AccessControlCustomizer

type AccessControlCustomizer interface {
	Customize(ac *access.AccessControlFeature, epId string, paths []string)
}

AccessControlCustomizer Similar to SecurityCustomizer, but is used to customize access control of each endpoint. Implementations of AccessControlCustomizer can be registered via Registrar, and NewAccessControlByPermissions is used if no other customizer is registered. Also See NewSimpleAccessControl, NewAccessControlByPermissions, NewAccessControlByScopes

func NewAccessControlByPermissions

func NewAccessControlByPermissions(properties SecurityProperties, defaultPerms ...string) AccessControlCustomizer

NewAccessControlByPermissions returns a AccessControlCustomizer that uses SecurityProperties and given default permissions to setup access control of each endpoint. 1. If security of any particular endpoint is not enabled, access.PermitAll is used 2. If no permissions are configured in the properties and no defaults are given, access.Authenticated is used

This is the default AccessControlCustomizer if no other AccessControlCustomizer is registered

func NewAccessControlByScopes

func NewAccessControlByScopes(properties SecurityProperties, usePermissions bool, defaultScopes ...string) AccessControlCustomizer

NewAccessControlByScopes returns a AccessControlCustomizer that uses SecurityProperties and given default approved scopes to setup access control of each endpoint. "usePermissions" indicate if we should use permissions configured in SecurityProperties for scope checking

1. If security of any particular endpoint is not enabled, access.PermitAll is used 2. If usePermissions is true but no permissions are configured in SecurityProperties, defaultScopes is used to resolve scoes 3. If no scopes are configured (regardless if usePermissions is enabled), access.Authenticated is used

Note: This customizer is particularly useful for client_credentials grant type

func NewSimpleAccessControl

func NewSimpleAccessControl(acCreator func(epId string) access.ControlFunc) AccessControlCustomizer

NewSimpleAccessControl is a convenient AccessControlCustomizer constructor that create simple access control rule to ALL paths of each endpoint. A mapper function is required to convert each endpoint ID to its corresponding access.ControlFunc

type BasicEndpointProperties

type BasicEndpointProperties struct {
	Enabled *bool `json:"enabled"`
}

type Endpoint

type Endpoint interface {
	Id() string
	EnabledByDefault() bool
	Operations() []Operation
}

type EndpointBase

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

EndpointBase implements EndpointExecutor and partially Endpoint, and can be embedded into any Endpoint implementation it calls Operations using reflect

func MakeEndpointBase

func MakeEndpointBase(opts ...EndpointOptions) EndpointBase

func (EndpointBase) EnabledByDefault

func (b EndpointBase) EnabledByDefault() bool

func (EndpointBase) Id

func (b EndpointBase) Id() string

func (EndpointBase) Operations

func (b EndpointBase) Operations() []Operation

func (EndpointBase) ReadOperation

func (b EndpointBase) ReadOperation(ctx context.Context, input interface{}) (interface{}, error)

func (EndpointBase) WriteOperation

func (b EndpointBase) WriteOperation(ctx context.Context, input interface{}) (interface{}, error)

type EndpointExecutor

type EndpointExecutor interface {
	ReadOperation(ctx context.Context, input interface{}) (interface{}, error)
	WriteOperation(ctx context.Context, input interface{}) (interface{}, error)
}

type EndpointOption

type EndpointOption struct {
	Id               string
	Ops              []Operation
	Properties       *EndpointsProperties
	EnabledByDefault bool
}

type EndpointOptions

type EndpointOptions func(opt *EndpointOption)

type EndpointSecurityProperties

type EndpointSecurityProperties struct {
	Enabled     *bool                     `json:"enabled"`
	Permissions utils.CommaSeparatedSlice `json:"permissions"`
}

type EndpointsProperties

type EndpointsProperties struct {
	EnabledByDefault bool                   `json:"enabled-by-default"`
	Web              WebEndpointsProperties `json:"web"`
}

type ManagementProperties

type ManagementProperties struct {
	Enabled       bool                               `json:"enabled"`
	Endpoints     EndpointsProperties                `json:"endpoints"`
	BasicEndpoint map[string]BasicEndpointProperties `json:"endpoint"`
	Security      SecurityProperties                 `json:"security"`
}

func BindManagementProperties

func BindManagementProperties(ctx *bootstrap.ApplicationContext) ManagementProperties

BindManagementProperties create and bind SessionProperties, with a optional prefix

func NewManagementProperties

func NewManagementProperties() *ManagementProperties

NewManagementProperties create a ManagementProperties with default values

type MappingNameFunc

type MappingNameFunc func(op Operation) string

type MappingPathFunc

type MappingPathFunc func(op Operation, props *WebEndpointsProperties) string

type Operation

type Operation interface {
	Mode() OperationMode
	Func() OperationFunc
	Matches(ctx context.Context, mode OperationMode, input interface{}) bool
	Execute(ctx context.Context, input interface{}) (interface{}, error)
}

func NewReadOperation

func NewReadOperation(opFunc OperationFunc, inputMatchers ...matcher.Matcher) Operation

func NewWriteOperation

func NewWriteOperation(opFunc OperationFunc, inputMatchers ...matcher.Matcher) Operation

type OperationFunc

type OperationFunc interface{}

OperationFunc is a func that have following signature:

func(ctx context.Context, input StructsOrPointerType1) (StructsOrPointerType2, error)

where

  • StructsOrPointerType1 and StructsOrPointerType2 can be any structs or struct pointers
  • input might be ignored by particular Endpoint impl.
  • 1st output is optional for "write" operations

Note: golang doesn't have generics yet...

type OperationMode

type OperationMode int
const (
	OperationRead OperationMode = iota
	OperationWrite
)

type Registrar

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

func NewRegistrar

func NewRegistrar(di constructDI) *Registrar

func (*Registrar) MustRegister

func (r *Registrar) MustRegister(items ...interface{})

func (*Registrar) Register

func (r *Registrar) Register(items ...interface{}) error

type SecurityCustomizer

type SecurityCustomizer interface {
	Customize(ws security.WebSecurity)
}

SecurityCustomizer is a single SecurityCustomizer can be registered via Registrar SecurityCustomizer is typically responsible to setup authentication scheme it should not configure access control, which is configured per-endpoint via properties or AccessControlCustomizer

func NewTokenAuthSecurity

func NewTokenAuthSecurity() SecurityCustomizer

NewTokenAuthSecurity returns a SecurityCustomizer config actuator security to use OAuth2 token auth. This is the default SecurityCustomizer if no other SecurityCustomizer is registered

type SecurityCustomizerFunc

type SecurityCustomizerFunc func(ws security.WebSecurity)

SecurityCustomizerFunc convert a function to interface SecurityCustomizer

func (SecurityCustomizerFunc) Customize

type SecurityProperties

type SecurityProperties struct {
	EnabledByDefault bool                                  `json:"enabled-by-default"`
	Permissions      utils.CommaSeparatedSlice             `json:"permissions"`
	Endpoints        map[string]EndpointSecurityProperties `json:"endpoint"`
}

type WebEndpoint

type WebEndpoint interface {
	Mappings(op Operation, group string) ([]web.Mapping, error)
}

type WebEndpointBase

type WebEndpointBase struct {
	EndpointBase
	// contains filtered or unexported fields
}

WebEndpointBase is similar to EndpointBase and implements default WebEndpoint mapping

func MakeWebEndpointBase

func MakeWebEndpointBase(opts ...EndpointOptions) WebEndpointBase

func (WebEndpointBase) MappingName

func (b WebEndpointBase) MappingName(op Operation) string

func (WebEndpointBase) MappingPath

func (b WebEndpointBase) MappingPath(_ Operation, props *WebEndpointsProperties) string

func (WebEndpointBase) Mappings

func (b WebEndpointBase) Mappings(op Operation, group string) ([]web.Mapping, error)

Mappings implements WebEndpoint

func (WebEndpointBase) NegotiableResponseEncoder

func (b WebEndpointBase) NegotiableResponseEncoder() web.EncodeResponseFunc

func (WebEndpointBase) NegotiateFormat

func (b WebEndpointBase) NegotiateFormat(ctx context.Context) string

func (WebEndpointBase) RestMappingBuilder

func (b WebEndpointBase) RestMappingBuilder(op Operation, group string,
	pathFunc MappingPathFunc, nameFunc MappingNameFunc) (*rest.MappingBuilder, error)

type WebEndpoints

type WebEndpoints map[string][]web.Mapping

func (WebEndpoints) EndpointIDs

func (w WebEndpoints) EndpointIDs() (ret []string)

func (WebEndpoints) Paths

func (w WebEndpoints) Paths(id string) []string

Paths returns all path patterns of given endpoint ID. only web.RoutedMapping & web.StaticMapping is possible to extract this information

type WebEndpointsProperties

type WebEndpointsProperties struct {
	BasePath string                `json:"base-path"`
	Mappings map[string]string     `json:"path-mapping"`
	Exposure WebExposureProperties `json:"exposure"`
}

type WebExposureProperties

type WebExposureProperties struct {
	// Endpoint IDs that should be included or '*' for all.
	Include utils.StringSet `json:"include"`
	// Endpoint IDs that should be excluded or '*' for all.
	Exclude utils.StringSet `json:"exclude"`
}

Directories

Path Synopsis
endpoint
Package healthep Contains implementation of health endpoint as a separate package to avoid cyclic package dependency.
Package healthep Contains implementation of health endpoint as a separate package to avoid cyclic package dependency.

Jump to

Keyboard shortcuts

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