admin

package
v2.15.2 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ManagementMutationCodeRouteAlreadyMapped   = "management_route_already_mapped"
	ManagementMutationCodeRoutePublishDisabled = "management_route_publish_disabled"
	ManagementMutationCodeRouteTargetMismatch  = "management_route_target_mismatch"
	ManagementMutationCodeRouteBacklogActive   = "management_route_backlog_active"
)

Variables

View Source
var (
	ErrSecretDuplicate = errors.New("admin: duplicate secret id")
	ErrSecretPoolFull  = errors.New("admin: secret pool is full")
	ErrSecretInvalid   = errors.New("admin: invalid secret version")
)

Sentinel errors the SecretPool.Add implementation should return. The host app's adapter translates internal/secrets errors to these.

View Source
var (
	ErrManagementRouteNotFound    = errors.New("management route not found")
	ErrManagementEndpointNotFound = errors.New("management endpoint not found")
	ErrManagementConflict         = errors.New("management conflict")
)

Functions

func ExtractManagementMutationError

func ExtractManagementMutationError(err error) (code, detail string, ok bool)

func NewManagementMutationError

func NewManagementMutationError(base error, code, detail string) error

Types

type Authorizer

type Authorizer func(r *http.Request) bool

func BearerTokenAuthorizer

func BearerTokenAuthorizer(tokens [][]byte) Authorizer

type Handler

type Handler interface {
	ServeHTTP(w http.ResponseWriter, r *http.Request)
}

type ManagementApplication

type ManagementApplication struct {
	Name          string               `json:"name"`
	EndpointCount int                  `json:"endpoint_count"`
	Endpoints     []ManagementEndpoint `json:"endpoints"`
}

type ManagementEndpoint

type ManagementEndpoint struct {
	Name          string                          `json:"name"`
	Route         string                          `json:"route"`
	Mode          string                          `json:"mode"`
	Targets       []string                        `json:"targets"`
	PublishPolicy ManagementEndpointPublishPolicy `json:"publish_policy"`
}

type ManagementEndpointDeleteRequest

type ManagementEndpointDeleteRequest struct {
	Application  string
	EndpointName string
	Reason       string
	Actor        string
	RequestID    string
}

type ManagementEndpointMutationResult

type ManagementEndpointMutationResult struct {
	Applied bool
	Action  string
	Route   string

	// PostWriteValidate is called after the config file is written but before
	// reload. If non-nil and it returns an error, the file write is rolled back.
	// Used to re-check invariants (e.g. backlog emptiness) after config mutation.
	PostWriteValidate func() error `json:"-"`
}

type ManagementEndpointPublishPolicy

type ManagementEndpointPublishPolicy struct {
	Enabled        bool `json:"enabled"`
	DirectEnabled  bool `json:"direct_enabled"`
	ManagedEnabled bool `json:"managed_enabled"`
}

type ManagementEndpointUpsertRequest

type ManagementEndpointUpsertRequest struct {
	Application  string
	EndpointName string
	Route        string
	Reason       string
	Actor        string
	RequestID    string
}

type ManagementModel

type ManagementModel struct {
	RouteCount       int                     `json:"route_count"`
	ApplicationCount int                     `json:"application_count"`
	EndpointCount    int                     `json:"endpoint_count"`
	Applications     []ManagementApplication `json:"applications"`
}

type ManagementMutationAuditEvent

type ManagementMutationAuditEvent struct {
	At           time.Time
	Operation    string
	Application  string
	EndpointName string
	Route        string
	Target       string
	State        string
	Limit        int
	PreviewOnly  bool
	Matched      int
	Changed      int
	Reason       string
	Actor        string
	RequestID    string
}

type ManagementMutationError

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

ManagementMutationError carries explicit conflict classification metadata while preserving sentinel compatibility via error wrapping.

func (*ManagementMutationError) Error

func (e *ManagementMutationError) Error() string

func (*ManagementMutationError) Unwrap

func (e *ManagementMutationError) Unwrap() error

type PublishResultEvent

type PublishResultEvent struct {
	Accepted int
	Rejected int
	Code     string
	Scoped   bool
}

type PullConsumer added in v2.13.0

type PullConsumer struct {
	ID            string    `json:"id"`
	Route         string    `json:"route"`
	ConsumerGroup string    `json:"consumer_group,omitempty"`
	Endpoint      string    `json:"endpoint"`
	RemoteAddr    string    `json:"remote_addr"`
	UserAgent     string    `json:"user_agent,omitempty"`
	TokenRef      string    `json:"token_ref,omitempty"`
	ConnectedAt   time.Time `json:"connected_at"`
	MessagesSent  int64     `json:"messages_sent"`
	LastMessageAt time.Time `json:"last_message_at,omitzero"`
}

PullConsumer is one pull consumer with an open SSE stream, as reported by GET /pull/consumers.

TokenRef is the configured secret reference the consumer authenticated with (`env.PULL_TOKEN`), never the token value.

type SecretLookup

type SecretLookup func(name string) (SecretPool, bool)

type SecretMutationAuditEvent

type SecretMutationAuditEvent struct {
	At        time.Time
	Operation string // "add" or "delete"
	PoolName  string
	SecretID  string
	NotBefore time.Time
	NotAfter  time.Time
	Reason    string
	Actor     string
	RequestID string
}

type SecretPool

type SecretPool interface {
	Name() string
	Runtime() bool
	// Add inserts a new version into the pool. Implementations must return
	// errors matching ErrSecret{Duplicate,PoolFull,Invalid} so the handler can
	// map them to HTTP responses.
	Add(id string, value []byte, notBefore, notAfter time.Time) error
	Remove(id string) (removed bool)
	ListMetadata() []SecretVersionMetadata
}

SecretPool is the admin-facing view of a runtime-mutable secret pool. The host app wires this by adapting *secrets.Pool so admin does not import internal/secrets directly.

type SecretRecord

type SecretRecord struct {
	PoolName  string
	ID        string
	Sealed    []byte
	NotBefore time.Time
	NotAfter  time.Time
	CreatedAt time.Time
}

SecretRecord is the persisted shape handed to PersistSecret. The admin package mirrors secrets.Record shape so internal/secrets stays decoupled.

type SecretVersionMetadata

type SecretVersionMetadata struct {
	ID        string    `json:"id"`
	NotBefore time.Time `json:"not_before"`
	NotAfter  time.Time `json:"not_after,omitempty"`
}

type Server

type Server struct {
	Store                              queue.Store
	Authorize                          Authorizer
	HealthDiagnostics                  func() map[string]any
	ResolveTrendSignalConfig           func() queue.BacklogTrendSignalConfig
	ResolveManaged                     func(application, endpointName string) (route string, targets []string, ok bool)
	ManagedRouteInfoForRoute           func(route string) (application, endpointName string, managed bool, available bool)
	ManagedRouteSet                    func() (routes map[string]struct{}, available bool)
	TargetsForRoute                    func(route string) []string
	ModeForRoute                       func(route string) string
	PublishEnabledForRoute             func(route string) bool
	PublishDirectEnabledForRoute       func(route string) bool
	PublishManagedEnabledForRoute      func(route string) bool
	LimitsForRoute                     func(route string) (maxBodyBytes int64, maxHeaderBytes int)
	ManagementModel                    func() ManagementModel
	PullConsumers                      func() []PullConsumer
	RequireManagementAuditReason       bool
	MaxBodyBytes                       int64
	MaxHeaderBytes                     int
	PublishGlobalDirectEnabled         bool
	PublishScopedManagedEnabled        bool
	PublishAllowPullRoutes             bool
	PublishAllowDeliverRoutes          bool
	PublishRequireAuditActor           bool
	PublishRequireAuditRequestID       bool
	PublishScopedManagedFailClosed     bool
	PublishScopedManagedActorAllowlist []string
	PublishScopedManagedActorPrefixes  []string
	AuditManagementMutation            func(event ManagementMutationAuditEvent)
	ObservePublishResult               func(event PublishResultEvent)
	UpsertManagedEndpoint              func(req ManagementEndpointUpsertRequest) (ManagementEndpointMutationResult, error)
	DeleteManagedEndpoint              func(req ManagementEndpointDeleteRequest) (ManagementEndpointMutationResult, error)

	// Runtime secret rotation (see handle_secrets.go).
	SecretLookup        SecretLookup
	PersistSecret       func(rec SecretRecord) error
	DeleteSecretRecord  func(poolName, id string) (bool, error)
	SealSecret          func(plain []byte) ([]byte, error)
	AuditSecretMutation func(event SecretMutationAuditEvent)
	// contains filtered or unexported fields
}

func NewServer

func NewServer(store queue.Store) *Server

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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