config

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 11 Imported by: 7

Documentation

Overview

Package config loads and understands the tegola config format.

Index

Constants

View Source
const (
	BboxToken             = "!BBOX!"
	ZoomToken             = "!ZOOM!"
	XToken                = "!X!"
	YToken                = "!Y!"
	ZToken                = "!Z!"
	ScaleDenominatorToken = "!SCALE_DENOMINATOR!"
	PixelWidthToken       = "!PIXEL_WIDTH!"
	PixelHeightToken      = "!PIXEL_HEIGHT!"
	IdFieldToken          = "!ID_FIELD!"
	GeomFieldToken        = "!GEOM_FIELD!"
	GeomTypeToken         = "!GEOM_TYPE!"
)

Variables

View Source
var ReservedTokens = map[string]struct{}{
	BboxToken:             {},
	ZoomToken:             {},
	XToken:                {},
	YToken:                {},
	ZToken:                {},
	ScaleDenominatorToken: {},
	PixelWidthToken:       {},
	PixelHeightToken:      {},
	IdFieldToken:          {},
	GeomFieldToken:        {},
	GeomTypeToken:         {},
}

ReservedTokens for query injection

Functions

func ValidateAndRegisterParams added in v0.17.0

func ValidateAndRegisterParams(mapName string, params []provider.QueryParameter) error

ValidateAndRegisterParams ensures configured params don't conflict with existing query tokens or have overlapping names

Types

type Config

type Config struct {
	// the tile buffer to use
	TileBuffer *env.Int `toml:"tile_buffer"`
	// LocationName is the file name or http server that the config was read from.
	// If this is an empty string, it means that the location was unknown. This is the case if
	// the Parse() function is used directly.
	LocationName string
	Webserver    Webserver `toml:"webserver"`
	Cache        env.Dict  `toml:"cache"`
	Observer     env.Dict  `toml:"observer"`
	// Map of providers.
	//  all providers must have at least two entries.
	// 1. name -- this is the name that is referenced in
	// the maps section
	// 2. type -- this is the name the provider modules register
	// themselves under. (e.g. postgis, gpkg, mvt_postgis )
	// Note: Use the type to figure out if the provider is a mvt or std provider
	Providers []env.Dict     `toml:"providers"`
	Maps      []provider.Map `toml:"maps"`
}

Config represents a tegola config file.

func Load

func Load(location string) (conf Config, err error)

Load will load and parse the config file from the given location.

func LoadAndValidate added in v0.6.0

func LoadAndValidate(filename string) (cfg Config, err error)

LoadAndValidate will load the config from the given filename and validate it if it was able to load the file

func Parse

func Parse(reader io.Reader, location string) (conf Config, err error)

Parse will parse the Tegola config file provided by the io.Reader.

func (*Config) ConfigureTileBuffers added in v0.9.0

func (c *Config) ConfigureTileBuffers()

ConfigureTileBuffers handles setting the tile buffer for a Map

func (*Config) Validate

func (c *Config) Validate() error

Validate checks the config for issues

type ErrInvalidHeader added in v0.8.0

type ErrInvalidHeader struct {
	Header string
}

func (ErrInvalidHeader) Error added in v0.8.0

func (e ErrInvalidHeader) Error() string

type ErrInvalidLayerZoom added in v0.7.0

type ErrInvalidLayerZoom struct {
	ProviderLayer string
	MinZoom       bool
	Zoom          int
	ZoomLimit     int
}

func (ErrInvalidLayerZoom) Error added in v0.7.0

func (e ErrInvalidLayerZoom) Error() string

type ErrInvalidProviderForMap added in v0.12.0

type ErrInvalidProviderForMap struct {
	MapName      string
	ProviderName string
}

func (ErrInvalidProviderForMap) Error added in v0.12.0

func (e ErrInvalidProviderForMap) Error() string

type ErrInvalidProviderLayerName

type ErrInvalidProviderLayerName struct {
	ProviderLayerName string
}

func (ErrInvalidProviderLayerName) Error

type ErrInvalidURIPrefix added in v0.10.0

type ErrInvalidURIPrefix string

func (ErrInvalidURIPrefix) Error added in v0.10.0

func (e ErrInvalidURIPrefix) Error() string

type ErrMVTDifferentProviders added in v0.12.0

type ErrMVTDifferentProviders struct {
	Original string
	Current  string
}

ErrMVTDifferentProviders represents when there are two different MVT providers in a map definition. MVT providers have to be unique per map definition

func (ErrMVTDifferentProviders) Error added in v0.12.0

func (e ErrMVTDifferentProviders) Error() string

type ErrMapNotFound

type ErrMapNotFound struct {
	MapName string
}

func (ErrMapNotFound) Error

func (e ErrMapNotFound) Error() string

type ErrMissingEnvVar added in v0.6.0

type ErrMissingEnvVar struct {
	EnvVar string
}

ErrMissingEnvVar represents an environmental variable the system was unable to find in the environment

func (ErrMissingEnvVar) Error added in v0.6.0

func (e ErrMissingEnvVar) Error() string

type ErrMixedProviders added in v0.12.0

type ErrMixedProviders struct {
	Map string
}

ErrMixedProviders represents the user configuration issue of using an MVT provider with another provider

func (ErrMixedProviders) Error added in v0.12.0

func (e ErrMixedProviders) Error() string

type ErrOverlappingLayerZooms

type ErrOverlappingLayerZooms struct {
	ProviderLayer1 string
	ProviderLayer2 string
}

func (ErrOverlappingLayerZooms) Error

func (e ErrOverlappingLayerZooms) Error() string

type ErrParamBadTokenName added in v0.17.0

type ErrParamBadTokenName struct {
	MapName   string
	Parameter provider.QueryParameter
}

func (ErrParamBadTokenName) Error added in v0.17.0

func (e ErrParamBadTokenName) Error() string

type ErrParamDuplicateName added in v0.17.0

type ErrParamDuplicateName struct {
	MapName   string
	Parameter provider.QueryParameter
}

func (ErrParamDuplicateName) Error added in v0.17.0

func (e ErrParamDuplicateName) Error() string

type ErrParamDuplicateToken added in v0.17.0

type ErrParamDuplicateToken struct {
	MapName   string
	Parameter provider.QueryParameter
}

func (ErrParamDuplicateToken) Error added in v0.17.0

func (e ErrParamDuplicateToken) Error() string

type ErrParamInvalidDefault added in v0.17.0

type ErrParamInvalidDefault struct {
	MapName   string
	Parameter provider.QueryParameter
}

func (ErrParamInvalidDefault) Error added in v0.17.0

func (e ErrParamInvalidDefault) Error() string

type ErrParamTokenReserved added in v0.17.0

type ErrParamTokenReserved struct {
	MapName   string
	Parameter provider.QueryParameter
}

func (ErrParamTokenReserved) Error added in v0.17.0

func (e ErrParamTokenReserved) Error() string

type ErrParamTwoDefaults added in v0.17.0

type ErrParamTwoDefaults struct {
	MapName   string
	Parameter provider.QueryParameter
}

func (ErrParamTwoDefaults) Error added in v0.17.0

func (e ErrParamTwoDefaults) Error() string

type ErrParamUnknownType added in v0.17.0

type ErrParamUnknownType struct {
	MapName   string
	Parameter provider.QueryParameter
}

func (ErrParamUnknownType) Error added in v0.17.0

func (e ErrParamUnknownType) Error() string

type ErrProviderNameDuplicate added in v0.12.0

type ErrProviderNameDuplicate struct {
	Pos int
}

ErrProviderNameDuplicate is returned when the name of a provider is duplicated in the provider list

func (ErrProviderNameDuplicate) Error added in v0.12.0

func (e ErrProviderNameDuplicate) Error() string

type ErrProviderNameRequired added in v0.12.0

type ErrProviderNameRequired struct {
	Pos int
}

ErrProviderNameRequired is returned when the name of a provider is missing from the provider list

func (ErrProviderNameRequired) Error added in v0.12.0

func (e ErrProviderNameRequired) Error() string

type ErrProviderTypeRequired added in v0.12.0

type ErrProviderTypeRequired struct {
	Pos int
}

ErrProviderTypeRequired is returned when the type of a provider is missing from the provider list

func (ErrProviderTypeRequired) Error added in v0.12.0

func (e ErrProviderTypeRequired) Error() string

type ErrUnknownProviderType added in v0.12.0

type ErrUnknownProviderType struct {
	Name           string // Name is the name of the entry in the config
	Type           string // Type is the name of the data provider
	KnownProviders []string
}

ErrUnknownProviderType is returned when the config contains a provider type that has not been registered

func (ErrUnknownProviderType) Error added in v0.12.0

func (e ErrUnknownProviderType) Error() string

func (ErrUnknownProviderType) Is added in v0.12.0

func (e ErrUnknownProviderType) Is(err error) bool

Is returns whether the error is of type ErrUnknownProviderType, only checking the Type value.

type Webserver

type Webserver struct {
	HostName      env.String `toml:"hostname"`
	Port          env.String `toml:"port"`
	URIPrefix     env.String `toml:"uri_prefix"`
	Headers       env.Dict   `toml:"headers"`
	SSLCert       env.String `toml:"ssl_cert"`
	SSLKey        env.String `toml:"ssl_key"`
	ProxyProtocol env.String `toml:"proxy_protocol"`
}

Webserver represents the config options for the webserver part of Tegola

Jump to

Keyboard shortcuts

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