setting

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2019 License: MIT Imports: 41 Imported by: 2,373

Documentation

Index

Constants

View Source
const (
	LevelQueueType   = "levelqueue"
	ChannelQueueType = "channel"
	RedisQueueType   = "redis"
)

enumerates all the indexer queue types

View Source
const (
	RepoCreatingLastUserVisibility = "last"
	RepoCreatingPrivate            = "private"
	RepoCreatingPublic             = "public"
)

enumerates all the policy repository creating

View Source
const (
	ImageCaptcha = "image"
	ReCaptcha    = "recaptcha"
)

enumerates all the types of captchas

Variables

View Source
var (
	// CORSConfig defines CORS settings
	CORSConfig cors.Options
	// EnableCORS defines whether CORS settings is enabled or not
	EnableCORS bool
)
View Source
var (
	Repository = struct {
		AnsiCharset                             string
		ForcePrivate                            bool
		DefaultPrivate                          string
		MaxCreationLimit                        int
		MirrorQueueLength                       int
		PullRequestQueueLength                  int
		PreferredLicenses                       []string
		DisableHTTPGit                          bool
		AccessControlAllowOrigin                string
		UseCompatSSHURI                         bool
		DefaultCloseIssuesViaCommitsInAnyBranch bool

		// Repository editor settings
		Editor struct {
			LineWrapExtensions   []string
			PreviewableFileModes []string
		} `ini:"-"`

		// Repository upload settings
		Upload struct {
			Enabled      bool
			TempPath     string
			AllowedTypes []string `delim:"|"`
			FileMaxSize  int64
			MaxFiles     int
		} `ini:"-"`

		// Repository local settings
		Local struct {
			LocalCopyPath string
		} `ini:"-"`

		// Pull request settings
		PullRequest struct {
			WorkInProgressPrefixes []string
		} `ini:"repository.pull-request"`

		// Issue Setting
		Issue struct {
			LockReasons []string
		} `ini:"repository.issue"`
	}{
		AnsiCharset:                             "",
		ForcePrivate:                            false,
		DefaultPrivate:                          RepoCreatingLastUserVisibility,
		MaxCreationLimit:                        -1,
		MirrorQueueLength:                       1000,
		PullRequestQueueLength:                  1000,
		PreferredLicenses:                       []string{"Apache License 2.0,MIT License"},
		DisableHTTPGit:                          false,
		AccessControlAllowOrigin:                "",
		UseCompatSSHURI:                         false,
		DefaultCloseIssuesViaCommitsInAnyBranch: false,

		Editor: struct {
			LineWrapExtensions   []string
			PreviewableFileModes []string
		}{
			LineWrapExtensions:   strings.Split(".txt,.md,.markdown,.mdown,.mkd,", ","),
			PreviewableFileModes: []string{"markdown"},
		},

		Upload: struct {
			Enabled      bool
			TempPath     string
			AllowedTypes []string `delim:"|"`
			FileMaxSize  int64
			MaxFiles     int
		}{
			Enabled:      true,
			TempPath:     "data/tmp/uploads",
			AllowedTypes: []string{},
			FileMaxSize:  3,
			MaxFiles:     5,
		},

		Local: struct {
			LocalCopyPath string
		}{
			LocalCopyPath: "tmp/local-repo",
		},

		PullRequest: struct {
			WorkInProgressPrefixes []string
		}{
			WorkInProgressPrefixes: []string{"WIP:", "[WIP]"},
		},

		Issue: struct {
			LockReasons []string
		}{
			LockReasons: strings.Split("Too heated,Off-topic,Spam,Resolved", ","),
		},
	}
	RepoRootPath string
	ScriptType   = "bash"
)

Repository settings

View Source
var (
	// AppVer settings
	AppVer         string
	AppBuiltWith   string
	AppName        string
	AppURL         string
	AppSubURL      string
	AppSubURLDepth int // Number of slashes
	AppPath        string
	AppDataPath    string
	AppWorkPath    string

	// Server settings
	Protocol             Scheme
	Domain               string
	HTTPAddr             string
	HTTPPort             string
	LocalURL             string
	RedirectOtherPort    bool
	PortToRedirect       string
	OfflineMode          bool
	CertFile             string
	KeyFile              string
	StaticRootPath       string
	EnableGzip           bool
	LandingPageURL       LandingPage
	UnixSocketPermission uint32
	EnablePprof          bool
	PprofDataPath        string
	EnableLetsEncrypt    bool
	LetsEncryptTOS       bool
	LetsEncryptDirectory string
	LetsEncryptEmail     string

	SSH = struct {
		Disabled                 bool           `ini:"DISABLE_SSH"`
		StartBuiltinServer       bool           `ini:"START_SSH_SERVER"`
		BuiltinServerUser        string         `ini:"BUILTIN_SSH_SERVER_USER"`
		Domain                   string         `ini:"SSH_DOMAIN"`
		Port                     int            `ini:"SSH_PORT"`
		ListenHost               string         `ini:"SSH_LISTEN_HOST"`
		ListenPort               int            `ini:"SSH_LISTEN_PORT"`
		RootPath                 string         `ini:"SSH_ROOT_PATH"`
		ServerCiphers            []string       `ini:"SSH_SERVER_CIPHERS"`
		ServerKeyExchanges       []string       `ini:"SSH_SERVER_KEY_EXCHANGES"`
		ServerMACs               []string       `ini:"SSH_SERVER_MACS"`
		KeyTestPath              string         `ini:"SSH_KEY_TEST_PATH"`
		KeygenPath               string         `ini:"SSH_KEYGEN_PATH"`
		AuthorizedKeysBackup     bool           `ini:"SSH_AUTHORIZED_KEYS_BACKUP"`
		MinimumKeySizeCheck      bool           `ini:"-"`
		MinimumKeySizes          map[string]int `ini:"-"`
		CreateAuthorizedKeysFile bool           `ini:"SSH_CREATE_AUTHORIZED_KEYS_FILE"`
		ExposeAnonymous          bool           `ini:"SSH_EXPOSE_ANONYMOUS"`
	}{
		Disabled:           false,
		StartBuiltinServer: false,
		Domain:             "",
		Port:               22,
		ServerCiphers:      []string{"aes128-ctr", "aes192-ctr", "aes256-ctr", "aes128-gcm@openssh.com", "arcfour256", "arcfour128"},
		ServerKeyExchanges: []string{"diffie-hellman-group1-sha1", "diffie-hellman-group14-sha1", "ecdh-sha2-nistp256", "ecdh-sha2-nistp384", "ecdh-sha2-nistp521", "curve25519-sha256@libssh.org"},
		ServerMACs:         []string{"hmac-sha2-256-etm@openssh.com", "hmac-sha2-256", "hmac-sha1", "hmac-sha1-96"},
		KeygenPath:         "ssh-keygen",
	}

	LFS struct {
		StartServer     bool          `ini:"LFS_START_SERVER"`
		ContentPath     string        `ini:"LFS_CONTENT_PATH"`
		JWTSecretBase64 string        `ini:"LFS_JWT_SECRET"`
		JWTSecretBytes  []byte        `ini:"-"`
		HTTPAuthExpiry  time.Duration `ini:"LFS_HTTP_AUTH_EXPIRY"`
	}

	// Security settings
	InstallLock           bool
	SecretKey             string
	LogInRememberDays     int
	CookieUserName        string
	CookieRememberName    string
	ReverseProxyAuthUser  string
	ReverseProxyAuthEmail string
	MinPasswordLength     int
	ImportLocalPaths      bool
	DisableGitHooks       bool

	// Database settings
	UseSQLite3       bool
	UseMySQL         bool
	UseMSSQL         bool
	UsePostgreSQL    bool
	UseTiDB          bool
	LogSQL           bool
	DBConnectRetries int
	DBConnectBackoff time.Duration

	// UI settings
	UI = struct {
		ExplorePagingNum    int
		IssuePagingNum      int
		RepoSearchPagingNum int
		FeedMaxCommitNum    int
		GraphMaxCommitNum   int
		CodeCommentLines    int
		ReactionMaxUserNum  int
		ThemeColorMetaTag   string
		MaxDisplayFileSize  int64
		ShowUserEmail       bool
		DefaultShowFullName bool
		DefaultTheme        string
		Themes              []string

		Admin struct {
			UserPagingNum   int
			RepoPagingNum   int
			NoticePagingNum int
			OrgPagingNum    int
		} `ini:"ui.admin"`
		User struct {
			RepoPagingNum int
		} `ini:"ui.user"`
		Meta struct {
			Author      string
			Description string
			Keywords    string
		} `ini:"ui.meta"`
	}{
		ExplorePagingNum:    20,
		IssuePagingNum:      10,
		RepoSearchPagingNum: 10,
		FeedMaxCommitNum:    5,
		GraphMaxCommitNum:   100,
		CodeCommentLines:    4,
		ReactionMaxUserNum:  10,
		ThemeColorMetaTag:   `#6cc644`,
		MaxDisplayFileSize:  8388608,
		DefaultTheme:        `gitea`,
		Themes:              []string{`gitea`, `arc-green`},
		Admin: struct {
			UserPagingNum   int
			RepoPagingNum   int
			NoticePagingNum int
			OrgPagingNum    int
		}{
			UserPagingNum:   50,
			RepoPagingNum:   50,
			NoticePagingNum: 25,
			OrgPagingNum:    50,
		},
		User: struct {
			RepoPagingNum int
		}{
			RepoPagingNum: 15,
		},
		Meta: struct {
			Author      string
			Description string
			Keywords    string
		}{
			Author:      "Gitea - Git with a cup of tea",
			Description: "Gitea (Git with a cup of tea) is a painless self-hosted Git service written in Go",
			Keywords:    "go,git,self-hosted,gitea",
		},
	}

	// Markdown settings
	Markdown = struct {
		EnableHardLineBreak bool
		CustomURLSchemes    []string `ini:"CUSTOM_URL_SCHEMES"`
		FileExtensions      []string
	}{
		EnableHardLineBreak: false,
		FileExtensions:      strings.Split(".md,.markdown,.mdown,.mkd", ","),
	}

	// Admin settings
	Admin struct {
		DisableRegularOrgCreation bool
	}

	// Picture settings
	AvatarUploadPath              string
	AvatarMaxWidth                int
	AvatarMaxHeight               int
	GravatarSource                string
	GravatarSourceURL             *url.URL
	DisableGravatar               bool
	EnableFederatedAvatar         bool
	LibravatarService             *libravatar.Libravatar
	AvatarMaxFileSize             int64
	RepositoryAvatarUploadPath    string
	RepositoryAvatarFallback      string
	RepositoryAvatarFallbackImage string

	// Log settings
	LogLevel           string
	StacktraceLogLevel string
	LogRootPath        string
	LogDescriptions    = make(map[string]*LogDescription)
	RedirectMacaronLog bool
	DisableRouterLog   bool
	RouterLogLevel     log.Level
	RouterLogMode      string
	EnableAccessLog    bool
	AccessLogTemplate  string
	EnableXORMLog      bool

	// Attachment settings
	AttachmentPath         string
	AttachmentAllowedTypes string
	AttachmentMaxSize      int64
	AttachmentMaxFiles     int
	AttachmentEnabled      bool

	// Time settings
	TimeFormat string

	CSRFCookieName = "_csrf"

	// Mirror settings
	Mirror struct {
		DefaultInterval time.Duration
		MinInterval     time.Duration
	}

	// API settings
	API = struct {
		EnableSwagger          bool
		SwaggerURL             string
		MaxResponseItems       int
		DefaultPagingNum       int
		DefaultGitTreesPerPage int
		DefaultMaxBlobSize     int64
	}{
		EnableSwagger:          true,
		SwaggerURL:             "",
		MaxResponseItems:       50,
		DefaultPagingNum:       30,
		DefaultGitTreesPerPage: 1000,
		DefaultMaxBlobSize:     10485760,
	}

	OAuth2 = struct {
		Enable                     bool
		AccessTokenExpirationTime  int64
		RefreshTokenExpirationTime int64
		InvalidateRefreshTokens    bool
		JWTSecretBytes             []byte `ini:"-"`
		JWTSecretBase64            string `ini:"JWT_SECRET"`
	}{
		Enable:                     true,
		AccessTokenExpirationTime:  3600,
		RefreshTokenExpirationTime: 730,
		InvalidateRefreshTokens:    false,
	}

	U2F = struct {
		AppID         string
		TrustedFacets []string
	}{}

	// Metrics settings
	Metrics = struct {
		Enabled bool
		Token   string
	}{
		Enabled: false,
		Token:   "",
	}

	// I18n settings
	Langs []string
	Names []string

	// Other settings
	ShowFooterBranding         bool
	ShowFooterVersion          bool
	ShowFooterTemplateLoadTime bool

	// Global setting objects
	Cfg               *ini.File
	CustomPath        string // Custom directory path
	CustomConf        string
	CustomPID         string
	ProdMode          bool
	RunUser           string
	IsWindows         bool
	HasRobotsTxt      bool
	InternalToken     string // internal access token
	IterateBufferSize int

	// UILocation is the location on the UI, so that we can display the time on UI.
	// Currently only show the default time.Local, it could be added to app.ini after UI is ready
	UILocation = time.Local
)

settings

View Source
var (

	// Cron tasks
	Cron = struct {
		UpdateMirror struct {
			Enabled    bool
			RunAtStart bool
			Schedule   string
		} `ini:"cron.update_mirrors"`
		RepoHealthCheck struct {
			Enabled    bool
			RunAtStart bool
			Schedule   string
			Timeout    time.Duration
			Args       []string `delim:" "`
		} `ini:"cron.repo_health_check"`
		CheckRepoStats struct {
			Enabled    bool
			RunAtStart bool
			Schedule   string
		} `ini:"cron.check_repo_stats"`
		ArchiveCleanup struct {
			Enabled    bool
			RunAtStart bool
			Schedule   string
			OlderThan  time.Duration
		} `ini:"cron.archive_cleanup"`
		SyncExternalUsers struct {
			Enabled        bool
			RunAtStart     bool
			Schedule       string
			UpdateExisting bool
		} `ini:"cron.sync_external_users"`
		DeletedBranchesCleanup struct {
			Enabled    bool
			RunAtStart bool
			Schedule   string
			OlderThan  time.Duration
		} `ini:"cron.deleted_branches_cleanup"`
	}{
		UpdateMirror: struct {
			Enabled    bool
			RunAtStart bool
			Schedule   string
		}{
			Enabled:    true,
			RunAtStart: false,
			Schedule:   "@every 10m",
		},
		RepoHealthCheck: struct {
			Enabled    bool
			RunAtStart bool
			Schedule   string
			Timeout    time.Duration
			Args       []string `delim:" "`
		}{
			Enabled:    true,
			RunAtStart: false,
			Schedule:   "@every 24h",
			Timeout:    60 * time.Second,
			Args:       []string{},
		},
		CheckRepoStats: struct {
			Enabled    bool
			RunAtStart bool
			Schedule   string
		}{
			Enabled:    true,
			RunAtStart: true,
			Schedule:   "@every 24h",
		},
		ArchiveCleanup: struct {
			Enabled    bool
			RunAtStart bool
			Schedule   string
			OlderThan  time.Duration
		}{
			Enabled:    true,
			RunAtStart: true,
			Schedule:   "@every 24h",
			OlderThan:  24 * time.Hour,
		},
		SyncExternalUsers: struct {
			Enabled        bool
			RunAtStart     bool
			Schedule       string
			UpdateExisting bool
		}{
			Enabled:        true,
			RunAtStart:     false,
			Schedule:       "@every 24h",
			UpdateExisting: true,
		},
		DeletedBranchesCleanup: struct {
			Enabled    bool
			RunAtStart bool
			Schedule   string
			OlderThan  time.Duration
		}{
			Enabled:    true,
			RunAtStart: true,
			Schedule:   "@every 24h",
			OlderThan:  24 * time.Hour,
		},
	}
)
View Source
var (
	ExternalMarkupParsers []MarkupParser
)

ExternalMarkupParsers represents the external markup parsers

View Source
var (
	// Git settings
	Git = struct {
		DisableDiffHighlight      bool
		MaxGitDiffLines           int
		MaxGitDiffLineCharacters  int
		MaxGitDiffFiles           int
		GCArgs                    []string `ini:"GC_ARGS" delim:" "`
		EnableAutoGitWireProtocol bool
		Timeout                   struct {
			Default int
			Migrate int
			Mirror  int
			Clone   int
			Pull    int
			GC      int `ini:"GC"`
		} `ini:"git.timeout"`
	}{
		DisableDiffHighlight:      false,
		MaxGitDiffLines:           1000,
		MaxGitDiffLineCharacters:  5000,
		MaxGitDiffFiles:           100,
		GCArgs:                    []string{},
		EnableAutoGitWireProtocol: true,
		Timeout: struct {
			Default int
			Migrate int
			Mirror  int
			Clone   int
			Pull    int
			GC      int `ini:"GC"`
		}{
			Default: int(git.DefaultCommandExecutionTimeout / time.Second),
			Migrate: 600,
			Mirror:  300,
			Clone:   300,
			Pull:    300,
			GC:      60,
		},
	}
)
View Source
var (
	// Indexer settings
	Indexer = struct {
		IssueType             string
		IssuePath             string
		RepoIndexerEnabled    bool
		RepoPath              string
		UpdateQueueLength     int
		MaxIndexerFileSize    int64
		IssueQueueType        string
		IssueQueueDir         string
		IssueQueueConnStr     string
		IssueQueueBatchNumber int
	}{
		IssueType:             "bleve",
		IssuePath:             "indexers/issues.bleve",
		IssueQueueType:        LevelQueueType,
		IssueQueueDir:         "indexers/issues.queue",
		IssueQueueConnStr:     "",
		IssueQueueBatchNumber: 20,
	}
)
View Source
var Service struct {
	DefaultOrgVisibility                    string
	DefaultOrgVisibilityMode                structs.VisibleType
	ActiveCodeLives                         int
	ResetPwdCodeLives                       int
	RegisterEmailConfirm                    bool
	EmailDomainWhitelist                    []string
	DisableRegistration                     bool
	AllowOnlyExternalRegistration           bool
	ShowRegistrationButton                  bool
	RequireSignInView                       bool
	EnableNotifyMail                        bool
	EnableReverseProxyAuth                  bool
	EnableReverseProxyAutoRegister          bool
	EnableReverseProxyEmail                 bool
	EnableCaptcha                           bool
	RequireExternalRegistrationCaptcha      bool
	RequireExternalRegistrationPassword     bool
	CaptchaType                             string
	RecaptchaSecret                         string
	RecaptchaSitekey                        string
	RecaptchaURL                            string
	DefaultKeepEmailPrivate                 bool
	DefaultAllowCreateOrganization          bool
	EnableTimetracking                      bool
	DefaultEnableTimetracking               bool
	DefaultEnableDependencies               bool
	DefaultAllowOnlyContributorsToTrackTime bool
	NoReplyAddress                          string
	EnableUserHeatmap                       bool
	AutoWatchNewRepos                       bool

	// OpenID settings
	EnableOpenIDSignIn bool
	EnableOpenIDSignUp bool
	OpenIDWhitelist    []*regexp.Regexp
	OpenIDBlacklist    []*regexp.Regexp
}

Service settings

View Source
var (
	// SessionConfig difines Session settings
	SessionConfig session.Options
)
View Source
var (
	// Webhook settings
	Webhook = struct {
		QueueLength    int
		DeliverTimeout int
		SkipTLSVerify  bool
		Types          []string
		PagingNum      int
	}{
		QueueLength:    1000,
		DeliverTimeout: 5,
		SkipTLSVerify:  false,
		PagingNum:      10,
	}
)

Functions

func CheckLFSVersion added in v1.7.0

func CheckLFSVersion()

CheckLFSVersion will check lfs version, if not satisfied, then disable it.

func DateLang

func DateLang(lang string) string

DateLang transforms standard language locale name to corresponding value in datetime plugin.

func IsRunUserMatchCurrentUser

func IsRunUserMatchCurrentUser(runUser string) (string, bool)

IsRunUserMatchCurrentUser returns false if configured run user does not match actual user that runs the app. The first return value is the actual user name. This check is ignored under Windows since SSH remote login is not the main method to login on Windows.

func NewContext

func NewContext()

NewContext initializes configuration context. NOTE: do not print any log except error.

func NewLogServices added in v1.9.0

func NewLogServices(disableConsole bool)

NewLogServices creates all the log services

func NewServices

func NewServices()

NewServices initializes the services

func NewXORMLogService added in v1.1.0

func NewXORMLogService(disableConsole bool)

NewXORMLogService initializes xorm logger service

func SetCustomPathAndConf added in v1.9.0

func SetCustomPathAndConf(providedCustom, providedConf, providedWorkPath string)

SetCustomPathAndConf will set CustomPath and CustomConf with reference to the GITEA_CUSTOM environment variable and with provided overrides before stepping back to the default

Types

type Cache added in v1.3.0

type Cache struct {
	Adapter  string
	Interval int
	Conn     string
	TTL      time.Duration
}

Cache represents cache settings

var (
	// CacheService the global cache
	CacheService *Cache
)

type LandingPage

type LandingPage string

LandingPage describes the default page

const (
	LandingPageHome          LandingPage = "/"
	LandingPageExplore       LandingPage = "/explore"
	LandingPageOrganizations LandingPage = "/explore/organizations"
)

enumerates all the landing page types

type LogDescription added in v1.9.0

type LogDescription struct {
	Name               string
	SubLogDescriptions []SubLogDescription
}

LogDescription describes a named logger

type Mailer

type Mailer struct {
	// Mailer
	QueueLength     int
	Name            string
	From            string
	FromName        string
	FromEmail       string
	SendAsPlainText bool
	MailerType      string
	SubjectPrefix   string

	// SMTP sender
	Host              string
	User, Passwd      string
	DisableHelo       bool
	HeloHostname      string
	SkipVerify        bool
	UseCertificate    bool
	CertFile, KeyFile string
	IsTLSEnabled      bool

	// Sendmail sender
	SendmailPath string
	SendmailArgs []string
}

Mailer represents mail service.

var (
	// MailService the global mailer
	MailService *Mailer
)

type MarkupParser added in v1.3.0

type MarkupParser struct {
	Enabled        bool
	MarkupName     string
	Command        string
	FileExtensions []string
	IsInputFile    bool
}

MarkupParser defines the external parser configured in ini

type Scheme

type Scheme string

Scheme describes protocol types

const (
	HTTP       Scheme = "http"
	HTTPS      Scheme = "https"
	FCGI       Scheme = "fcgi"
	UnixSocket Scheme = "unix"
)

enumerates all the scheme types

type SubLogDescription added in v1.9.0

type SubLogDescription struct {
	Name     string
	Provider string
	Config   string
}

SubLogDescription describes a sublogger

Jump to

Keyboard shortcuts

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