Documentation
¶
Overview ¶
Package tablehttp serves the register / unregister actions that make an uploaded file readable as a query-engine table (#1327).
One handler serves both kinds. A managed resource and a portal asset reach the registrar through different records -- a resource is a person's upload, an asset is what the platform wrote for them -- but the action, the request body, and the response are the same, so the parts that differ are a Subject resolver per kind and nothing else.
It sits beside the resource and portal handlers rather than inside them: the routes it registers are more specific than the prefix mounts those handlers occupy, so ServeMux gives them precedence, and neither public package gains a dependency on the registrar.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectionChoice ¶
type ConnectionChoice struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Catalog string `json:"catalog"`
Schema string `json:"schema"`
}
ConnectionChoice is one connection a person can register onto.
type ConnectionEnumerator ¶
type ConnectionEnumerator func(ctx context.Context, user *portal.User) []ConnectionChoice
ConnectionEnumerator lists the connections this caller may register onto: granted to their persona and carrying a scratch target. It is the picker's only source, so a connection the form offers is one the registrar accepts.
type Deps ¶
type Deps struct {
Registrar *tableregister.Registrar
// Resources and Assets resolve the two kinds. Either may be nil, which
// leaves that kind's routes unregistered rather than answering an error.
Resources Subject
Assets Subject
// Connections fills the picker. Nil serves an empty list, which a form
// renders as "no connection here can hold a table".
Connections ConnectionEnumerator
// Visible reports the connections a caller may SEE registrations on, which
// is a wider set than Connections: the picker narrows to connections that
// can hold a NEW table, and a listing has to keep showing the tables
// already on one that no longer can.
Visible Visibility
// Sources resolves the records a cross-source listing names. Nil leaves
// every row without a source name and without the unregister action,
// which is the listing a deployment that cannot resolve its sources can
// honestly serve.
Sources tableregister.Sources
// Caller builds the registrar's view of the authenticated user: their
// persona and whether they are an administrator.
Caller func(*portal.User) tableregister.Caller
}
Deps is what the handler needs.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves the table routes.
type Subject ¶
type Subject = tableregister.Subject
Subject resolves the record a route's {id} names into what the registrar needs, and decides whether this caller may act on it. Returning ok=false means the caller may not act on the record at all, which is answered as a not-found so the surface never reveals a record the caller could not reach.
It is the registrar's own resolver type rather than one of this package's, so the rule for who may register a file is written once and serves the tool surface as well as these routes.
type Visibility ¶ added in v1.126.0
type Visibility func(ctx context.Context, caller tableregister.Caller) (connections []string, all bool)
Visibility reports the connections a caller may see registrations on. all lifts the boundary entirely, which is what an administrator gets.
A nil Visibility on the handler shows an administrator everything and everyone else nothing, which is the fail-closed reading of a deployment that cannot enumerate its connections.