context

package
v1.0.292 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: Apache-2.0 Imports: 33 Imported by: 55

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("NOT_FOUND")
)
View Source
var Local map[string]string

Functions

func FindConnection added in v1.0.207

func FindConnection(ctx Context, connectionType, name, namespace string) (*models.Connection, error)

FindConnection returns the connection with the given type and name

func FindConnectionByURL added in v1.0.207

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 of the form: connection://<type>/<name>

func GetConfigMapFromCache added in v1.0.207

func GetConfigMapFromCache(ctx Context, namespace, name, key string) (string, error)

func GetConnection added in v1.0.207

func GetConnection(ctx Context, connectionType, name, namespace string) (*models.Connection, error)

func GetEnvStringFromCache added in v1.0.207

func GetEnvStringFromCache(ctx Context, env string, namespace string) (string, error)

func GetEnvValueFromCache added in v1.0.207

func GetEnvValueFromCache(ctx Context, input types.EnvVar, namespace string) (string, error)

func GetHelmValueFromCache added in v1.0.239

func GetHelmValueFromCache(ctx Context, namespace, releaseName, key string) (string, error)

func GetSecretFromCache added in v1.0.207

func GetSecretFromCache(ctx Context, namespace, name, key string) (string, error)

func GetServiceAccountTokenFromCache added in v1.0.233

func GetServiceAccountTokenFromCache(ctx Context, namespace, serviceAccount string) (string, error)

func HydrateConnection added in v1.0.207

func HydrateConnection(ctx Context, connection *models.Connection) (*models.Connection, error)

Create a cache with a default expiration time of 5 minutes, and which purges expired items every 10 minutes var connectionCache = cache.New(5*time.Minute, 10*time.Minute)

func HydrateConnectionByURL added in v1.0.216

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://<type>/<name> or connection://<type>/<namespace>/<name>
  • the UUID of the connection.

func IsValidConnectionURL added in v1.0.207

func IsValidConnectionURL(connectionString string) bool

func LoadPropertiesFromFile added in v1.0.259

func LoadPropertiesFromFile(ctx Context, filename string) error

func ParsePropertiesFile added in v1.0.259

func ParsePropertiesFile(filename string) (map[string]string, error)

func UpdateProperties added in v1.0.259

func UpdateProperties(ctx Context, props map[string]string) error

func UpdateProperty added in v1.0.259

func UpdateProperty(ctx Context, key, value string) error

Types

type Context

type Context struct {
	commons.Context
}

func New added in v1.0.253

func New(opts ...commons.ContextOptions) Context

func NewContext

func NewContext(baseCtx gocontext.Context, opts ...commons.ContextOptions) Context

func (Context) ClearCache added in v1.0.250

func (k Context) ClearCache()

func (Context) DB

func (k Context) DB() *gorm.DB

func (Context) FastDB added in v1.0.254

func (k Context) FastDB() *gorm.DB

FastDB returns a db suitable for high-performance usage, with limited logging

func (Context) GetAnnotations

func (k Context) GetAnnotations() map[string]string

func (Context) GetConfigMapFromCache

func (k Context) GetConfigMapFromCache(namespace, name, key string) (string, error)

func (Context) GetConnection added in v1.0.207

func (ctx Context) GetConnection(connectionType, name, namespace string) (*models.Connection, error)

func (Context) GetEnvStringFromCache

func (k Context) GetEnvStringFromCache(env string, namespace string) (string, error)

func (Context) GetEnvValueFromCache

func (k Context) GetEnvValueFromCache(input types.EnvVar, namespace ...string) (string, error)

func (Context) GetLabels

func (k Context) GetLabels() map[string]string

func (Context) GetName

func (k Context) GetName() string

func (Context) GetNamespace

func (k Context) GetNamespace() string

func (Context) GetObjectMeta

func (k Context) GetObjectMeta() metav1.ObjectMeta

func (Context) GetSecretFromCache

func (k Context) GetSecretFromCache(namespace, name, key string) (string, error)

func (Context) HydrateConnection

func (k Context) HydrateConnection(connection *models.Connection) (*models.Connection, error)

func (Context) HydrateConnectionByURL added in v1.0.216

func (k Context) HydrateConnectionByURL(connectionString string) (*models.Connection, error)

func (*Context) Kommons added in v1.0.202

func (k *Context) Kommons() *kommons.Client

func (*Context) Kubernetes

func (k *Context) Kubernetes() kubernetes.Interface

func (Context) Pool added in v1.0.197

func (k Context) Pool() *pgxpool.Pool

func (Context) Properties added in v1.0.245

func (k Context) Properties() map[string]string

Properties returns a cached map of properties

func (Context) StartSpan

func (k Context) StartSpan(name string) (Context, trace.Span)

func (Context) Topology added in v1.0.276

func (k Context) Topology() any

func (Context) User

func (k Context) User() *models.Person

func (Context) WithAnyValue added in v1.0.276

func (k Context) WithAnyValue(key, val any) Context

WithAnyValue is a wrapper around WithValue

func (Context) WithDB

func (k Context) WithDB(db *gorm.DB, pool *pgxpool.Pool) Context

func (Context) WithDBLogLevel added in v1.0.250

func (k Context) WithDBLogLevel(level string) Context

func (Context) WithDebug added in v1.0.254

func (k Context) WithDebug() Context

func (Context) WithKommons added in v1.0.202

func (k Context) WithKommons(client *kommons.Client) Context

func (Context) WithKubernetes

func (k Context) WithKubernetes(client kubernetes.Interface) Context

func (Context) WithNamespace added in v1.0.197

func (k Context) WithNamespace(namespace string) Context

func (Context) WithObject

func (k Context) WithObject(object metav1.ObjectMeta) Context

func (Context) WithTimeout added in v1.0.197

func (k Context) WithTimeout(timeout time.Duration) (Context, gocontext.CancelFunc)

func (Context) WithTopology added in v1.0.276

func (k Context) WithTopology(topology any) Context

func (Context) WithTrace added in v1.0.254

func (k Context) WithTrace() Context

func (Context) WithUser

func (k Context) WithUser(user *models.Person) Context

func (Context) Wrap added in v1.0.197

func (k Context) Wrap(ctx gocontext.Context) Context

type Gormable added in v1.0.227

type Gormable interface {
	DB() *gorm.DB
}

type Poolable added in v1.0.227

type Poolable interface {
	Pool() *pgxpool.Pool
}

Jump to

Keyboard shortcuts

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