connections

package
v0.1.74 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 66 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SourceSecret         = "secret"
	SourceConfigMap      = "configmap"
	SourceHelm           = "helm"
	SourceServiceAccount = "serviceaccount"
	SourceOnePassword    = "onepassword"
	SourceValue          = "value"
)

Value sources, by the reference form each is stored as: secret://, configmap://, helm://, serviceaccount://, op://, or a literal value.

Variables

This section is empty.

Functions

func AddConnectionsOpenAPI added in v0.1.29

func AddConnectionsOpenAPI(spec *rpc.OpenAPISpec)

AddConnectionsOpenAPI documents the inventory read and its opt-in health trigger without publishing either as an explorer surface.

func MaskValue

func MaskValue(value string) string

func Parse

func Parse(body map[string]any) (*models.Connection, error)

Types

type BodyDecoder

type BodyDecoder func(context.Context, map[string]any) (map[string]any, error)

type ConnectionInspection added in v0.1.30

type ConnectionInspection struct {
	Targets []ConnectionInspectionTarget `json:"targets,omitempty"`
	Result  *query.InspectionResult      `json:"result,omitempty"`
}

func (*ConnectionInspection) Pretty added in v0.1.30

func (result *ConnectionInspection) Pretty() api.Text

func (*ConnectionInspection) PrettyFull added in v0.1.30

func (result *ConnectionInspection) PrettyFull() api.Textable

type ConnectionInspectionTarget added in v0.1.30

type ConnectionInspectionTarget struct {
	Name       string          `json:"name"`
	Target     string          `json:"target"`
	Kind       string          `json:"kind"`
	Schema     string          `json:"schema,omitempty"`
	FieldCount int             `json:"fieldCount,omitempty"`
	Inspect    api.LinkCommand `json:"inspect"`
}

func (ConnectionInspectionTarget) Columns added in v0.1.30

func (ConnectionInspectionTarget) Row added in v0.1.30

func (target ConnectionInspectionTarget) Row() map[string]any

type ConnectionInventory added in v0.1.72

type ConnectionInventory struct {
	*models.Connection
	Layer string `json:"layer,omitempty"`
}

type ContextProvider

type ContextProvider func() dbcontext.Context

type DatabaseProvider

type DatabaseProvider func() (*gorm.DB, error)

type InspectFlags added in v0.1.30

type InspectFlags struct {
	Database   string `flag:"database" help:"Database to inspect"`
	Schema     string `flag:"schema" hidden:"true" help:"SQL schema containing the target"`
	Target     string `flag:"target" help:"Table, view, index, alias, data stream, or pattern to inspect"`
	TargetKind string `flag:"target-kind" hidden:"true" help:"OpenSearch target kind"`
	Sample     bool   `flag:"sample" help:"Sample the selected target to resolve cardinality and auto-filters"`
	Refresh    bool   `flag:"refresh" help:"Refresh cached inspection metadata and re-read connection secrets"`
	// contains filtered or unexported fields
}

func (InspectFlags) ClickyActionFlags added in v0.1.30

func (InspectFlags) ClickyActionFlags()

func (InspectFlags) Filters added in v0.1.30

func (options InspectFlags) Filters() []entity.Filter[InspectFlags]

func (*InspectFlags) SetClickyActionContext added in v0.1.30

func (options *InspectFlags) SetClickyActionContext(ctx context.Context, id string)

type KEKStatus added in v0.1.72

type KEKStatus struct {
	State  string `json:"state"`
	Detail string `json:"detail"`
}

type LayeredConnectionProvider added in v0.1.72

type LayeredConnectionProvider interface {
	WritableConnectionProvider
	StorageLayers() []StorageLayer
	DefaultLayer() string
}

type ListOptions

type ListOptions struct {
	Type  string `flag:"type" help:"Filter by connection type"`
	Types string `flag:"types" help:"Filter by connection types (comma-separated)"`
}

ListOptions are the list/filter options for the connection entity. Types is the comma-separated form used by the connection lookup to scope a picker to the connection types valid for a profile's provider (e.g. sql → postgres,mysql,...).

type Options

type Options struct {
	// Database is the connection store. Without one, host-owned connections may
	// persist through a WritableConnectionProvider supplied as Virtual.
	Database   DatabaseProvider
	Context    ContextProvider
	DecodeBody BodyDecoder
	Profiles   ProfileProvider
	Virtual    VirtualConnectionProvider
	// Policy narrows the connection types and value sources the service lists,
	// offers in its form schema and accepts on save.
	Policy Policy
	// Secrets, when set, makes Handler serve the connection form's secret,
	// namespace, workload and 1Password pickers under {prefix}/connections.
	// Its Prefix and Next are set by Handler; an unset Context is the
	// service's, and an unset Kube that context's local Kubernetes client.
	Secrets   *secretcatalog.Options
	KEKStatus func(context.Context) KEKStatus
}

type Policy added in v0.1.64

type Policy struct {
	// AllowedTypes are the connection types listed, offered in the form and
	// accepted on save.
	AllowedTypes []string
	// SecretSources are where a username, password or certificate may come
	// from, and URLSources where a URL may: clicky-ui's SecretValueSource
	// vocabulary (secret, configmap, helm, serviceaccount, onepassword), plus
	// value for a literal.
	SecretSources []string
	URLSources    []string
}

Policy narrows the connections an app offers and accepts. An empty field places no restriction.

type ProfileProvider added in v0.1.29

type ProfileProvider func(context.Context) ([]query.Profile, error)

type Service

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

func New

func New(options Options) (*Service, error)

func (*Service) Create

func (s *Service) Create(ctx context.Context, body map[string]any) (*models.Connection, error)

func (*Service) Delete

func (s *Service) Delete(id string) error

func (*Service) Get

func (s *Service) Get(id string) (*models.Connection, error)

func (*Service) Handler

func (s *Service) Handler(prefix string, next http.Handler) http.Handler

func (*Service) Inspect added in v0.1.30

func (s *Service) Inspect(ctx context.Context, id string, options InspectFlags) (*ConnectionInspection, error)

func (*Service) Inventory added in v0.1.72

func (s *Service) Inventory(options ListOptions) ([]ConnectionInventory, error)

func (*Service) List

func (s *Service) List(options ListOptions) ([]*models.Connection, error)

func (*Service) RegisterClicky

func (s *Service) RegisterClicky()

registerConnectionEntity registers the DB-backed connection entity with full CRUD on both the CLI and over HTTP. Create/Update use the context-aware handlers so they can read the raw nested JSON body (e.g. connection `properties`) clicky stashes on the context via rpc.RequestFromContext, which the executor would otherwise flatten to string flags. The database provider resolves lazily because entities register before the database exists.

func (*Service) ResolveReference added in v0.1.72

func (s *Service) ResolveReference(reference string) (*models.Connection, error)

ResolveReference refuses ambiguous names rather than choosing an arbitrary row.

func (*Service) SetVirtual added in v0.1.29

func (s *Service) SetVirtual(provider VirtualConnectionProvider)

func (*Service) Storage added in v0.1.72

func (s *Service) Storage(ctx context.Context) StorageInfo

func (*Service) Update

func (s *Service) Update(ctx context.Context, id string, body map[string]any) (*models.Connection, error)

func (*Service) Validate added in v0.1.72

func (s *Service) Validate(ctx context.Context, options ValidateOptions) (ValidationResult, error)

type StorageInfo added in v0.1.72

type StorageInfo struct {
	Layers       []StorageLayer `json:"layers"`
	DefaultLayer string         `json:"defaultLayer"`
	KEK          KEKStatus      `json:"kek"`
}

type StorageLayer added in v0.1.72

type StorageLayer struct {
	Name     string `json:"name"`
	Label    string `json:"label"`
	Path     string `json:"path,omitempty"`
	Writable bool   `json:"writable"`
}

type StoreProvider added in v0.1.64

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

StoreProvider exposes a layered connection store (connection/store) to the connection service: it lists and resolves every layer's connections and writes those of its WriteLayer as typed Connection files.

func NewStoreProvider added in v0.1.64

func NewStoreProvider(options StoreProviderOptions) (*StoreProvider, error)

NewStoreProvider is the provider over options.Store, writing to its options.WriteLayer layer.

func (*StoreProvider) DefaultLayer added in v0.1.72

func (p *StoreProvider) DefaultLayer() string

func (*StoreProvider) DeleteConnection added in v0.1.64

func (p *StoreProvider) DeleteConnection(ctx context.Context, id string) error

DeleteConnection removes the write layer's file for the connection id names.

func (*StoreProvider) ListConnections added in v0.1.64

func (p *StoreProvider) ListConnections() ([]*models.Connection, error)

func (*StoreProvider) ResolveConnection added in v0.1.64

func (p *StoreProvider) ResolveConnection(_ dbcontext.Context, reference string) (*models.Connection, error)

func (*StoreProvider) SaveConnection added in v0.1.64

func (p *StoreProvider) SaveConnection(ctx context.Context, connection *models.Connection) (*models.Connection, error)

SaveConnection creates connection (a zero ID) or updates the connection its ID names, renaming its file when its name changes.

func (*StoreProvider) StorageLayers added in v0.1.72

func (p *StoreProvider) StorageLayers() []StorageLayer

func (*StoreProvider) Writable added in v0.1.64

func (p *StoreProvider) Writable() bool

Writable reports whether the write layer's directory accepts files.

type StoreProviderOptions added in v0.1.64

type StoreProviderOptions struct {
	// Store holds the connection files, in layers.
	Store *store.Store
	// WriteLayer is the creation layer and default writable layer.
	WriteLayer string
	// WritableLayers permits editing existing files in these layers. Defaults to WriteLayer.
	WritableLayers []string
	// ValidateDelete, when set, may veto deleting a connection, such as one
	// the host's own configuration still names.
	ValidateDelete func(context.Context, models.Connection) error
}

StoreProviderOptions configure a StoreProvider.

type ValidateOptions added in v0.1.72

type ValidateOptions struct{ Reference string }

type ValidationResult added in v0.1.72

type ValidationResult struct {
	Name    string `json:"name"`
	OK      bool   `json:"ok"`
	Message string `json:"message"`
}

type VirtualConnectionProvider added in v0.1.29

type VirtualConnectionProvider interface {
	// ListConnections fails when the host cannot read its catalog, rather than
	// listing it as empty.
	ListConnections() ([]*models.Connection, error)
	// ResolveConnection takes the context for the same reason
	// dbcontext.ConnectionResolver does: a reference alone does not always
	// identify a connection, and the same provider answers it here and there.
	ResolveConnection(dbcontext.Context, string) (*models.Connection, error)
}

type WritableConnectionProvider added in v0.1.62

type WritableConnectionProvider interface {
	VirtualConnectionProvider
	Writable() bool
	SaveConnection(context.Context, *models.Connection) (*models.Connection, error)
	DeleteConnection(context.Context, string) error
}

WritableConnectionProvider persists host-owned connections outside the service's database. SaveConnection receives a complete connection, including preserved credentials; a zero ID creates an entry and a non-zero ID updates the existing entry.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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