Documentation
¶
Overview ¶
Package cedar holds a a number of application level constants and shared resources for the Cedar application.
Index ¶
Constants ¶
const ( // Auth constants. AuthTokenCookie = "cedar-token" APIUserHeader = "Api-User" APIKeyHeader = "Api-Key" EvergreenAPIUserHeader = "Evergreen-Api-User" EvergreenAPIKeyHeader = "Evergreen-Api-Key" TokenExpireAfter = time.Hour // Version requester types. PatchVersionRequester = "patch_request" GithubPRRequester = "github_pull_request" GitTagRequester = "git_tag_request" RepotrackerVersionRequester = "gitter_request" TriggerRequester = "trigger_request" MergeTestRequester = "merge_test" AdHocRequester = "ad_hoc" // Stats cache names. StatsCacheBuildlogger = "buildlogger" StatsCacheTestResults = "test_results" StatsCachePerf = "perf" )
const (
ShortDateFormat = "2006-01-02T15:04"
)
Variables ¶
var ( // Convenience slice for patch requester types. PatchRequesters = []string{ PatchVersionRequester, GithubPRRequester, MergeTestRequester, } // Convenience slice for slice cache names. StatsCacheNames = []string{ StatsCacheBuildlogger, StatsCacheTestResults, StatsCachePerf, } )
var BuildRevision = ""
BuildRevision stores the commit in the git repository at build time and is specified with -ldflags at build time.
Functions ¶
func GetUserMiddlewareConfiguration ¶
func GetUserMiddlewareConfiguration() gimlet.UserMiddlewareConfiguration
GetUserMiddlewareConfiguration returns the gimlet user middleware config with cedar's global auth constants.
func SetEnvironment ¶
func SetEnvironment(env Environment)
Types ¶
type CloserFunc ¶
type Configuration ¶
type Configuration struct { BucketName string DatabaseName string QueueName string MongoDBURI string DbConfigurationCollection string MongoDBDialTimeout time.Duration SocketTimeout time.Duration DisableLocalQueue bool DisableRemoteQueue bool DisableRemoteQueueGroup bool DisableCache bool NumWorkers int DBUser string DBPwd string }
Configuration defines configuration settings to initialize the global environment without the presence of a DB to store the settings.
func GetSessionWithConfig ¶
func GetSessionWithConfig(env Environment) (*Configuration, db.Session, error)
func (*Configuration) GetQueueGroupOptions ¶
func (c *Configuration) GetQueueGroupOptions() queue.MongoDBOptions
GetQueueGroupOptions returns the options to initialize a MongoDB-backed Amboy queue group.
func (*Configuration) GetQueueOptions ¶
func (c *Configuration) GetQueueOptions() queue.MongoDBOptions
GetQueueOptions returns the options to initialize a MongoDB-backed Amboy queue.
func (*Configuration) HasAuth ¶
func (c *Configuration) HasAuth() bool
HasAuth returns whether or not the DB uses authentication.
func (*Configuration) Validate ¶
func (c *Configuration) Validate() error
Validate checks that all the required fields are set and sets defaults for unset optional fields.
type Environment ¶
type Environment interface { GetConfig() *Configuration GetCache() (EnvironmentCache, bool) Context() (context.Context, context.CancelFunc) // GetQueue retrieves the application's shared queue, which is cached // for easy access from within units or inside of requests or command // line operations. GetRemoteQueue() amboy.Queue SetRemoteQueue(amboy.Queue) error GetRemoteManager() management.Manager GetLocalQueue() amboy.Queue SetLocalQueue(amboy.Queue) error GetRemoteQueueGroup() amboy.QueueGroup GetSession() db.Session GetClient() *mongo.Client GetDB() *mongo.Database Jasper() jasper.Manager GetServerCertVersion() int SetServerCertVersion(i int) // GetStatsCache returns the cache corresponding to the string. GetStatsCache(string) *statsCache RegisterCloser(string, CloserFunc) Close(context.Context) error }
Environment objects provide access to shared configuration and state, in a way that you can isolate and test for in
func GetEnvironment ¶
func GetEnvironment() Environment
func NewEnvironment ¶
func NewEnvironment(ctx context.Context, name string, conf *Configuration) (Environment, error)
type EnvironmentCache ¶
type EnvironmentCache interface { // PutNew adds new (key, value) pair to the cache and returns whether // the operation was successful or not. PutNew(string, interface{}) bool // RegisterUpdater registers a new cache value updater for the given // key and returns whether the operation was successful or not. The // updater should listen for updates on the given channel and use the // context and cancel function for signaling. RegisterUpdater(context.Context, context.CancelFunc, string, chan interface{}) bool // Get returns the value of the given key and if the key exists in the // cache. Get(string) (interface{}, bool) // Delete removes the given key from the cache. Delete(string) }
EnvironmentCache provides thread-safe, in-memory access to data persisted elsewhere, such as on disk or a DB.