config

package
v8.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package config supports configuring the Vervet Underground service.

Index

Constants

View Source
const (
	// GeneratorScopeDefault indicates the default scope should be used in
	// configuration.
	GeneratorScopeDefault = ""

	// GeneratorScopeVersion indicates the generator operates on a single
	// resource version.
	GeneratorScopeVersion = "version"

	// GeneratorScopeResource indicates the generator operates on all versions
	// in a resource. This is useful for generating version routers, for
	// example.
	GeneratorScopeResource = "resource"
)

Variables

This section is empty.

Functions

func Save

func Save(w io.Writer, proj *Project) error

Save saves a Project configuration to YAML.

Types

type API

type API struct {
	Name      string         `json:"-"`
	Resources []*ResourceSet `json:"resources"`
	Overlays  []*Overlay     `json:"overlays"`
	Output    *Output        `json:"output"`
}

An API defines how and where to build versioned OpenAPI documents from a source collection of individual resource specifications and additional overlay content to merge.

type APIs

type APIs map[string]*API

APIs defines a named map of API instances.

type DiskConfig

type DiskConfig struct {
	Path string
}

DiskConfig defines configuration options for local disk storage.

type GcsConfig

type GcsConfig struct {
	Region    string
	Endpoint  string
	ProjectId string
	Filename  string
}

GcsConfig defines configuration options for Google Cloud Storage (GCS).

type Generator

type Generator struct {
	Name      string         `json:"-"`
	Scope     GeneratorScope `json:"scope"`
	Filename  string         `json:"filename,omitempty"`
	Template  string         `json:"template"`
	Files     string         `json:"files,omitempty"`
	Functions string         `json:"functions,omitempty"`
}

Generator describes how files are generated for a resource.

type GeneratorScope

type GeneratorScope string

GeneratorScope determines the template context when running the generator. Different scopes allow templates to operate over a single resource version, or all versions in a resource, for example.

type Generators

type Generators map[string]*Generator

Generators defines a named map of Generator instances.

func LoadGenerators

func LoadGenerators(r io.Reader) (Generators, error)

LoadGenerators loads Generators from their YAML representation.

type MergeConfig

type MergeConfig struct {
	ExcludePatterns vervet.ExcludePatterns
}

MergeConfig contains configuration options defining how to merge OpenAPI documents when collating aggregate OpenAPI specifications across all services.

type Output

type Output struct {
	Path  string   `json:"path,omitempty"`
	Paths []string `json:"paths,omitempty"`
}

Output defines where the aggregate versioned OpenAPI specs should be created during compilation.

func (*Output) ResolvePaths

func (o *Output) ResolvePaths() []string

EffectivePaths returns a slice of effective configured output paths, whether a single or multiple output paths have been configured.

type Overlay

type Overlay struct {
	Include string `json:"include"`
	Inline  string `json:"inline"`
}

An Overlay defines additional OpenAPI documents to merge into the aggregate OpenAPI spec when compiling an API. These might include special endpoints that should be included in the aggregate API but are not versioned, or top-level descriptions of the API itself.

type Project

type Project struct {
	Version    string     `json:"version"`
	Generators Generators `json:"generators,omitempty"`
	APIs       APIs       `json:"apis"`
}

Project defines collection of APIs and the standards they adhere to.

func Load

func Load(r io.Reader) (*Project, error)

Load loads a Project configuration from its YAML representation.

func (*Project) APINames

func (p *Project) APINames() []string

APINames returns the API names in deterministic ascending order.

type ResourceSet

type ResourceSet struct {
	Description string   `json:"description"`
	Path        string   `json:"path"`
	Excludes    []string `json:"excludes"`
}

A ResourceSet defines a set of versioned resources that adhere to the same standards.

Versioned resources are expressed as individual OpenAPI documents in a directory structure:

+-resource

|
+-2021-08-01
| |
| +-spec.yaml
| +-<implementation code, etc. can go here>
|
+-2021-08-15
| |
| +-spec.yaml
| +-<implementation code, etc. can go here>
...

Each YYYY-mm-dd directory under a resource is a version. The spec.yaml in each version is a complete OpenAPI document describing the resource at that version.

type S3Config

type S3Config struct {
	Region     string
	Endpoint   string
	AccessKey  string
	SecretKey  string
	SessionKey string
}

S3Config defines configuration options for AWS S3 storage.

type ServerConfig

type ServerConfig struct {
	Host     string
	Services []ServiceConfig
	Storage  StorageConfig
	Merging  MergeConfig
}

ServerConfig defines the configuration options for the Vervet Underground service.

func LoadServerConfig

func LoadServerConfig(configPaths ...string) (*ServerConfig, error)

LoadServerConfig returns a ServerConfig instance loaded from the given paths to a JSON config file.

func (*ServerConfig) ServiceFilter

func (c *ServerConfig) ServiceFilter() map[string]bool

ServiceFilter provides a map of service names to quickly filter old services.

type ServiceConfig

type ServiceConfig struct {
	Name string
	URL  string
}

ServiceConfig defines configuration options on a service.

type StorageConfig

type StorageConfig struct {
	Type           StorageType
	BucketName     string
	IamRoleEnabled bool
	S3             S3Config
	GCS            GcsConfig
	Disk           DiskConfig
}

StorageConfig defines the configuration options for storage. The value of Type determines which of S3 or GCS will be used.

type StorageType

type StorageType string

StorageType describes backend implementations supported by Vervet Underground.

const (
	StorageTypeDisk StorageType = "disk"
	StorageTypeS3   StorageType = "s3"
	StorageTypeGCS  StorageType = "gcs"
)

Jump to

Keyboard shortcuts

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