config

package
v2.0.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2020 License: AGPL-3.0 Imports: 51 Imported by: 518

Documentation

Overview

Package config provides tools for managing configurations

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultCaUrl        = "https://acme-v02.api.letsencrypt.org/directory"
	DefaultCaStagingUrl = "https://acme-staging-v02.api.letsencrypt.org/directory"
)
View Source
var (
	PydioConfigDir  = ApplicationWorkingDir()
	PydioConfigFile = "pydio.json"

	VersionsStore file2.VersionsStore
)
View Source
var SampleConfig = `{
    "ports":{
        "nats": 4222
    },
    "frontend":{
        "secureHeaders":{
			"X-XSS-Protection": "1; mode=block"
		},
        "plugin": {
            "editor.libreoffice": {
                "LIBREOFFICE_HOST": "localhost",
                "LIBREOFFICE_PORT": "9980",
                "LIBREOFFICE_SSL": true
            }
        }
    },
    "services":{
        "pydio.grpc.config":{
            "dsn": "default"
        },
        "pydio.grpc.user":{
            "dsn": "default",
            "tables":{
                "tree": "idm_user_tree",
                "nodes":"idm_user_nodes",
                "roles":"idm_user_roles",
                "attributes":"idm_user_attributes"
            }
        },
		"pydio.grpc.mailer": {
			"queue": {
				"@value": "boltdb"
			},
			"sender": {
				"@value": "smtp",
				"host": "my.smtp.server",
				"password": "",
				"port": 465,
				"user": "name"
			}
		},
        "pydio.grpc.role":{
            "dsn": "default"
        },
        "pydio.grpc.workspace":{
            "dsn": "default"
        },
        "pydio.grpc.acl":{
            "dsn": "default"
        },
        "pydio.grpc.auth":{
            "dsn": "default",
            "dex" : {
                "issuer": "http://127.0.0.1:5556/dex",
                "web"   : {
                    "http": "0.0.0.0:5556"
                },
                "frontend" : {
                    "Dir" : "idm/auth/web"
                },
                "logger" : {
                    "level" : "debug",
                    "format": "text"
                },
				"expiry": {
					"idTokens": "10m"
				},
                "oauth2" : {
                    "responseTypes": ["code", "token", "id_token"],
					"skipApprovalScreen": true
                },
                "staticClients" : [
                    {
                        "id": "example-app",
                        "redirectURIs" : ["http://127.0.0.1:5555/callback"],
                        "name" : "Example App",
                        "secret" : "ZXhhbXBsZS1hcHAtc2VjcmV0"
                    }
                ],
                "connectors": [
                    {
                        "type": "pydio",
                        "id"  : "pydio",
                        "name": "Pydio Aggregation Connector",
                        "config": {
                            "pydioconnectors": [
                                {
                                    "type": "pydio-api",
                                    "name": "pydioapi",
                                    "id"  : 1
                                }
                            ]
                        }
                    }
                ]
            }
        },
        "pydio.grpc.tree":{
            "dsn":"default"
        },
        "pydio.grpc.meta":{
            "dsn":"default"
        },
        "pydio.thumbs_store":{
            "datasource" : "default",
            "bucket"     : "thumbs"
        },
        "pydio.docstore-binaries":{
            "datasource" : "default",
            "bucket"     : "binaries"
        },
        "pydio.versions-store":{
            "datasource" : "default",
            "bucket"     : "versions"
        },
        "pydio.grpc.search": {
            "indexContent": false
        },
		"pydio.grpc.policy": {
			"dsn": "databaseParseTime"
		},
        "pydio.grpc.data-key": {
            "dsn": "default"
        },
        "pydio.grpc.user-key": {
            "dsn": "default"
        },
        "pydio.grpc.changes": {
            "dsn": "default"
        },
		"pydio.grpc.update" : {
			"channel": "` + common.UpdateDefaultChannel + `",
			"publicKey": "` + common.UpdateDefaultPublicKey + `",
			"updateUrl": "` + common.UpdateDefaultServerUrl + `"
		},
		"pydio.grpc.user-meta": {
			"dsn": "default"
		},
        "pydio.grpc.tasks": {
            "fork": true
        },
		"pydio.web.oauth":{
			"cors": {
				"public": {
					"allowedOrigins": "*"
				}
			},
			"staticClients": [
				{
					"client_id": "cells-sync",
					"client_name": "CellsSync Application",
					"grant_types": [
						"authorization_code", 
						"refresh_token"
					],
					"redirect_uris": [
						"http://localhost:3000/servers/callback",
						"http://localhost:[3636-3666]/servers/callback"
					],
					"response_types": ["code", "token", "id_token"],
					"scope": "openid email profile pydio offline"
				},
				{
					"client_id": "cells-client",
					"client_name": "Cells Client CLI Tool",
					"grant_types": [
						"authorization_code",
						"refresh_token"
					],
					"redirect_uris": [
						"http://localhost:3000/servers/callback",
						"http://EXTERNAL_HOST/oauth2/oob"
					],
					"response_types": [
						"code",
						"token",
						"id_token"
					],
					"scope": "openid email profile pydio offline"
				},
				{
					"client_id": "cells-mobile",
					"client_name": "Mobile Applications",
					"grant_types": [
						"authorization_code",
						"refresh_token"
					],
					"redirect_uris": [
						"cellsauth://callback"
					],
					"response_types": [
						"code",
						"token",
						"id_token"
					],
					"scope": "openid email profile pydio offline"
				}
			]
		}
    }
}`

Functions

func ApplicationWorkingDir

func ApplicationWorkingDir(dirType ...ApplicationDirType) string

ApplicationWorkingDir creates a local file to store pydio system data

func Default

func Default() config.Config

Default Config with initialisation

func Del

func Del(path ...string)

func DelSecret added in v1.2.2

func DelSecret(uuid string)

func ExposedConfigsForService added in v1.2.2

func ExposedConfigsForService(serviceName string) common.XMLSerializableForm

ExposedConfigsForService returns exposed configs for service

func FactorizeMinioServers added in v1.2.2

func FactorizeMinioServers(existingConfigs map[string]*object.MinioConfig, newSource *object.DataSource, update bool) (config *object.MinioConfig)

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

func Get

func Get(path ...string) reader.Value

func GetDatabase

func GetDatabase(name string) (string, string)

GetDatabase retrieves the database data from the config

func GetDefaultDatabase

func GetDefaultDatabase() (string, string)

GetDefaultDatabase returns the information for the default database

func GetJsonPath added in v1.0.1

func GetJsonPath() string

GetJsonPath build path for json that contain the local config

func GetRemoteSource added in v1.2.2

func GetRemoteSource() bool

func GetSecret added in v1.2.2

func GetSecret(uuid string) reader.Value

func GetTLSClientConfig added in v1.2.2

func GetTLSClientConfig(t string) *tls.Config

GetTLSClientConfig returns the configuration ssl for a server handler.

func GetTLSServerConfig added in v1.2.2

func GetTLSServerConfig(t string) *tls.Config

GetTLSServerConfig returns the configuration ssl for a server handler

func IndexServiceTableNames added in v1.2.2

func IndexServiceTableNames(dsName string) map[string]string

func ListMinioConfigsFromConfig added in v1.2.2

func ListMinioConfigsFromConfig() map[string]*object.MinioConfig

ListMinioConfigsFromConfig scans configs for objects services configs

func ListSourcesFromConfig added in v1.2.2

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

ListSourcesFromConfig scans configs for sync services configs

func MinioConfigNamesToConfig added in v1.2.2

func MinioConfigNamesToConfig(sources map[string]*object.MinioConfig)

MinioConfigNamesToConfig saves objects sources to config

func NewKeyForSecret added in v1.2.2

func NewKeyForSecret() string

func RegisterExposedConfigs added in v1.2.2

func RegisterExposedConfigs(serviceName string, form common.XMLSerializableForm)

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

func RegisterVaultKey added in v1.2.2

func RegisterVaultKey(path ...string)

func ResetTlsConfigs

func ResetTlsConfigs()

func Save added in v1.0.1

func Save(ctxUser string, ctxMessage string) error

SaveConfigs sends configuration to a local file.

func ServiceDataDir

func ServiceDataDir(serviceName string) (string, error)

ServiceDataDir returns the applicationdir/services/serviceName and creates it if it does not exists

func Set

func Set(val interface{}, path ...string)

func SetSecret added in v1.2.2

func SetSecret(uuid string, val string)

func SourceNamesFiltered added in v1.2.4

func SourceNamesFiltered(names []string) []string

SourceNamesForDataServices excludes the timestamp key from a slice of source names

func SourceNamesForDataServices added in v1.2.4

func SourceNamesForDataServices(dataSrvType string) []string

SourceNamesForDataServices list sourceNames from the config, excluding the timestamp key

func SourceNamesFromDataConfigs added in v1.2.4

func SourceNamesFromDataConfigs(cfgMap common.ConfigValues) []string

SourceNamesForDataServices list sourceNames from the config, excluding the timestamp key

func SourceNamesToConfig added in v1.2.2

func SourceNamesToConfig(sources map[string]*object.DataSource)

SourceNamesToConfig saves index and sync sources to configs

func TouchSourceNamesForDataServices added in v1.2.4

func TouchSourceNamesForDataServices(dataSrvType string)

func UnusedMinioServers added in v1.2.2

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 UpgradeConfigsIfRequired added in v1.2.1

func UpgradeConfigsIfRequired(config *Config) (bool, error)

UpgradeConfigsIfRequired applies all registered configMigration functions Returns true if there was a change and save is required, error if something nasty happened

func Values

func Values(keys ...string) common.ConfigValues

func Vault added in v1.2.2

func Vault() config.Config

Vault Config with initialisation

func Watch added in v1.2.2

func Watch(path ...string) (config.Watcher, error)

Types

type ApplicationDirType

type ApplicationDirType int
const (
	ApplicationDirData ApplicationDirType = iota
	ApplicationDirLogs
	ApplicationDirServices
)

type Array

type Array []interface{}

func (Array) Scan

func (c Array) Scan(val interface{}) error

type Config

type Config struct {
	config.Config
}

Config wrapper around micro Config

func (*Config) Unmarshal

func (c *Config) Unmarshal(val interface{}) error

func (*Config) UnmarshalKey

func (c *Config) UnmarshalKey(key string, val interface{}) error

type Map

type Map map[string]interface{}

Map structure to store configuration

func NewMap

func NewMap(ms ...map[string]interface{}) *Map

NewMap variable

func (Map) Array

func (c Map) Array(key string) common.Scanner

func (Map) Bool

func (c Map) Bool(key string, def ...bool) bool

func (Map) Bytes

func (c Map) Bytes(key string, def ...[]byte) []byte

func (Map) Database

func (c Map) Database(k string) (string, string)

Database returns the driver and dsn in that order for the given key

func (Map) Del

func (c Map) Del(key string) error

Del deletes the values associated with key.

func (Map) Duration

func (c Map) Duration(key string, def ...string) time.Duration

func (Map) Get

func (c Map) Get(keys ...string) interface{}

Get retrieves the first value associated with the given key. If there are no values associated with the key, Get returns the empty string. To access multiple values, use the map directly.

func (Map) Int

func (c Map) Int(key string, def ...int) int

Int retrieves the value at the given key if it exists and performs best effort to cast it as an int. If no such key exists or if it cannot be cast as an int, it returns the default value if defined and 0 otherwise.

func (Map) Int64

func (c Map) Int64(key string, defaultValue ...int64) int64

Int64 retrieves the value at the given key if it exists and performs best effort to cast it as an int64. If no such key exists or if it cannot be cast as an int64, it returns the default value if defined and 0 otherwise.

func (Map) IsEmpty

func (c Map) IsEmpty() bool

func (Map) Map

func (c Map) Map(key string) map[string]interface{}

func (Map) Scan

func (c Map) Scan(val interface{}) error

func (Map) Set

func (c Map) Set(key string, value interface{}) error

Set sets the key to value. It replaces any existing values.

func (Map) String

func (c Map) String(key string, def ...string) string

func (Map) StringArray

func (c Map) StringArray(key string, def ...[]string) []string

func (Map) StringMap

func (c Map) StringMap(key string) map[string]string

func (Map) Values

func (c Map) Values(key string) common.ConfigValues

type MkCert

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

MkCert provides tooling for generating auto-certified certificate

func NewMkCert

func NewMkCert(storageLocation string) *MkCert

NewMkCert creates a new MkCert instance

func (*MkCert) GeneratedResources

func (m *MkCert) GeneratedResources() (certFile, keyFile, caFile, caKeyFile string)

GeneratedResources returns all files generated during certificate creation

func (*MkCert) MakeCert

func (m *MkCert) MakeCert(hosts []string) error

MakeCerts triggers the certificate generation process, using a list of known hosts

type Value

type Value interface {
	Bool(def bool) bool
	Int(def int) int
	Int64(def int64) int64
	String(def string) string
	Float64(def float64) float64
	Duration(def time.Duration) time.Duration
	StringSlice(def []string) []string
	StringMap(def map[string]string) map[string]string
	Scan(val interface{}) error
	Bytes() []byte
}

Value Represent a value retrieved from the values loaded

type Watcher

type Watcher interface {
	Next() (*micro.ChangeSet, error)
	Stop()
}

Directories

Path Synopsis
Package envvar implements Pydio specific interface for dynamic configurations that are backed by OS environment variables.
Package envvar implements Pydio specific interface for dynamic configurations that are backed by OS environment variables.
Package source implements a configuration client backed by a config server
Package source implements a configuration client backed by a config server

Jump to

Keyboard shortcuts

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