Documentation
¶
Overview ¶
Package admin provisions mash endpoints: the permission template a NATS user needs, and the streams, consumer and directory record behind it. mash never mints users or holds account seeds; the operator's own tooling issues the user with these permissions.
Index ¶
- func NSCFlags(owner, name string) []string
- func Permissions(owner, name string) jwt.Permissions
- type Admin
- func (a *Admin) ApplyLimits(ctx context.Context, names ...string) ([]string, error)
- func (a *Admin) Deprovision(ctx context.Context, name string) error
- func (a *Admin) EnsureInbox(ctx context.Context, name string) ([]string, error)
- func (a *Admin) Init(ctx context.Context) error
- func (a *Admin) List(ctx context.Context) ([]store.Record, error)
- func (a *Admin) Provision(ctx context.Context, name, user, account, note string, meta Meta) (store.Record, error)
- func (a *Admin) SetLimits(l store.Limits) error
- func (a *Admin) SetMeta(ctx context.Context, name string, u MetaUpdate) (store.Record, error)
- type Meta
- type MetaUpdate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Permissions ¶
func Permissions(owner, name string) jwt.Permissions
Permissions is the complete permission set of endpoint name under owner (spec section 8). Anything not listed is denied.
Types ¶
type Admin ¶
type Admin struct {
// contains filtered or unexported fields
}
Admin provisions endpoints with the account's admin credentials.
func (*Admin) ApplyLimits ¶ added in v0.3.1
ApplyLimits raises the configured limits on existing inboxes in place with a stream update: max_bytes and max_age where they are below the configured value, and max_consumers where it differs. With no names it covers every directory endpoint. Lowering max_bytes or max_age is refused with an error naming the endpoint and field (nothing changes for that endpoint), because it could discard stored mail; the other endpoints are still processed and the errors are joined. It returns one line per endpoint saying what changed.
func (*Admin) Deprovision ¶
Deprovision fences name's lease with a tombstone, then removes its directory record and inbox stream. The fence comes first: a session that is live or starting cannot take the lease back once its endpoint is gone (#10).
func (*Admin) EnsureInbox ¶
EnsureInbox makes sure name's inbox stream and its durable consumer exist, creating whichever is missing with the same configuration Provision uses. It is for an endpoint whose directory record already exists (Provision refuses those) and reports what it had to create: "stream", "consumer", both, or neither. An existing stream or consumer is only checked, never updated: one that differs from that configuration in any field mail depends on is an error naming the field, because fixing it in place could discard stored mail (a lower MaxBytes or MaxAge would). The user decides to deprovision it, which removes whatever the inbox holds, and provisions again.
func (*Admin) Init ¶
Init creates the directory and lease buckets. It is idempotent. A bucket from before buckets had a size cap (no MaxBytes) is bounded in place with a stream update, keeping its keys; a bucket whose MaxBytes is smaller than the configured limit is raised to it; a larger one is kept (a limit is never lowered), and nothing is purged.
func (*Admin) Provision ¶
func (a *Admin) Provision(ctx context.Context, name, user, account, note string, meta Meta) (store.Record, error)
Provision creates name's inbox stream, its consumer and, last, its directory record, so a half-done provision can simply be re-run.
func (*Admin) SetLimits ¶ added in v0.3.1
SetLimits sets the caps Init, Provision and EnsureInbox use (default: store.DefaultLimits). It validates them.
func (*Admin) SetMeta ¶
SetMeta changes name's role, host and labels, only those given. It merges into the stored JSON object, so every other field, including ones a newer mash wrote, survives, and writes with a compare-and-set against the revision it read, re-reading and retrying if another write got in between.
type MetaUpdate ¶
MetaUpdate names the metadata fields SetMeta changes; a nil field is left alone and a pointer to "" clears it. Labels is applied per key: a value sets that label, an empty value clears it, other labels are left alone.