1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-19 05:09:42 +02:00
documize/core/env/flags.go

59 lines
1.9 KiB
Go
Raw Normal View History

2016-07-07 18:54:16 -07:00
// Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved.
//
// This software (Documize Community Edition) is licensed under
2016-07-07 18:54:16 -07:00
// GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html
//
// You can operate outside the AGPL restrictions by purchasing
// Documize Enterprise Edition and obtaining a commercial license
// by contacting <sales@documize.com>.
2016-07-07 18:54:16 -07:00
//
// https://documize.com
2017-07-19 18:47:01 +01:00
// Package env provides runtime, server level setup and configuration
2017-07-18 21:55:17 +01:00
package env
2016-07-07 18:54:16 -07:00
2017-07-19 18:47:01 +01:00
// Flags provides access to environment and command line switches for this program.
type Flags struct {
DBType string // database type
2017-07-19 18:47:01 +01:00
DBConn string // database connection string
Salt string // the salt string used to encode JWT tokens
HTTPPort string // (optional) HTTP or HTTPS port
ForceHTTPPort2SSL string // (optional) HTTP that should be redirected to HTTPS
SSLCertFile string // (optional) name of SSL certificate PEM file
SSLKeyFile string // (optional) name of SSL key PEM file
TLSVersion string // (optional) minimum TLS version for SSL connections
2017-07-19 18:47:01 +01:00
SiteMode string // (optional) if 1 then serve offline web page
Location string // reserved
ConfigSource string // tells us if configuration info was obtained from command line or config file
2017-07-19 18:47:01 +01:00
}
// SSLEnabled returns true if both cert and key were provided at runtime.
func (f *Flags) SSLEnabled() bool {
return f.SSLCertFile != "" && f.SSLKeyFile != ""
}
2016-07-07 18:54:16 -07:00
// ConfigToml represents configuration file that contains all flags as per above.
type ConfigToml struct {
HTTP httpConfig `toml:"http"`
Database databaseConfig `toml:"database"`
Install installConfig `toml:"install"`
2016-07-07 18:54:16 -07:00
}
type httpConfig struct {
Port int
ForceSSLPort int
Cert string
Key string
TLSVersion string
2017-07-19 18:47:01 +01:00
}
type databaseConfig struct {
Type string
Connection string
Salt string
2016-07-07 18:54:16 -07:00
}
type installConfig struct {
Location string
2016-07-07 18:54:16 -07:00
}