config

package
v5.0.0-...-2679821 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Overview

Package config provides tools for managing configurations

Index

Constants

View Source
const (
	ContextKey configKey = iota
	VaultKey
	RevisionsKey
)
View Source
const (
	// KeyFrontPluginEnabled is the frontend config to enable/disable plugins
	KeyFrontPluginEnabled = "PYDIO_PLUGIN_ENABLED"
	// DefaultOAuthClientID set the default client id to use
	DefaultOAuthClientID = "cells-frontend"
)

Variables

View Source
var CustomValueDiffers []diff.ValueDiffer
View Source
var SampleConfig = `{
	"version": "` + common.Version().String() + `",
	"defaults": {
		"update": {
			"publicKey": "` + common.UpdateDefaultPublicKey + `",
			"updateUrl": "` + common.UpdateDefaultServerUrl + `"
		},
		"sites": [
		  {
			"Binds": [
			  "0.0.0.0:8080"
			],
			"Routing": [
			  {
				"Effect": 1,
				"Matcher": "*"
			  }
			],
			"TLSConfig": {
			  "SelfSigned": {}
			}
		  }
		],
        "telemetry": {
		  "loggers": [
			{
			  "encoding": "console",
			  "level": "info",
			  "outputs": [
				"stdout:///"
			  ]
			},
			{
			  "encoding": "json",
			  "level": "info",
			  "outputs": [
				"file://` + runtime.ApplicationWorkingDir(runtime.ApplicationDirLogs) + `/pydio.log",
				"service:///?service=pydio.grpc.log"
			  ]
			}
		  ],
		  "metrics": {
			"readers": []
		  },
		  "otelService": {
			"attributes": {
			  "deployment": "local"
			},
			"name": "cells"
		  },
		  "profiling": {
			"publishers": [
			  "pull://"
			]
		  },
		  "tracing": {
			"outputs": []
		  }
		}
	}
}`

SampleConfig is the default config used during the first install

Functions

func Del

func Del(ctx context.Context, path ...string)

Del value at a certain path TODO - surely there should be an error returned

func DelSecret

func DelSecret(ctx context.Context, uuid string) error

DelSecret deletes the value of a uuid in the vault

func ExposedConfigsForService

func ExposedConfigsForService(serviceName string) common.XMLSerializableForm

ExposedConfigsForService returns exposed configs for service

func FactorizeMinioServers

func FactorizeMinioServers(ctx context.Context, existingConfigs map[string]*object.MinioConfig, newSource *object.DataSource, update bool) (config *object.MinioConfig, e error)

FactorizeMinioServers tries to find exisiting MinioConfig that can be directly reused by the new source, or creates a new one

func Get

func Get(ctx context.Context, path ...string) configx.Values

Get access to the underlying structure at a certain path

func GetAndWatch

func GetAndWatch(ctx context.Context, store Store, configPath []string, callback func(values configx.Values))

GetAndWatch applies a callback on a current value, then watch for its changes and re-apply TODO : watcher should be cancellable with context

func GetDatabase

func GetDatabase(ctx context.Context, key string) (string, string)

GetDatabase retrieves the database data from the config

func GetMinioConfigForName

func GetMinioConfigForName(ctx context.Context, name string, skipSecret bool) *object.MinioConfig

func GetSecret

func GetSecret(ctx context.Context, uuid string) configx.Values

GetSecret returns the non encrypted value for a uuid

func GetSourceInfoByName

func GetSourceInfoByName(ctx context.Context, dsName string) (*object.DataSource, error)

func GetStorageDriver

func GetStorageDriver(store Store, configKey, serviceName string) (driver string, dsn string, defined bool)

GetStorageDriver looks up for a storage driver/dsn definition It may find databases/[(services/{serviceName}/storage)|{serviceName}|default]

func GetTLSClientConfig

func GetTLSClientConfig(ctx context.Context, t string) *tls.Config

GetTLSClientConfig returns the configuration ssl for a server handler.

func GetTLSServerConfig

func GetTLSServerConfig(ctx context.Context, t string) *tls.Config

GetTLSServerConfig returns the configuration ssl for a server handler

func GetUpdatesConfigs

func GetUpdatesConfigs(ctx context.Context) configx2.Values

GetUpdatesConfigs gather update configs from correct location

func HasDatabase

func HasDatabase(ctx context.Context, key string) bool

HasDatabase checks if DB key is set

func IndexServiceTableNames

func IndexServiceTableNames(dsName string) map[string]string

IndexServiceTableNames returns table names for indexes

func IsRestEditable

func IsRestEditable(path string) bool

IsRestEditable checks if the given path is allowed to be read/written via the REST API.

func ListMinioConfigsFromConfig

func ListMinioConfigsFromConfig(ctx context.Context, skipSecret ...bool) map[string]*object.MinioConfig

ListMinioConfigsFromConfig scans configs for objects services configs

func ListSourcesFromConfig

func ListSourcesFromConfig(ctx context.Context) map[string]*object.DataSource

ListSourcesFromConfig scans configs for sync services configs

func MinioConfigNamesToConfig

func MinioConfigNamesToConfig(ctx context.Context, sources map[string]*object.MinioConfig)

MinioConfigNamesToConfig saves objects sources to config

func NewKeyForSecret

func NewKeyForSecret() string

NewKeyForSecret creates a new random key

func PoolFromURL

func PoolFromURL[T any](ctx context.Context, u *url.URL, opener openurl.Opener[T]) map[string]*openurl.Pool[T]

func ReferencePoolOptionsFromURL

func ReferencePoolOptionsFromURL(ctx context.Context, u *url.URL) (opts []configx.Option)

ReferencePoolOptionsFromURL returns the options needed to set multiple reference pool in a config wrappedStore based on the wrappedStore url

eg. for a url mem://?pools=(urlencoded:rp=file:///tmp/example.json) it will open the config file:///tmp/example.json every time the reference pool rp is mentionned in the mem:// wrappedStore

func RegisterCustomValueDiffer

func RegisterCustomValueDiffer(differ diff.ValueDiffer)

func RegisterExposedConfigs

func RegisterExposedConfigs(serviceName string, form common.XMLSerializableForm)

RegisterExposedConfigs let services register specific forms for configs editions Used by discovery service

func RegisterProxy

func RegisterProxy(key string, interceptors ...interface{})

func RegisterRestEditablePath

func RegisterRestEditablePath(segments ...string)

RegisterRestEditablePath registers a config path that can be exposed and modified via the REST API

func RegisterVaultKey

func RegisterVaultKey(s ...string)

RegisterVaultKey adds a key to the configuration so that the value associated with the key is swapped to an encrypted value

func ResetTlsConfigs

func ResetTlsConfigs()

func RevisionsStore

func RevisionsStore(ctx context.Context) revisions.Store

func Save

func Save(ctx context.Context, ctxUser string, ctxMessage string) error

Save the config in the hard wrappedStore

func Set

func Set(ctx context.Context, val interface{}, path ...string) error

Set new values at a certain path

func SetDatabase

func SetDatabase(ctx context.Context, key string, driver string, dsn string, defaultsKey string) error

SetDatabase adds a database entry, plus an optional reference in the defaults

func SetSecret

func SetSecret(ctx context.Context, uuid string, val string) error

SetSecret set the value for a uuid in the vault

func SourceNamesFiltered

func SourceNamesFiltered(names []string) []string

SourceNamesFiltered excludes the timestamp key from a slice of source names

func SourceNamesForDataServices

func SourceNamesForDataServices(ctx context.Context, dataSrvType string) []string

SourceNamesForDataServices list sourceNames from the config, excluding the timestamp key

func SourceNamesFromDataConfigs

func SourceNamesFromDataConfigs(values configx.Values) []string

SourceNamesFromDataConfigs list sourceNames from the config, excluding the timestamp key

func SourceNamesToConfig

func SourceNamesToConfig(ctx context.Context, sources map[string]*object.DataSource)

SourceNamesToConfig saves index and sync sources to configs

func TouchSourceNamesForDataServices

func TouchSourceNamesForDataServices(ctx context.Context, dataSrvType string)

TouchSourceNamesForDataServices update the timestamp set with the source list

func UnusedMinioServers

func UnusedMinioServers(minios map[string]*object.MinioConfig, sources map[string]*object.DataSource) []string

UnusedMinioServers searches for existing minio configs that are not used anywhere in datasources

func Watch

func Watch(ctx context.Context, opts ...watch.WatchOption) (watch.Receiver, error)

Watch for config changes for a specific path or underneath

func WatchCombined

func WatchCombined(ctx context.Context, paths [][]string, opts ...watch.WatchOption) (watch.Receiver, error)

WatchCombined watches for different config paths

Types

type DistributedStore

type DistributedStore interface {
	NewLocker(name string) sync.Locker
}

type Getter

type Getter interface {
	Get() any
}

type Options

type Options struct {
	ReferencePool map[string]*openurl.Pool[Store]
}

type ProxyDeleter

type ProxyDeleter func(Store, ...string) error

type ProxyGetter

type ProxyGetter func(Store, ...string) configx.Values

type ProxySetter

type ProxySetter func(Store, interface{}, ...string) error

type RevisionsProvider

type RevisionsProvider interface {
	AsRevisionsStore(...RevisionsStoreOption) (Store, revisions.Store)
}

type RevisionsStoreOption

type RevisionsStoreOption func(o *RevisionsStoreOptions)

func WithDebounce

func WithDebounce(d time.Duration) RevisionsStoreOption

type RevisionsStoreOptions

type RevisionsStoreOptions struct {
	Debounce time.Duration
}

type Saver

type Saver interface {
	Save(string, string) error
}

type Store

type Store interface {
	configx.Storer
	watch.Watcher
	As(out any) bool
	Close(ctx context.Context) error
	Done() <-chan struct{}
	Saver
	sync.Locker
}

Store defines the functionality a config must provide

func NewStoreWithReferencePool

func NewStoreWithReferencePool(st Store, rp map[string]*openurl.Pool[Store]) Store

NewStoreWithReferencePool creates a new store

func NewVault

func NewVault(vaultStore, configStore Store) Store

NewVault creates a new vault with a standard config wrappedStore and a vault wrappedStore

func NewVersionStore

func NewVersionStore(vs revisions.Store, store Store) Store

NewVersionStore based on a file Version Store and a wrappedStore

func OpenStore

func OpenStore(ctx context.Context, urlstr string) (Store, error)

OpenStore opens the Store identified by the URL given. See the URLOpener documentation in driver subpackages for details on supported URL formats, and https://gocloud.dev/concepts/urls for more information.

func Proxy

func Proxy(store Store) Store

type URLMux

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

URLMux is a URL opener multiplexer. It matches the scheme of the URLs against a set of registered schemes and calls the opener that matches the URL's scheme. See https://gocloud.dev/concepts/urls/ for more information.

The zero value is a multiplexer with no registered schemes.

func DefaultURLMux

func DefaultURLMux() *URLMux

DefaultURLMux returns the URLMux used by OpenTopic and OpenSubscription.

Driver packages can use this to register their TopicURLOpener and/or SubscriptionURLOpener on the mux.

func (*URLMux) OpenStore

func (mux *URLMux) OpenStore(ctx context.Context, urlstr string) (Store, error)

OpenStore calls OpenURL with the URL parsed from urlstr. OpenStore is safe to call from multiple goroutines.

func (*URLMux) Register

func (mux *URLMux) Register(scheme string, opener URLOpener)

Register registers the opener with the given scheme. If an opener already exists for the scheme, Register panics.

func (*URLMux) Schemes

func (mux *URLMux) Schemes() []string

Schemes returns a sorted slice of the registered schemes.

func (*URLMux) ValidScheme

func (mux *URLMux) ValidScheme(scheme string) bool

ValidScheme returns true if scheme has been registered.

type URLOpener

type URLOpener interface {
	Open(ctx context.Context, urlstr string) (Store, error)
}

URLOpener represents types than can open Registries based on a URL. The opener must not modify the URL argument. OpenURL must be safe to call from multiple goroutines.

This interface is generally implemented by types in driver packages.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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