Documentation
¶
Index ¶
- Constants
- Variables
- func FindConnection(ctx Context, name, namespace string) (*models.Connection, error)
- func FindConnectionByURL(ctx Context, connectionString string) (*models.Connection, error)
- func GetConfigMapFromCache(ctx Context, namespace, name, key string) (string, error)
- func GetConnection(ctx Context, name, namespace string) (*models.Connection, error)
- func GetEnvStringFromCache(ctx Context, env string, namespace string) (string, error)
- func GetEnvValueFromCache(ctx Context, input types.EnvVar, namespace string) (value string, err error)
- func GetHelmValueFromCache(ctx Context, namespace, releaseName, key string) (string, error)
- func GetHelmValuesFromCache(ctx Context, namespace, releaseName string) (map[string]any, error)
- func GetOnePasswordValueFromCache(ctx Context, ref string) (string, error)
- func GetSecretFromCache(ctx Context, namespace, name, key string) (string, error)
- func GetServiceAccountTokenFromCache(ctx Context, namespace, serviceAccount string) (string, error)
- func HydrateConnection(ctx Context, connection *models.Connection) (*models.Connection, error)
- func HydrateConnectionByURL(ctx Context, connectionString string) (*models.Connection, error)
- func InvalidateConfigMapCache(ctx Context, namespace, name, key string) error
- func InvalidateConnectionSecrets(ctx Context, connection *models.Connection) error
- func InvalidateSecretCache(ctx Context, namespace, name, key string) error
- func IsValidConnectionURL(connectionString string) bool
- func Objects(k gocontext.Context) []any
- func UpdateProperties(ctx Context, props map[string]string) error
- func UpdateProperty(ctx Context, key, value string) error
- type AnnotationsAccessor
- type ConnectionLeaseResolver
- type ConnectionResolver
- type Context
- func (k Context) AcquireConnectionLease(reference string) (func(), error)
- func (k Context) CanResolveConnectionReferences() bool
- func (k Context) ClearCache()
- func (ctx Context) ConnectionCacheIdentity(connectionString string) (string, error)
- func (k Context) ConnectionCacheScope() string
- func (k Context) ConnectionString() string
- func (k Context) Counter(name string, labels ...string) Counter
- func (k Context) DB() *gorm.DB
- func (k Context) EffectiveHARCollector(feature string, explicit *har.Collector) *har.Collector
- func (k Context) EffectiveHARLevel(feature string) (logger.LogLevel, string)
- func (k Context) EffectiveLogLevel(feature string) (logger.LogLevel, string)
- func (k Context) Fast(name ...string) Context
- func (k Context) FastDB(name ...string) *gorm.DB
- func (k Context) Gauge(name string, labels ...string) Gauge
- func (k Context) GetAnnotations() map[string]string
- func (k Context) GetConfigMapFromCache(namespace, name, key string) (string, error)
- func (ctx Context) GetConnection(name, namespace string) (*models.Connection, error)
- func (k Context) GetEnvStringFromCache(env string, namespace string) (string, error)
- func (k Context) GetEnvValueFromCache(input types.EnvVar, namespace string) (string, error)
- func (k Context) GetLabels() map[string]string
- func (k Context) GetLoggingContext() map[string]any
- func (k Context) GetName() string
- func (k Context) GetNamespace() string
- func (k Context) GetObjectMeta() metav1.ObjectMeta
- func (k Context) GetSecretFromCache(namespace, name, key string) (string, error)
- func (k Context) HARCollector() *har.Collector
- func (k Context) HARConfig(feature string) har.HARConfig
- func (k Context) HTTPLoggingContent(feature string) (headers bool, bodies bool)
- func (k Context) Histogram(name string, buckets []float64, labels ...string) Histogram
- func (k Context) HydrateConnection(connection *models.Connection) (*models.Connection, error)
- func (k Context) HydrateConnectionByURL(connectionString string) (*models.Connection, error)
- func (k Context) IsHARCaptureEnabled(feature string) bool
- func (k Context) IsHTTPLoggingEnabled(feature string) bool
- func (k Context) IsTracing() bool
- func (k Context) KubeAuthFingerprint() string
- func (k Context) Kubernetes() (*dutyKubernetes.Client, error)
- func (k Context) KubernetesConnection() KubernetesConnection
- func (k Context) LocalKubernetes(kubeconfigPaths ...string) (*dutyKubernetes.Client, error)
- func (ctx Context) Lookup(namespace string) *EnvVarSourceBuilder
- func (k Context) NewStructTemplater(vals map[string]any, requiredTag string, funcs map[string]any) gomplate.StructTemplater
- func (k Context) Objects() []any
- func (k Context) Oops(tags ...string) oops.OopsErrorBuilder
- func (k Context) Pool() *pgxpool.Pool
- func (k Context) Properties() Properties
- func (k Context) ResolveConnectionURL(raw, connType, namespace string) (string, error)
- func (k Context) RunTemplate(t gomplate.Template, env map[string]any) (string, error)
- func (k Context) RunTemplateBool(t gomplate.Template, env map[string]any) (bool, error)
- func (k Context) StartSpan(name string) (Context, trace.Span)
- func (k Context) String() string
- func (k Context) Subject() string
- func (k Context) Topology() any
- func (k Context) Transaction(fn func(ctx Context, span trace.Span) error, opts ...any) error
- func (k Context) Verbose() logger.Logger
- func (k Context) WithAnyValue(key, val any) Context
- func (k Context) WithAppendObject(object any) Context
- func (k Context) WithCancel() (Context, gocontext.CancelFunc)
- func (k Context) WithConnectionLeaseResolver(resolver ConnectionLeaseResolver) Context
- func (k Context) WithConnectionResolver(resolver ConnectionResolver) Context
- func (k Context) WithConnectionString(connectionString string) Context
- func (k Context) WithDB(db *gorm.DB, pool *pgxpool.Pool) Context
- func (k Context) WithDBLogLevel(level any) Context
- func (k Context) WithDBLogger(name string, baseLevel any) Context
- func (k Context) WithDeadline(deadline time.Time) (Context, gocontext.CancelFunc)
- func (k Context) WithDebug() Context
- func (k Context) WithHARCollector(collector *har.Collector) Context
- func (k Context) WithKubernetes(conn KubernetesConnection) Context
- func (k Context) WithLocalKubernetes(client *dutyKubernetes.Client) Context
- func (k Context) WithLoggingValues(args ...interface{}) Context
- func (k Context) WithName(name string) Context
- func (k Context) WithNamespace(namespace string) Context
- func (k Context) WithObject(object ...any) Context
- func (k Context) WithRequestHARLevel(level logger.LogLevel) Context
- func (k Context) WithSubject(subject string) Context
- func (k Context) WithTimeout(timeout time.Duration) (Context, gocontext.CancelFunc)
- func (k Context) WithTopology(topology any) Context
- func (k Context) WithTrace() Context
- func (k Context) WithValue(key, val any) Context
- func (k Context) WithoutName() Context
- func (k Context) WithoutTracing() Context
- func (k Context) Wrap(ctx gocontext.Context) Context
- func (k Context) WrapEcho(c echo.Context) Context
- type ContextAccessor
- type ContextAccessor2
- type Counter
- type EnvVarSourceBuilder
- func (b *EnvVarSourceBuilder) GetString() (string, error)
- func (b *EnvVarSourceBuilder) MustGetString() string
- func (b *EnvVarSourceBuilder) WithConfigMapKeyRef(name, key string) *EnvVarSourceBuilder
- func (b *EnvVarSourceBuilder) WithHelmRef(name, key string) *EnvVarSourceBuilder
- func (b *EnvVarSourceBuilder) WithSecretKeyRef(name, key string) *EnvVarSourceBuilder
- func (b *EnvVarSourceBuilder) WithServiceAccount(name string) *EnvVarSourceBuilder
- type Gauge
- type Gormable
- type Histogram
- type KubernetesClient
- type KubernetesConnection
- type LabelsAccessor
- type NameAccessor
- type NamespaceAccess
- type OnePasswordField
- type OnePasswordItem
- type OnePasswordVault
- type PKAccessor
- type Poolable
- type Properties
- func (p Properties) Duration(key string, def time.Duration) time.Duration
- func (p Properties) Int(key string, def int) int
- func (p Properties) Off(key string, def bool) bool
- func (p Properties) On(def bool, keys ...string) bool
- func (p Properties) String(key string, def string) string
- func (p Properties) SupportedProperties() map[string]PropertyType
- type PropertyType
Constants ¶
const HARMaxBodySizeDefault = 64 * 1024
HARMaxBodySizeDefault is the default per-entry body capture size for HAR.
Variables ¶
var ( ErrNotFound = errors.New("NOT_FOUND") ErrConnectionExpired = errors.New("connection expired") )
var LatencyBuckets = []float64{ float64(10 * time.Millisecond), float64(100 * time.Millisecond), float64(500 * time.Millisecond), float64(1 * time.Second), float64(10 * time.Second), }
var LongLatencyBuckets = []float64{ float64(1 * time.Second), float64(10 * time.Second), float64(100 * time.Second), float64(1000 * time.Second), }
var MetricsLogLevel = 5
var ShortLatencyBuckets = []float64{ float64(10 * time.Millisecond), float64(100 * time.Millisecond), float64(500 * time.Millisecond), }
var TemplateFuncs = make(map[string]func(Context) any)
Functions ¶
func FindConnection ¶
func FindConnection(ctx Context, name, namespace string) (*models.Connection, error)
FindConnection returns the connection with the given type and name
func FindConnectionByURL ¶
func FindConnectionByURL(ctx Context, connectionString string) (*models.Connection, error)
FindConnectionByURL retrieves a connection from the given connection string. The connection string is expected to be in one of the following forms:
- connection://<namespace>/<name> or connection://<name>
- the UUID of the connection.
func GetConfigMapFromCache ¶
func GetConnection ¶
func GetConnection(ctx Context, name, namespace string) (*models.Connection, error)
func GetEnvStringFromCache ¶
func GetEnvValueFromCache ¶
func GetHelmValueFromCache ¶
func GetHelmValuesFromCache ¶ added in v0.1.1
func GetOnePasswordValueFromCache ¶ added in v0.1.15
GetOnePasswordValueFromCache resolves a 1Password secret reference of the form op://<vault>/<item>/<field> to its value. A service-account token (the `1password.service-account-token` property, else the OP_SERVICE_ACCOUNT_TOKEN environment variable) selects non-interactive auth; without one the ambient `op` CLI session is used. Both paths shell out to `op read`.
func GetSecretFromCache ¶
func HydrateConnection ¶
func HydrateConnection(ctx Context, connection *models.Connection) (*models.Connection, error)
func HydrateConnectionByURL ¶
func HydrateConnectionByURL(ctx Context, connectionString string) (*models.Connection, error)
HydrateConnectionByURL retrieves a connection from the given connection string. The connection string is expected to be in one of the following forms:
- connection://<namespace>/<name> or connection://<name>
- the UUID of the connection.
func InvalidateConfigMapCache ¶ added in v0.1.15
func InvalidateConnectionSecrets ¶ added in v0.1.29
func InvalidateConnectionSecrets(ctx Context, connection *models.Connection) error
InvalidateConnectionSecrets drops every cached env value the connection resolves through, so an explicit re-check reads a rotated secret instead of serving the last one for the remainder of the cache TTL. Connection edits do not touch the referenced Secret or ConfigMap, so nothing else invalidates these entries.
func InvalidateSecretCache ¶ added in v0.1.15
InvalidateSecretCache and InvalidateConfigMapCache provide an explicit hook for controllers that observe Kubernetes resource-version changes.
func IsValidConnectionURL ¶
func UpdateProperty ¶
Types ¶
type AnnotationsAccessor ¶
type ConnectionLeaseResolver ¶ added in v0.1.29
type ConnectionResolver ¶ added in v0.1.29
type ConnectionResolver func(string) (*models.Connection, error)
type Context ¶
func New ¶
func New(opts ...commons.ContextOptions) Context
func NewContext ¶
func NewContext(baseCtx gocontext.Context, opts ...commons.ContextOptions) Context
func (Context) AcquireConnectionLease ¶ added in v0.1.29
func (Context) CanResolveConnectionReferences ¶ added in v0.1.29
CanResolveConnectionReferences reports whether this context owns connection reference resolution. Providers may also accept connection:// references and resolve them through a provider-specific seam.
func (Context) ClearCache ¶
func (k Context) ClearCache()
func (Context) ConnectionCacheIdentity ¶ added in v0.1.29
ConnectionCacheIdentity returns a credential-safe identity for metadata derived through this context. Stored references include their update time so an edit invalidates old metadata; inline URLs are hashed so credentials never become observable cache keys.
func (Context) ConnectionCacheScope ¶ added in v0.1.29
func (Context) ConnectionString ¶
ConnectionString returns the connection string for the database
func (Context) EffectiveHARCollector ¶ added in v0.1.13
EffectiveHARCollector resolves which HAR collector to use for a feature. An explicit collector always wins; otherwise the context-owned collector is returned only when the feature's level is >= Debug.
func (Context) EffectiveHARLevel ¶ added in v0.1.13
EffectiveHARLevel resolves the effective HAR capture level for a feature.
func (Context) EffectiveLogLevel ¶ added in v0.1.13
EffectiveLogLevel resolves the effective HTTP log level for a feature.
func (Context) FastDB ¶
FastDB returns a db suitable for high-performance usage, with limited logging and tracing
func (Context) GetAnnotations ¶
func (Context) GetConfigMapFromCache ¶
func (Context) GetConnection ¶
func (ctx Context) GetConnection(name, namespace string) (*models.Connection, error)
func (Context) GetEnvStringFromCache ¶
func (Context) GetEnvValueFromCache ¶
func (Context) GetLoggingContext ¶
func (Context) GetNamespace ¶
func (Context) GetObjectMeta ¶
func (k Context) GetObjectMeta() metav1.ObjectMeta
func (Context) GetSecretFromCache ¶
func (Context) HARCollector ¶ added in v0.1.13
HARCollector returns the context-held HAR collector, or nil when none is set.
func (Context) HARConfig ¶ added in v0.1.13
HARConfig returns the HAR capture configuration for a feature.
func (Context) HTTPLoggingContent ¶ added in v0.1.13
HTTPLoggingContent reports whether headers and bodies should be logged.
func (Context) HydrateConnection ¶
func (k Context) HydrateConnection(connection *models.Connection) (*models.Connection, error)
func (Context) HydrateConnectionByURL ¶
func (k Context) HydrateConnectionByURL(connectionString string) (*models.Connection, error)
func (Context) IsHARCaptureEnabled ¶ added in v0.1.13
IsHARCaptureEnabled reports whether HAR capture is on for a feature.
func (Context) IsHTTPLoggingEnabled ¶ added in v0.1.13
IsHTTPLoggingEnabled reports whether HTTP request logging is on for a feature.
func (Context) KubeAuthFingerprint ¶
KubeAuthFingerprint generates a unique SHA-256 hash to identify the Kubernetes API server and client authentication details from the REST configuration.
func (Context) Kubernetes ¶
func (k Context) Kubernetes() (*dutyKubernetes.Client, error)
func (Context) KubernetesConnection ¶
func (k Context) KubernetesConnection() KubernetesConnection
func (Context) LocalKubernetes ¶
func (k Context) LocalKubernetes(kubeconfigPaths ...string) (*dutyKubernetes.Client, error)
func (Context) Lookup ¶
func (ctx Context) Lookup(namespace string) *EnvVarSourceBuilder
func (Context) NewStructTemplater ¶
func (Context) Properties ¶
func (k Context) Properties() Properties
Properties returns a cached map of properties
func (Context) ResolveConnectionURL ¶ added in v0.1.15
ResolveConnectionURL resolves a literal/EnvVar URL and then expands workload references (svc://, ip://, proxy://, host://, portforward://) using namespace. It is the shared inline-connection counterpart of HydrateConnection.
func (Context) RunTemplate ¶
func (Context) RunTemplateBool ¶
func (Context) Transaction ¶
func (Context) WithAnyValue ¶
// Deprecated: use WithValue
func (Context) WithAppendObject ¶
func (Context) WithCancel ¶ added in v0.1.29
func (k Context) WithCancel() (Context, gocontext.CancelFunc)
WithCancel derives a context this caller can stop, keeping everything the parent carries — the database, the logger, the connection resolver and the rest of its values.
It is what a fan-out needs and neither WithTimeout nor WithDeadline can give it: work stopped by its siblings failing is stopped at no particular instant. Only the cancellation is swapped, because reconstructing the commons context would drop the debug and trace predicates it holds unexported.
func (Context) WithConnectionLeaseResolver ¶ added in v0.1.29
func (k Context) WithConnectionLeaseResolver(resolver ConnectionLeaseResolver) Context
func (Context) WithConnectionResolver ¶ added in v0.1.29
func (k Context) WithConnectionResolver(resolver ConnectionResolver) Context
func (Context) WithConnectionString ¶
WithConnectionString sets the connection string for the database
func (Context) WithDBLogLevel ¶
Changes the minimum log level for db statements
func (Context) WithDBLogger ¶
Returns a new named logger, the default db log level starts at INFO for DDL and then increases to TRACE1 depending on the query type and rows returned set a baseLevel at Debug, will increase all the levels by 1
func (Context) WithDeadline ¶
func (Context) WithHARCollector ¶ added in v0.1.13
WithHARCollector returns a copy of the context carrying a shared HAR collector that HTTP-based providers and connections record requests into.
func (Context) WithKubernetes ¶
func (k Context) WithKubernetes(conn KubernetesConnection) Context
func (Context) WithLocalKubernetes ¶
func (k Context) WithLocalKubernetes(client *dutyKubernetes.Client) Context
func (Context) WithLoggingValues ¶
func (Context) WithNamespace ¶
func (Context) WithObject ¶
Order the objects from parent -> child
func (Context) WithRequestHARLevel ¶ added in v0.1.29
WithRequestHARLevel raises HAR capture for this request without enabling the process-wide HTTP logger. Connection policies use it to collect exactly the detail that their configured log records need.
func (Context) WithTimeout ¶
func (Context) WithTopology ¶
func (Context) WithoutName ¶
func (Context) WithoutTracing ¶
type ContextAccessor ¶
type ContextAccessor2 ¶
type Counter ¶
type Counter struct {
Context Context
Name string
Labels map[string]string
Counter *prometheus.CounterVec
}
type EnvVarSourceBuilder ¶
type EnvVarSourceBuilder struct {
// contains filtered or unexported fields
}
func (*EnvVarSourceBuilder) GetString ¶
func (b *EnvVarSourceBuilder) GetString() (string, error)
func (*EnvVarSourceBuilder) MustGetString ¶
func (b *EnvVarSourceBuilder) MustGetString() string
func (*EnvVarSourceBuilder) WithConfigMapKeyRef ¶
func (b *EnvVarSourceBuilder) WithConfigMapKeyRef(name, key string) *EnvVarSourceBuilder
func (*EnvVarSourceBuilder) WithHelmRef ¶
func (b *EnvVarSourceBuilder) WithHelmRef(name, key string) *EnvVarSourceBuilder
func (*EnvVarSourceBuilder) WithSecretKeyRef ¶
func (b *EnvVarSourceBuilder) WithSecretKeyRef(name, key string) *EnvVarSourceBuilder
func (*EnvVarSourceBuilder) WithServiceAccount ¶
func (b *EnvVarSourceBuilder) WithServiceAccount(name string) *EnvVarSourceBuilder
type Gauge ¶
type Histogram ¶
type Histogram struct {
Context Context
Name string
Histogram *prometheus.HistogramVec
Labels map[string]string
}
type KubernetesClient ¶
type KubernetesClient struct {
*dutyKubernetes.Client
Connection KubernetesConnection
// contains filtered or unexported fields
}
func NewKubernetesClient ¶
func NewKubernetesClient(ctx Context, conn KubernetesConnection, cacheKeys ...string) (*KubernetesClient, error)
func (*KubernetesClient) DutyClient ¶ added in v0.1.15
func (c *KubernetesClient) DutyClient() *dutyKubernetes.Client
func (*KubernetesClient) HasExpired ¶
func (c *KubernetesClient) HasExpired() bool
func (*KubernetesClient) Refresh ¶
func (c *KubernetesClient) Refresh(ctx Context) (*rest.Config, error)
func (*KubernetesClient) SetLogger ¶
func (c *KubernetesClient) SetLogger(log logger.Logger)
type KubernetesConnection ¶
type LabelsAccessor ¶
type NameAccessor ¶
type NameAccessor interface {
GetName() string
}
type NamespaceAccess ¶
type NamespaceAccess interface {
GetNamespace() string
}
type OnePasswordField ¶ added in v0.1.29
type OnePasswordField struct {
ID string `json:"id"`
Label string `json:"label"`
Reference string `json:"reference"`
Section string `json:"section,omitempty"`
}
func ListOnePasswordFields ¶ added in v0.1.29
func ListOnePasswordFields(ctx Context, vaultID, itemID string) ([]OnePasswordField, error)
type OnePasswordItem ¶ added in v0.1.29
func ListOnePasswordItems ¶ added in v0.1.29
func ListOnePasswordItems(ctx Context, vaultID string) ([]OnePasswordItem, error)
type OnePasswordVault ¶ added in v0.1.29
func ListOnePasswordVaults ¶ added in v0.1.29
func ListOnePasswordVaults(ctx Context) ([]OnePasswordVault, error)
type PKAccessor ¶
type PKAccessor interface {
PK() string
}
type Properties ¶
func (Properties) Off ¶
func (p Properties) Off(key string, def bool) bool
Returns true if the property is false|disabled|off, if there is no property it defaults to true
func (Properties) On ¶
func (p Properties) On(def bool, keys ...string) bool
Returns true if the property is true|enabled|on, if there is no property it defaults to true
func (Properties) SupportedProperties ¶
func (p Properties) SupportedProperties() map[string]PropertyType