config

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterTransformKind added in v0.2.0

func RegisterTransformKind(kind string)

RegisterTransformKind register new transformation in config validator

Types

type Bucket

type Bucket struct {
	Transform *Transform   `yaml:"transform,omitempty"`
	Storages  StorageTypes `yaml:"storages"`
	Keys      []S3Key      `yaml:"keys"`
	Name      string
}

Bucket describe single bucket entry in config

type Config

type Config struct {
	Buckets map[string]Bucket `yaml:"buckets"`
	Headers []HeaderYaml      `yaml:"headers"`
	Server  Server            `yaml:"server"`
	// contains filtered or unexported fields
}

Config contains configuration for buckets etc

Config should be used like singleton

func GetInstance

func GetInstance() *Config

GetInstance return single instance of Config object

func (*Config) BucketsByAccessKey

func (c *Config) BucketsByAccessKey(accessKey string) []Bucket

BucketsByAccessKey return list of buckets that have given accessKey

func (*Config) Load

func (c *Config) Load(filePath string) error

Load reads config data from file How configuration file should be formatted see README.md

func (*Config) LoadFromString

func (c *Config) LoadFromString(data string) error

LoadFromString parse configuration form string

type HeaderYaml

type HeaderYaml struct {
	StatusCodes []int             `yaml:"statusCodes"`
	Values      map[string]string `yaml:"values"`
}

HeaderYaml allow you to override response headers

type Preset

type Preset struct {
	Quality int    `yaml:"quality"`
	Format  string `yaml:"format"`
	Filters struct {
		Thumbnail *struct {
			Width  int    `yaml:"width"`
			Height int    `yaml:"height"`
			Mode   string `yaml:"mode"`
		} `yaml:"thumbnail,omitempty"`
		Interlace bool `yaml:"interlace"`
		Crop      *struct {
			Width   int    `yaml:"width"`
			Height  int    `yaml:"height"`
			Gravity string `yaml:"gravity"`
			Mode    string `yaml:"mode"`
		} `yaml:"crop,omitempty"`
		AutoRotate bool `yaml:"auto_rotate"`
		Grayscale  bool `yaml:"grayscale"`
		Strip      bool `yaml:"strip"`
		Blur       *struct {
			Sigma   float64 `yaml:"sigma"`
			MinAmpl float64 `yaml:"minAmpl"`
		} `yaml:"blur,omitempty"`
		Watermark *struct {
			Image    string  `yaml:"image"`
			Position string  `yaml:"position"`
			Opacity  float32 `yaml:"opacity"`
		} `yaml:"watermark,omitempty"`
		Rotate *struct {
			Angle int `yaml:"angle"`
		} `yaml:"rotate,omitempty"`
	} `yaml:"filters"`
}

Preset describe properties of transform preset

type S3Key

type S3Key struct {
	AccessKey       string `yaml:"accessKey"`
	SecretAccessKey string `yaml:"secretAccessKey"`
}

S3Key define credentials for s3 auth

type Server

type Server struct {
	InternalListen string   `yaml:"internalListen"`
	SingleListen   string   `yaml:"listen"`
	CacheSize      int64    `yaml:"cacheSize"`
	RequestTimeout int      `yaml:"requestTimeout"`
	QueueLen       int      `yaml:"queueLen"`
	Listen         []string `yaml:"listens"`
	Monitoring     string   `yaml:"monitoring"`
}

Server configure HTTP server

type Storage

type Storage struct {
	RootPath        string            `yaml:"rootPath,omitempty"`        // root path for local-* storage
	Kind            string            `yaml:"kind"`                      // type of storage from list ("local", "local-meta", "s3", "http", "noop")
	Url             string            `yaml:"url,omitempty"`             // Url for http storage
	Headers         map[string]string `yaml:"headers,omitempty"`         // request headers for http storage
	AccessKey       string            `yaml:"accessKey,omitempty"`       // access key for s3 storage
	SecretAccessKey string            `yaml:"secretAccessKey,omitempty"` // SecretAccessKey for s3 storage
	Region          string            `yaml:"region,omitempty"`          // region for s3 storage
	Endpoint        string            `yaml:"endpoint,omitempty"`        // endpoint for s3 storage
	PathPrefix      string            `yaml:"pathPrefix,omitempty"`      // prefix in path for all storage
	Bucket          string            `yaml:"bucket"`
	Hash            string            // unique hash for given storage
}

Storage contains information about kind of used storage

type StorageTypes

type StorageTypes map[string]Storage

StorageTypes contains map of storage for bucket

func (*StorageTypes) Basic

func (s *StorageTypes) Basic() Storage

Basic return storage that contains originals object

func (*StorageTypes) Get

func (s *StorageTypes) Get(name string) Storage

Get basic method for getting storage by name

func (*StorageTypes) Transform

func (s *StorageTypes) Transform() Storage

Transform return strorage in which we should storage processed objects

type Transform

type Transform struct {
	Path          string `yaml:"path"`
	ParentStorage string `yaml:"parentStorage"`
	ParentBucket  string `yaml:"parentBucket"`
	PathRegexp    *regexp.Regexp
	Kind          string            `yaml:"kind"`
	Presets       map[string]Preset `yaml:"presets"`
	CheckParent   bool              `yaml:"checkParent"`
	ResultKey     string            `yaml:"resultKey"`
}

Transform describe transform for bucket

Jump to

Keyboard shortcuts

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