config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2021 License: MPL-2.0-no-copyleft-exception Imports: 20 Imported by: 1

Documentation

Index

Constants

View Source
const SessionErrorsKey = "errors"

SessionErrorsKey is the key used to retrieve the errors from the sessions table.

View Source
const SessionKey = "tinyci"

SessionKey is the name of the cookie where the session will be stored.

Variables

View Source
var DefaultEndpoint = ghoauth.Endpoint

DefaultEndpoint is the default endpoint for oauth2 operations.

View Source
var DefaultServices = AddressMap{
	Hook:       ServiceAddress{Port: 2020},
	Data:       ServiceAddress{Port: 6000},
	Queue:      ServiceAddress{Port: 6001},
	Asset:      ServiceAddress{Port: 6002},
	Repository: ServiceAddress{Port: 6003},
	Auth:       ServiceAddress{Port: 6004},
	Log:        ServiceAddress{Port: 6005},
	UI:         ServiceAddress{Port: 6010, HTTP: true},
}

DefaultServices is the standard array of service mappings when unconfigured.

View Source
var OAuthRepositoryScope = []string{"repo"}

OAuthRepositoryScope determines how to get enough information out of github to manipulate repositories. The default is to not ask for any real permissions; but for this behavior we need more than that.

View Source
var TestClientConfig = ClientConfig{
	Data:       DefaultServices.Data.String(),
	Queue:      DefaultServices.Queue.String(),
	UI:         DefaultServices.UI.String(),
	Asset:      DefaultServices.Asset.String(),
	Repository: DefaultServices.Repository.String(),
	Log:        DefaultServices.Log.String(),
	Auth:       DefaultServices.Auth.String(),
}

TestClientConfig is a default test client configuration

Functions

func DefaultGithubClient

func DefaultGithubClient(username string) github.Client

DefaultGithubClient returns the default github client set by SetDefaultGithubClient, if any.

func Parse

func Parse(filename string, obj interface{}) error

Parse parses a configuration file into an object; returns an error if necessary.

func SetDefaultGithubClient

func SetDefaultGithubClient(client github.Client, username string)

SetDefaultGithubClient sets the default github client which is necessary for many testing scenarios. Not to be used in typical code.

Types

type AddressMap

type AddressMap struct {
	Hook       ServiceAddress
	Data       ServiceAddress
	Queue      ServiceAddress
	UI         ServiceAddress
	Asset      ServiceAddress
	Repository ServiceAddress
	Auth       ServiceAddress
	Log        ServiceAddress
}

AddressMap is a mapping of service -> service address

type AuthConfig

type AuthConfig struct {
	SessionCryptKey   string              `yaml:"session_crypt_key"`
	TokenCryptKey     string              `yaml:"token_crypt_key"`
	FixedCapabilities map[string][]string `yaml:"fixed_capabilities"`
	// contains filtered or unexported fields
}

AuthConfig is the configuration for auth and secrets in the case auth isn't used.

func (*AuthConfig) ParseTokenKey

func (ac *AuthConfig) ParseTokenKey() error

ParseTokenKey reads the key from the config, validates it, and assigns it to the appropriate variables

func (*AuthConfig) ParsedSessionCryptKey

func (ac *AuthConfig) ParsedSessionCryptKey() []byte

ParsedSessionCryptKey returns the parsed session crypt key

func (*AuthConfig) Validate

func (ac *AuthConfig) Validate(parseCrypt bool) error

Validate ensures the auth configuration is sane.

type CertConfig

type CertConfig struct {
	CAFile   string `yaml:"ca"`
	CertFile string `yaml:"cert"`
	KeyFile  string `yaml:"key"`
}

CertConfig manages the configuration of client and server certs for handler services.

func (CertConfig) Load

func (cc CertConfig) Load() (*transport.Cert, error)

Load loads the cert based on the provided config and returns it.

func (*CertConfig) Validate

func (cc *CertConfig) Validate() error

Validate the certificate configuration (if supplied)

type ClientConfig

type ClientConfig struct {
	Data       string `yaml:"datasvc"`
	UI         string `yaml:"uisvc"`
	Queue      string `yaml:"queuesvc"`
	Asset      string `yaml:"assetsvc"`
	Log        string `yaml:"logsvc"`
	Repository string `yaml:"reposvc"`
	Auth       string `yaml:"authsvc"`

	Cert CertConfig `yaml:"tls"`
}

ClientConfig configures the clients

func (*ClientConfig) CreateClients

func (cc *ClientConfig) CreateClients(uc UserConfig, service string) (*Clients, error)

CreateClients creates all the clients that are populated in the clients struct. It will also tweak any settings for the github client.

func (*ClientConfig) Validate

func (cc *ClientConfig) Validate() error

Validate validates the client configuration to ensure basic needs are met.

type Clients

type Clients struct {
	Data  *data.Client
	Queue *queue.Client
	Asset *asset.Client
	Log   *log.SubLogger
	Auth  *auth.Client
}

Clients is a struct that encapsulates the various internal clients we use.

func (*Clients) CloseClients

func (c *Clients) CloseClients()

CloseClients closes all clients.

type OAuthConfig

type OAuthConfig struct {
	ClientID     string `yaml:"client_id"`
	ClientSecret string `yaml:"client_secret"`
	RedirectURL  string `yaml:"redirect_url"`
}

OAuthConfig configures the oauth end of the uiservice handler, specifically focusing around the application credentials and login process.

func (OAuthConfig) Config

func (oc OAuthConfig) Config(scopes []string) *oauth2.Config

Config returns the oauth configuration if one was provided.

func (OAuthConfig) GithubClient

func (oc OAuthConfig) GithubClient(token *types.OAuthToken) github.Client

GithubClient either returns the client for the token.

func (OAuthConfig) Validate

func (oc OAuthConfig) Validate() error

Validate validates the oauth configuration

type Service

type Service struct {
	UseSessions bool            `yaml:"-"`
	UseDB       bool            `yaml:"-"`
	NoTLSServer bool            `yaml:"-"`
	Formats     strfmt.Registry `yaml:"-"`

	Clients *Clients `yaml:"-"`

	Model *model.Model `yaml:"-"`
	Name  string       `yaml:"-"`
}

Service is the internal configuration for a service

type ServiceAddress

type ServiceAddress struct {
	Hostname string
	Port     uint
	HTTP     bool
	TLS      bool
}

ServiceAddress is a well-formed address for service connections

func (ServiceAddress) String

func (sa ServiceAddress) String() string

type ServiceConfig

type ServiceConfig map[string]interface{}

ServiceConfig is the pre-normalized version of the config struct

type UserConfig

type UserConfig struct {
	ServiceConfig ServiceConfig `yaml:"services"`
	ClientConfig  ClientConfig  `yaml:"clients"`

	OAuth          OAuthConfig `yaml:"oauth"`
	Auth           AuthConfig  `yaml:"auth"`
	HookURL        string      `yaml:"hook_url"`
	DSN            string      `yaml:"db"`
	TLS            CertConfig  `yaml:"tls"`
	Websockets     Websockets  `yaml:"websockets"`
	RequestLogging bool        `yaml:"log_requests"`
	Port           uint        `yaml:"port"`
	URL            string      `yaml:"url"`
	EnableTracing  bool        `yaml:"enable_tracing"`
	ReadonlyClient bool        `yaml:"readonly_client"`
}

UserConfig is the user-supplied configuration parsed from yaml.

type Websockets

type Websockets struct {
	MaxAttachBuffer    int64 `yaml:"attach_buffer_size"`
	BufSize            int   `yaml:"read_buffer_size"`
	InsecureWebSockets bool  `yaml:"insecure_websockets"`
}

Websockets is general websocket configuration.

Jump to

Keyboard shortcuts

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