config

package
v1.8.10 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContextKeyConfig is the key used to store the configuration in the context.
	ContextKeyStatistics contextKey = "githubStatistics"
)

Variables

View Source
var Config = struct {

	// LogrusLevel sets the logrus logging level
	LogrusLevel string `env:"GOLIAC_LOGRUS_LEVEL" envDefault:"info"`
	// LogrusFormat sets the logrus logging formatter
	// Possible values: text, json
	LogrusFormat string `env:"GOLIAC_LOGRUS_FORMAT" envDefault:"text"`

	GithubServer              string `env:"GOLIAC_GITHUB_SERVER" envDefault:"https://api.github.com"`
	GithubAppOrganization     string `env:"GOLIAC_GITHUB_APP_ORGANIZATION" envDefault:""`
	GithubAppID               int64  `env:"GOLIAC_GITHUB_APP_ID"`
	GithubAppPrivateKeyFile   string `env:"GOLIAC_GITHUB_APP_PRIVATE_KEY_FILE" envDefault:""`
	GithubAppClientSecret     string `env:"GOLIAC_GITHUB_APP_CLIENT_SECRET"`
	GithubAppCallbackURL      string `env:"GOLIAC_GITHUB_APP_CALLBACK_URL"`
	GithubPersonalAccessToken string `env:"GOLIAC_GITHUB_PERSONAL_ACCESS_TOKEN"`
	GoliacEmail               string `env:"GOLIAC_EMAIL" envDefault:"goliac@goliac-project.com"`
	GoliacTeamOwnerSuffix     string `env:"GOLIAC_TEAM_OWNER_SUFFIX" envDefault:"-goliac-owners"`

	GithubConcurrentThreads int64 `env:"GOLIAC_GITHUB_CONCURRENT_THREADS" envDefault:"5"`
	GithubCacheTTL          int64 `env:"GOLIAC_GITHUB_CACHE_TTL" envDefault:"86400"`

	ServerApplyInterval int64  `env:"GOLIAC_SERVER_APPLY_INTERVAL" envDefault:"600"`
	ServerGitRepository string `env:"GOLIAC_SERVER_GIT_REPOSITORY" envDefault:""`
	ServerGitBranch     string `env:"GOLIAC_SERVER_GIT_BRANCH" envDefault:"main"`
	// the name of the CI validating each PR on the teams repsotiry. See scaffold.go for the Github action
	ServerGitBranchProtectionRequiredCheck string `env:"GOLIAC_SERVER_PR_REQUIRED_CHECK" envDefault:"validate"`

	// MaxChangesetsOverride - override the max changesets limitation from the repository config
	MaxChangesetsOverride bool `env:"GOLIAC_MAX_CHANGESETS_OVERRIDE" envDefault:"false"`

	// SyncUsersBeforeApply - to sync users before applying the commits
	SyncUsersBeforeApply bool `env:"GOLIAC_SYNC_USERS_BEFORE_APPLY" envDefault:"true"`

	// Host - golang-skeleton server host
	SwaggerHost string `env:"GOLIAC_SERVER_HOST" envDefault:"localhost"`
	// Port - golang-skeleton server port
	SwaggerPort int `env:"GOLIAC_SERVER_PORT" envDefault:"18000"`

	// MiddlewareVerboseLoggerEnabled - to enable the negroni-logrus logger for all the endpoints useful for debugging
	MiddlewareVerboseLoggerEnabled bool `env:"GOLIAC_MIDDLEWARE_VERBOSE_LOGGER_ENABLED" envDefault:"true"`
	// MiddlewareVerboseLoggerExcludeURLs - to exclude urls from the verbose logger via comma separated list
	MiddlewareVerboseLoggerExcludeURLs []string `env:"GOLIAC_MIDDLEWARE_VERBOSE_LOGGER_EXCLUDE_URLS" envDefault:"" envSeparator:","`
	// MiddlewareGzipEnabled - to enable gzip middleware
	MiddlewareGzipEnabled bool `env:"GOLIAC_MIDDLEWARE_GZIP_ENABLED" envDefault:"true"`

	// CORSEnabled - enable CORS
	CORSEnabled          bool     `env:"GOLIAC_CORS_ENABLED" envDefault:"false"`
	CORSAllowCredentials bool     `env:"GOLIAC_CORS_ALLOW_CREDENTIALS" envDefault:"true"`
	CORSAllowedHeaders   []string `` /* 131-byte string literal not displayed */
	CORSAllowedMethods   []string `env:"GOLIAC_CORS_ALLOWED_METHODS" envDefault:"GET,POST,PUT,DELETE,PATCH" envSeparator:","`
	CORSAllowedOrigins   []string `env:"GOLIAC_CORS_ALLOWED_ORIGINS" envDefault:"*" envSeparator:","`
	CORSExposedHeaders   []string `env:"GOLIAC_CORS_EXPOSED_HEADERS" envDefault:"WWW-Authenticate" envSeparator:","`

	// WebPrefix - base path for web and API
	// e.g. GOLANG_SKELETON_WEB_PREFIX=/foo
	// UI path  => localhost:18000/foo"
	// API path => localhost:18000/foo/api/v1"
	WebPrefix string `env:"GOLIAC_WEB_PREFIX" envDefault:""`

	// to receive slack notifications on errors
	SlackToken   string `env:"GOLIAC_SLACK_TOKEN" envDefault:""`
	SlackChannel string `env:"GOLIAC_SLACK_CHANNEL" envDefault:""`

	// to receive Github main branch merge webhook events on the /webhook endpoint
	GithubWebhookSecret        string `env:"GOLIAC_GITHUB_WEBHOOK_SECRET" envDefault:""`
	GithubWebhookDedicatedHost string `env:"GOLIAC_GITHUB_WEBHOOK_HOST" envDefault:"localhost"`
	GithubWebhookDedicatedPort int    `env:"GOLIAC_GITHUB_WEBHOOK_PORT" envDefault:"18001"`
	GithubWebhookPath          string `env:"GOLIAC_GITHUB_WEBHOOK_PATH" envDefault:"/webhook"`

	OpenTelemetryEnabled      bool   `env:"GOLIAC_OPENTELEMETRY_ENABLED" envDefault:"false"`
	OpenTelemetryGrpcEndpoint string `env:"GOLIAC_OPENTELEMETRY_GRPC_ENDPOINT" envDefault:"localhost:4317"`
	OpenTelemetryTraceAll     bool   `env:"GOLIAC_OPENTELEMETRY_TRACE_ALL" envDefault:"true"`

	// ForcemergeWorkflow specific configuration
	WorkflowJiraAtlassianDomain string `env:"GOLIAC_WORKFLOW_JIRA_ATLASSIAN_DOMAIN" envDefault:""`
	WorkflowJiraProjectKey      string `env:"GOLIAC_WORKFLOW_JIRA_PROJECT_KEY" envDefault:""`
	WorkflowJiraEmail           string `env:"GOLIAC_WORKFLOW_JIRA_EMAIL" envDefault:""`
	WorkflowJiraApiToken        string `env:"GOLIAC_WORKFLOW_JIRA_API_TOKEN" envDefault:""`
	WorkflowJiraIssueType       string `env:"GOLIAC_WORKFLOW_JIRA_ISSUE_TYPE" envDefault:"Task"`
	WorkflowDynamoDBTableName   string `env:"GOLIAC_WORKFLOW_DYNAMODB_TABLE_NAME" envDefault:"goliac-workflows"`
}{}

Config is the whole configuration of the app

View Source
var GoliacBuildVersion = "unknown"

to be overrided at build time with go build -ldflags "-X github.com/goliac-project/goliac/internal/config.GoliacBuildVersion=...

Functions

func DefaultAfter

func DefaultAfter(entry *logrus.Entry, res negroni.ResponseWriter, latency time.Duration, name string) *logrus.Entry

DefaultAfter is the default func assigned to *Middleware.After

func DefaultBefore

func DefaultBefore(entry *logrus.Entry, req *http.Request, remoteAddr string) *logrus.Entry

DefaultBefore is the default func assigned to *Middleware.Before

func ServerShutdown

func ServerShutdown()

ServerShutdown is a callback function that will be called when we tear down the golang-skeleton server

func SetupGlobalMiddleware

func SetupGlobalMiddleware(handler http.Handler) http.Handler

SetupGlobalMiddleware setup the global middleware

func ShutdownTraceProvider added in v0.16.3

func ShutdownTraceProvider() error

Types

type AfterFunc

AfterFunc is the func type used to modify or replace the *logrus.Entry after calling the next func in the middleware chain

type BeforeFunc

type BeforeFunc func(*logrus.Entry, *http.Request, string) *logrus.Entry

BeforeFunc is the func type used to modify or replace the *logrus.Entry prior to calling the next func in the middleware chain

type GithubCustomProperty added in v1.5.0

type GithubCustomProperty struct {
	PropertyName     string   `yaml:"property_name" json:"property_name"`
	ValueType        string   `yaml:"value_type" json:"value_type"` // "string", "single_select", "multi_select"
	Required         bool     `yaml:"required,omitempty" json:"required,omitempty"`
	DefaultValue     string   `yaml:"default_value,omitempty" json:"default_value,omitempty"`
	Description      string   `yaml:"description,omitempty" json:"description,omitempty"`
	AllowedValues    []string `yaml:"allowed_values,omitempty" json:"allowed_values,omitempty"`
	ValuesEditableBy string   `yaml:"values_editable_by,omitempty" json:"values_editable_by,omitempty"` // "org_actors", "org_and_repo_actors"
}

type GoliacFeatures added in v1.8.0

type GoliacFeatures struct {
	ManageGithubEnvAndVariables bool `yaml:"manage_github_env_and_variables"`
	ManageGithubAutolinks       bool `yaml:"manage_github_autolinks"`
	ManageOrgCustomProperties   bool `yaml:"manage_org_custom_properties"`
}

GoliacFeatures toggles optional GitHub integrations (see goliac.yaml `features`).

type GoliacStatistics

type GoliacStatistics struct {
	GithubApiCalls  int
	GithubThrottled int
}

type Middleware

type Middleware struct {
	// Logger is the log.Logger instance used to log messages with the Logger middleware
	Logger *logrus.Logger
	// Name is the name of the application as recorded in latency metrics
	Name   string
	Before func(*logrus.Entry, *http.Request, string) *logrus.Entry
	After  func(*logrus.Entry, negroni.ResponseWriter, time.Duration, string) *logrus.Entry
	// contains filtered or unexported fields
}

Middleware is a middleware handler that logs the request as it goes in and the response as it goes out.

func NewCustomMiddleware

func NewCustomMiddleware(level logrus.Level, formatter logrus.Formatter, name string) *Middleware

NewCustomMiddleware builds a *Middleware with the given level and formatter

func NewMiddleware

func NewMiddleware() *Middleware

NewMiddleware returns a new *Middleware, yay!

func NewMiddlewareFromLogger

func NewMiddlewareFromLogger(logger *logrus.Logger, level logrus.Level, name string) *Middleware

NewMiddlewareFromLogger returns a new *Middleware which writes to a given logrus logger.

func (*Middleware) ExcludeURL

func (m *Middleware) ExcludeURL(u string) error

ExcludeURL adds a new URL u to be ignored during logging. The URL u is parsed, hence the returned error

func (*Middleware) ExcludedURLs

func (m *Middleware) ExcludedURLs() []string

ExcludedURLs returns the list of excluded URLs for this middleware

func (*Middleware) ServeHTTP

func (m *Middleware) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

func (*Middleware) SetLogCompleted

func (m *Middleware) SetLogCompleted(v bool)

SetLogCompleted accepts a bool to control the logging of "completed handling request" after returning from the next middleware

func (*Middleware) SetLogStarting

func (m *Middleware) SetLogStarting(v bool)

SetLogStarting accepts a bool to control the logging of "started handling request" prior to passing to the next middleware

type OtelMiddleware added in v0.15.4

type OtelMiddleware struct {
	// contains filtered or unexported fields
}

func NewOtelMiddleware added in v0.15.4

func NewOtelMiddleware() *OtelMiddleware

func (*OtelMiddleware) ServeHTTP added in v0.15.4

func (o *OtelMiddleware) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type RepositoryConfig

type RepositoryConfig struct {
	AdminTeam           string `yaml:"admin_team"`
	EveryoneTeamEnabled bool   `yaml:"everyone_team_enabled"`

	Rulesets                []string
	MaxChangesets           int `yaml:"max_changesets"`
	GithubConcurrentThreads int `yaml:"github_concurrent_threads"`
	UserSync                struct {
		Plugin string `yaml:"plugin"`
		Path   string `yaml:"path"`
	}
	ArchiveOnDelete       bool `yaml:"archive_on_delete"`
	DestructiveOperations struct {
		AllowDestructiveRepositories bool `yaml:"repositories"`
		AllowDestructiveTeams        bool `yaml:"teams"`
		AllowDestructiveUsers        bool `yaml:"users"`
		AllowDestructiveRulesets     bool `yaml:"rulesets"`
	} `yaml:"destructive_operations"`

	VisibilityRules struct {
		ForbidPublicRepositories           bool     `yaml:"forbid_public_repositories"`
		ForbidPublicRepositoriesExclusions []string `yaml:"forbid_public_repositories_exclusions"`
	} `yaml:"visibility_rules"`

	Workflows           []string                `yaml:"workflows"`
	OrgCustomProperties []*GithubCustomProperty `yaml:"org_custom_properties"`
	Features            GoliacFeatures          `yaml:"features"`
}

func (*RepositoryConfig) UnmarshalYAML

func (rc *RepositoryConfig) UnmarshalYAML(value *yaml.Node) error

set default values

Jump to

Keyboard shortcuts

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