config

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2020 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Config is the general configuration object
	Config RawConfig

	// CfgFile is the path to the config file
	CfgFile string
)

Functions

func InitConfig

func InitConfig()

InitConfig reads in config file and ENV variables if set.

func SplitURI

func SplitURI(uri string) (base string, name string)

SplitURI takes a given URI and splits it into a base URI and a local name

Types

type BuildVersionInfo

type BuildVersionInfo struct {
	Version    string `json:"version"`
	Commit     string `json:"commit"`
	BuildAgent string `json:"buildAgent"`
	BuildDate  string `json:"buildDate"`
	BuildID    string `json:"buildID"`
}

BuildVersionInfo holds all the version information

func NewBuildVersionInfo

func NewBuildVersionInfo(version, commit, buildagent, builddate string) *BuildVersionInfo

NewBuildVersionInfo creates a BuildVersionInfo struct

func (*BuildVersionInfo) JSON

func (b *BuildVersionInfo) JSON(pretty bool) ([]byte, error)

JSON returns a json version of the BuildVersionInfo

type Cache

type Cache struct {
	Enabled           bool   `json:"enabled"`
	LifeWindowMinutes int    `json:"lifeWindowMinutes"`
	APIPrefix         string `json:"apiPrefix"`
	StripPrefix       bool   `json:"stripPrefix"`
	CacheDomain       string `json:"cacheDomain"`
	HardMaxCacheSize  int    `json:"hardMaxCacheSize"`
	MaxEntrySize      int    `json:"maxEntrySize"`
}

Cache is the configuration of the BigCache implementation

type EAD

type EAD struct {
	CacheDir         string   `json:"cacheDir"`
	SearchURL        string   `json:"searchURL"`
	GenreFormDefault string   `json:"genreFormDefault"`
	TreeFields       []string `json:"treeFields"`
	SearchFields     []string `json:"searchFields"`
}

EAD holds all the configuration for the EAD endpoint

type ElasticSearch

type ElasticSearch struct {
	Urls               []string `json:"urls"`
	Enabled            bool     `json:"enabled"`
	IndexName          string   `json:"indexName"`
	Proxy              bool     `json:"proxy"`
	Fragments          bool     `json:"fragments"`
	IndexV1            bool     `json:"indexV1"` // exclusive with v2 indexing
	EnableTrace        bool     `json:"enableTrace"`
	EnableInfo         bool     `json:"enableInfo"`
	SpecKey            string   `json:"specKey"`
	RevisionKey        string   `json:"revisionKey"`
	OrgIDKey           string   `json:"orgIDKey"`
	UserName           string   `json:"userName"`
	Password           string   `json:"password"`
	FacetSize          int      `json:"facetSize"`
	MinimumShouldMatch string   `json:"minimumShouldMatch"`
	Workers            int      `json:"workers"`
	Shards             int      `json:"shards"`
	Replicas           int      `json:"replicas"`
	RequestTimeout     int      `json:"requestTimeout"`
	EnableSearchAfter  bool     `json:"enableSearchAfter"`
	TrackTotalHits     bool     `json:"trackTotalHits"`
	IndexTypes         []string
}

ElasticSearch holds all the configuration values It is bound by Viper.

func (*ElasticSearch) FragmentIndexName

func (es *ElasticSearch) FragmentIndexName() string

FragmentIndexName returns the name of the Fragment index.

func (*ElasticSearch) GetIndexName

func (es *ElasticSearch) GetIndexName() string

GetIndexName returns the lowercased indexname. This inforced correct behavior when creating an index in ElasticSearch.

func (*ElasticSearch) GetV1IndexName added in v0.1.8

func (es *ElasticSearch) GetV1IndexName() string

func (*ElasticSearch) HasAuthentication

func (es *ElasticSearch) HasAuthentication() bool

HasAuthentication returns if ElasticSearch has authentication enabled.

type HTTP

type HTTP struct {
	Port      int    `json:"port" mapstructure:"port"`
	StaticDir string `json:"staticDir"` // the relative path to the static directory to serve documentation.
}

HTTP holds all the configuration for the http server subcommand

type ImageProxy

type ImageProxy struct {
	Enabled     bool     `json:"enabled"`     // Make the imageproxy endpoint available
	CacheDir    string   `json:"cacheDir"`    // The path to the imageCache
	Referrer    []string `json:"referrer"`    // A list of allowed referrers. If empty allow all.
	Whitelist   []string `json:"whitelist"`   // A list of allowed remote hosts. If empty allow all.
	ScaleUp     bool     `json:"scaleUp"`     // Allow images to scale beyond their original dimensions.
	TimeOut     int      `json:"timeout"`     // timelimit for request served by this proxy. 0 is for no timeout
	Deepzoom    bool     `json:"deepzoom"`    // Enable deepzoom of remote images.
	ProxyPrefix string   `json:"proxyPrefix"` // The prefix where we mount the imageproxy. default: imageproxy. default: imageproxy.
}

ImageProxy holds all the configuration for the ImageProxy functionality

type LOD

type LOD struct {
	Enabled           bool   `json:"enabled"`        // Make the lod endpoint available
	Resource          string `json:"resource"`       // the 303 redirect entry point. This is where the content negotiation happens
	HTML              string `json:"html"`           // the endpoint that renders the data as formatted HTML
	RDF               string `json:"rdf"`            // the endpoint that renders the RDF data in the requested RDF format. Currently, JSON-LD and N-triples are supported
	SingleEndpoint    string `json:"singleEndpoint"` // when this is set it overrides the other endpoints
	HTMLRedirectRegex string `json:"redirectregex"`  // the regular expression to convert the subject uri to the uri for the external Page view
}

LOD holds all the configuration for the Linked Open Data (LOD) functionality

type Logging

type Logging struct {
	DevMode   bool   `json:"devmode"`
	SentryDSN string `json:"sentrydsn"`
	Level     string `json:"level"`
}

Logging holds all the logging and path configuration

type NameSpace

type NameSpace struct {
	Base   string `json:"base"`
	Prefix string `json:"prefix"`
}

NameSpace is a container for Namespaces base URLs and prefixes This is used by resolving namespaces in the RDF conversions

type NameSpaceMap

type NameSpaceMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

NameSpaceMap contains all the namespaces

func NewConfigNameSpaceMap

func NewConfigNameSpaceMap(c *RawConfig) *NameSpaceMap

NewConfigNameSpaceMap creates a map from the NameSpaces defined in the config

func NewNameSpaceMap

func NewNameSpaceMap() *NameSpaceMap

NewNameSpaceMap creates a new NameSpaceMap

func (*NameSpaceMap) Add

func (n *NameSpaceMap) Add(prefix, base string)

Add adds a namespace to the namespace Map

func (*NameSpaceMap) AddNameSpace

func (n *NameSpaceMap) AddNameSpace(ns NameSpace)

AddNameSpace is a convenience function to add NameSpace objects to the Map

func (*NameSpaceMap) ByPrefix

func (n *NameSpaceMap) ByPrefix() map[string]string

ByPrefix returns the map with prefixes as keys

func (*NameSpaceMap) DeleteBaseURI

func (n *NameSpaceMap) DeleteBaseURI(base string)

DeleteBaseURI removes a namespace from the NameSpaceMap

func (*NameSpaceMap) DeletePrefix

func (n *NameSpaceMap) DeletePrefix(prefix string)

DeletePrefix removes a namespace from the NameSpaceMap

func (*NameSpaceMap) GetBaseURI

func (n *NameSpaceMap) GetBaseURI(prefix string) (base string, ok bool)

GetBaseURI returns the base URI from the prefix

func (*NameSpaceMap) GetPrefix

func (n *NameSpaceMap) GetPrefix(baseURI string) (prefix string, ok bool)

GetPrefix returns the prefix for a base URI

func (*NameSpaceMap) GetSearchLabel

func (n *NameSpaceMap) GetSearchLabel(uri string) (string, error)

GetSearchLabel returns the search label for a Predicate URI

func (*NameSpaceMap) Len

func (n *NameSpaceMap) Len() (int, int)

Len counts the number of keys in the Map

func (*NameSpaceMap) Load

func (n *NameSpaceMap) Load(c *RawConfig)

Load loads the namespaces from the config object

type OAIPMH

type OAIPMH struct {
	// Make the oai-pmh endpoint available
	Enabled bool `json:"enabled"`
	// AdminEmails has a list of the admin emails of this endpoint
	AdminEmails []string `json:"adminEmails"`
	// RepositoryName is the name of the OAI-PMH repossitory
	RepositoryName string `json:"repositoryName"`
}

OAIPMH holds all the configuration options for the OAI-PMH endpoint

type PostHook

type PostHook struct {
	ExcludeSpec []string `json:"excludeSpec"`
	URLs        []string `json:"urLs"`
}

PostHook contains the configuration for the JSON-LD posthook configuration

type RDF

type RDF struct {
	SparqlEnabled    bool   `json:"sparqlEnabled"`    // Enable the SPARQL proxy
	SparqlHost       string `json:"sparqlHost"`       // the base-url to the SPARQL endpoint including the scheme and the port
	SparqlPath       string `json:"sparqlPath"`       // the relative path of the endpoint. This can should contain the database name that is injected when the sparql endpoint is build
	SparqlUpdatePath string `json:"sparqlUpdatePath"` // the relative path of the update endpoint. This can should contain the database name that is injected when the sparql endpoint is build
	GraphStorePath   string `json:"dataPath"`         // the relative GraphStore path of the endpoint. This can should contain the database name that is injected when the sparql endpoint is build
	BaseURL          string `json:"baseUrl"`          // the RDF baseUrl used for minting new URIs (should not include scheme)
	BaseScheme       string `json:"baseScheme"`       // the scheme (http or https) used in the baseURL
	RDFStoreEnabled  bool   `json:"rdfStoreEnabled"`  // Store to Triple Store while saving RDF
	// the RDF entryPoints. Lookups are made on the fully qualified URIs. It is sometimes needed to support other baseUrls as well.
	// The entry-points need to be fully qualified, i.e. with their scheme.
	RoutedEntryPoints []string `json:"RoutedEntryPoints"`
	Tags              string   `json:"tags" mapstructure:"tags"`
	DefaultFormat     string   `json:"defaultFormat"`
	RDFStoreTags      []string `json:"rdfStoreTags"` // the tags that trigger storage in the triple-store
}

RDF holds all the configuration for SPARQL queries and RDF conversions

func (*RDF) HasStoreTag

func (rdf *RDF) HasStoreTag(tags []string) bool

type RDFTag

type RDFTag struct {
	Title            []string `json:"title"`
	Label            []string `json:"label"`
	Owner            []string `json:"owner"`
	Thumbnail        []string `json:"thumbnail"`
	LandingPage      []string `json:"landingPage"`
	Description      []string `json:"description"`
	Subject          []string `json:"subject"`
	Date             []string `json:"date"`
	Collection       []string `json:"collection"`
	SubCollectection []string `json:"subCollectection"`
	ObjectType       []string `json:"objectType"`
	ObjectID         []string `json:"objectID"`
	Creator          []string `json:"creator"`
	LatLong          []string `json:"latLong"`
	IsoDate          []string `json:"isoDate"`
	DateRange        []string `json:"dateRange"`
	Integer          []string `json:"integer"`
	IntegerRange     []string `json:"integerRange"`
}

RDFTag holds tag information how to tag predicate values

type RDFTagMap

type RDFTagMap struct {
	sync.RWMutex
	TagMap map[string][]string
}

RDFTagMap contains all the URIs that trigger indexing labels

func NewRDFTagMap

func NewRDFTagMap(c *RawConfig) *RDFTagMap

NewRDFTagMap return

func (*RDFTagMap) Get

func (rtm *RDFTagMap) Get(uri string) ([]string, bool)

Get returns the indexType label for a given URI

func (*RDFTagMap) Len

func (rtm *RDFTagMap) Len() int

Len return number of URIs in the RDFTagMap

type RawConfig

type RawConfig struct {
	OrgID         string `json:"orgId"`
	HTTP          `json:"http"`
	ElasticSearch `json:"elasticsearch"`
	Logging       `json:"logging"`
	RDF           `json:"rdf"`
	OAIPMH        `json:"oaipmh"`
	WebResource   `json:"webresource"`
	ImageProxy    `json:"imageproxy"`
	LOD           `json:"lod"`
	NameSpaces    []NameSpace   `json:"namespaces"`
	NameSpaceMap  *NameSpaceMap `json:"nameSpaceMap"`
	RDFTag        `json:"rdftag"`
	PostHook      `json:"postHook"`
	Cache         `json:"cache"`
	RDFTagMap     *RDFTagMap `json:"rdfTagMap"`
	SiteMap       `json:"siteMap"`
	EAD           `json:"ead"`
	Logger        *zerolog.Logger
}

RawConfig holds all the configuration blocks. These are bound from cli, Environment variables or configuration files by Viper.

func (*RawConfig) GetGraphStoreEndpoint

func (c *RawConfig) GetGraphStoreEndpoint(dbName string) string

GetGraphStoreEndpoint builds the GraphStore endpoint from the RDF Config object. When the dbName is empty the OrgId from the configuration is used.

func (*RawConfig) GetSparqlEndpoint

func (c *RawConfig) GetSparqlEndpoint(dbName string) string

GetSparqlEndpoint builds the SPARQL endpoint from the RDF Config object. When the dbName is empty the OrgId from the configuration is used.

func (*RawConfig) GetSparqlUpdateEndpoint

func (c *RawConfig) GetSparqlUpdateEndpoint(dbName string) string

GetSparqlUpdateEndpoint builds the SPARQL Update endpoint from the RDF Config object. When the dbName is empty the OrgId from the configuration is used.

func (*RawConfig) Save

func (c *RawConfig) Save() error

Save saves the update version of the configuration file At the moment this is mostly used for persisting the namespaces

type SiteMap

type SiteMap struct {
	Enabled bool   `json:"enabled"`
	BaseDir string `json:"baseDir"`
	BaseURL string `json:"baseURL"`
	Gzip    bool   `json:"gzip"`
}

SiteMap holds all the configuration for the sitemap generation

type WebResource

type WebResource struct {
	Enabled          bool   `json:"enabled"`   // Make the webresource endpoint available
	WebResourceDir   string `json:"sourceDir"` // Target directory for the webresources
	CacheResourceDir string `json:"cacheDir"`  // cache directory for the webresources

	MediaManagerHost          string `json:"mediaManagerHost"` // the domain to build the derivatives
	SmallDefault              string `json:"smallDefault"`
	MediumDefault             string `json:"mediumDefault"`
	LargeDefault              string `json:"largeDefault"`
	MaxSize                   int32  `json:"maxSize"`
	ResolveRemoteWebResources bool   `json:"resolveRemoteWebResources"`
	// contains filtered or unexported fields
}

WebResource holds all the configuration options for the WebResource endpoint

Jump to

Keyboard shortcuts

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