Documentation
¶
Overview ¶
Package config holds project and service related data and structures that define optional parameters for different parts of the service.
Index ¶
- Variables
- func Prepare(options []Options) error
- func Update(options []Options, dirs ...string) error
- func Verify(options []Options) (help string, err error)
- type CertificateOptions
- type EmailOptions
- type GopherPitOptions
- type LDAPOptions
- type LoggingOptions
- type Options
- type ServicesOptions
- type SessionOptions
- type UserOptions
Constants ¶
This section is empty.
Variables ¶
var ( // Name is the name of the service. Name = "gopherpit" // Description is a service description. Description = "" // Author is the name of the service's author. Author = "Janoš Guljaš" // AuthorEmail is a contact address of the author. AuthorEmail = "janos@resenje.org" // Version is a string representing service's version. // Set the version on build with: go build -ldflags "-X gopherpit.com/gopherpit/server/config.Version=$(VERSION)" Version = "0" // BuildInfo is usually a git commit short hash. // Set the version on build with: go build -ldflags "-X gopherpit.com/gopherpit/server/config.BuildInfo=$(shell git describe --long --dirty --always)" BuildInfo = "" // UserAgent is a value for User-Agent HTTP request header value. UserAgent = func() string { if BuildInfo != "" { return fmt.Sprintf("%s/%s-%s", Name, Version, BuildInfo) } return fmt.Sprintf("%s/%s", Name, Version) }() // BaseDir is the directory where the service's executable is located. BaseDir = func() string { baseDir, err := filepath.Abs(filepath.Dir(os.Args[0])) if err != nil { panic(err) } return baseDir }() // Dir is default directory where configuration files are located. // Set the version on build with: go build -ldflags "-X gopherpit.com/gopherpit/server/config.Dir=$(CONFIG_DIR)" Dir = "/etc/" + Name )
Functions ¶
Types ¶
type CertificateOptions ¶
type CertificateOptions struct {
DirectoryURL string `json:"directory-url" yaml:"directory-url" envconfig:"DIRECTORY_URL"`
DirectoryURLStaging string `json:"directory-url-staging" yaml:"directory-url-staging" envconfig:"DIRECTORY_URL_STAGING"`
RenewPeriod marshal.Duration `json:"renew-period" yaml:"renew-period" envconfig:"RENEW_PERIOD"`
RenewCheckPeriod marshal.Duration `json:"renew-check-period" yaml:"renew-check-period" envconfig:"RENEW_CHECK_PERIOD"`
}
CertificateOptions defines parameters related to service's core functionality.
func NewCertificateOptions ¶
func NewCertificateOptions() *CertificateOptions
NewCertificateOptions initializes CertificateOptions with default values.
func (*CertificateOptions) Prepare ¶
func (o *CertificateOptions) Prepare() error
Prepare creates configured directories for home, storage, logs and temporary files.
func (*CertificateOptions) String ¶
func (o *CertificateOptions) String() string
String returns a JSON representation of the options.
func (*CertificateOptions) Update ¶
func (o *CertificateOptions) Update(dirs ...string) error
Update updates options by loading certificate.json files.
func (*CertificateOptions) Verify ¶
func (o *CertificateOptions) Verify() (help string, err error)
Verify checks if configuration values are valid and if all requirements are set for service to start.
type EmailOptions ¶
type EmailOptions struct {
NotifyAddresses []string `json:"notify-addresses" yaml:"notify-addresses" envconfig:"NOTIFY_ADDRESS"`
DefaultFrom string `json:"default-from" yaml:"default-from" envconfig:"DEFAULT_FROM"`
SubjectPrefix string `json:"subject-prefix" yaml:"subject-prefix" envconfig:"SUBJECT_PREFIX"`
SMTPIdentity string `json:"smtp-identity" yaml:"smtp-identity" envconfig:"SMTP_IDENTITY"`
SMTPUsername string `json:"smtp-username" yaml:"smtp-username" envconfig:"SMTP_USERNAME"`
SMTPPassword string `json:"smtp-password" yaml:"smtp-password" envconfig:"SMTP_PASSWORD"`
SMTPHost string `json:"smtp-host" yaml:"smtp-host" envconfig:"SMTP_HOST"`
SMTPPort int `json:"smtp-port" yaml:"smtp-port" envconfig:"SMTP_PORT"`
SMTPSkipVerify bool `json:"smtp-skip-verify" yaml:"smtp-skip-verify" envconfig:"SMTP_SKIP_VERIFY"`
}
EmailOptions defines parameters for email sending.
func NewEmailOptions ¶
func NewEmailOptions() *EmailOptions
NewEmailOptions initializes EmailOptions with default values.
func (*EmailOptions) Prepare ¶
func (o *EmailOptions) Prepare() error
Prepare doesn't do anything, just provides method for Options interface.
func (*EmailOptions) String ¶
func (o *EmailOptions) String() string
String returns a JSON representation of the options.
func (*EmailOptions) Update ¶
func (o *EmailOptions) Update(dirs ...string) error
Update updates options by loading email.json files.
func (*EmailOptions) Verify ¶
func (o *EmailOptions) Verify() (help string, err error)
Verify doesn't do anything, just provides method for Options interface.
type GopherPitOptions ¶
type GopherPitOptions struct {
Listen string `json:"listen" yaml:"listen" envconfig:"LISTEN"`
ListenTLS string `json:"listen-tls" yaml:"listen-tls" envconfig:"LISTEN_TLS"`
ListenInternal string `json:"listen-internal" yaml:"listen-internal" envconfig:"LISTEN_INTERNAL"`
ListenInternalTLS string `json:"listen-internal-tls" yaml:"listen-internal-tls" envconfig:"LISTEN_INTERNAL_TLS"`
TLSCert string `json:"tls-cert" yaml:"tls-cert" envconfig:"TLS_CERT"`
TLSKey string `json:"tls-key" yaml:"tls-key" envconfig:"TLS_KEY"`
Brand string `json:"brand" yaml:"brand" envconfig:"BRAND"`
Domain string `json:"domain" yaml:"domain" envconfig:"DOMAIN"`
Headers map[string]string `json:"headers" yaml:"headers" envconfig:"HEADERS"`
SessionCookieName string `json:"session-cookie-name" yaml:"session-cookie-name" envconfig:"SESSION_COOKIE_NAME"`
XSRFCookieName string `json:"xsrf-cookie-name" yaml:"xsrf-cookie-name" envconfig:"XSRF_COOKIE_NAME"`
XSRFHeader string `json:"xsrf-header" yaml:"xsrf-header" envconfig:"XSRF_HEADER"`
XSRFFormField string `json:"xsrf-form-field" yaml:"xsrf-form-field" envconfig:"XSRF_FORM_FIELD"`
Debug bool `json:"debug" yaml:"debug" envconfig:"DEBUG"`
PidFileName string `json:"pid-file" yaml:"pid-file" envconfig:"PID_FILE"`
PidFileMode marshal.Mode `json:"pid-file-mode" yaml:"pid-file-mode" envconfig:"PID_FILE_MODE"`
StorageFileMode marshal.Mode `json:"storage-file-mode" yaml:"storage-file-mode" envconfig:"STORAGE_FILE_MODE"`
StorageDir string `json:"storage-dir" yaml:"storage-dir" envconfig:"STORAGE_DIR"`
AssetsDir string `json:"assets-dir" yaml:"assets-dir" envconfig:"ASSETS_DIR"`
StaticDir string `json:"static-dir" yaml:"static-dir" envconfig:"STATIC_DIR"`
TemplatesDir string `json:"templates-dir" yaml:"templates-dir" envconfig:"TEMPLATES_DIR"`
MaintenanceFilename string `json:"maintenance-filename" yaml:"maintenance-filename" envconfig:"MAINTENANCE_FILENAME"`
GoogleAnalyticsID string `json:"google-analytics-id" yaml:"google-analytics-id" envconfig:"GOOGLE_ANALYTICS_ID"`
ContactRecipientEmail string `json:"contact-recipient-email" yaml:"contact-recipient-email" envconfig:"CONTACT_RECIPIENT_EMAIL"`
SkipDomainVerification bool `json:"skip-domain-verification" yaml:"skip-domain-verification" envconfig:"SKIP_DOMAIN_VERIFICATION"`
VerificationSubdomain string `json:"verification-subdomain" yaml:"verification-subdomain" envconfig:"VERIFICATION_SUBDOMAIN"`
ForbiddenDomains []string `json:"forbidden-domains" yaml:"forbidden-domains" envconfig:"FORBIDDEN_DOMAINS"`
}
GopherPitOptions defines parameters related to service's core functionality.
func NewGopherPitOptions ¶
func NewGopherPitOptions() *GopherPitOptions
NewGopherPitOptions initializes GopherPitOptions with default values.
func (*GopherPitOptions) Prepare ¶
func (o *GopherPitOptions) Prepare() error
Prepare creates configured directories for home, storage, logs and temporary files.
func (*GopherPitOptions) String ¶
func (o *GopherPitOptions) String() string
String returns a JSON representation of the options.
func (*GopherPitOptions) Update ¶
func (o *GopherPitOptions) Update(dirs ...string) error
Update updates options by loading gopherpit.json files.
func (*GopherPitOptions) Verify ¶
func (o *GopherPitOptions) Verify() (help string, err error)
Verify checks if configuration values are valid and if all requirements are set for service to start.
type LDAPOptions ¶ added in v0.2.1
type LDAPOptions struct {
Enabled bool `json:"enabled" yaml:"enabled" envconfig:"ENABLED"`
Host string `json:"host" yaml:"host" envconfig:"HOST"`
Port uint `json:"port" yaml:"port" envconfig:"PORT"`
Secure bool `json:"secure" yaml:"secure" envconfig:"SECURE"`
Username string `json:"username" yaml:"username" envconfig:"USERNAME"`
Password string `json:"password" yaml:"password" envconfig:"PASSWORD"`
DN string `json:"dn" yaml:"dn" envconfig:"DN"`
DNUsers string `json:"dn-users" yaml:"dn-users" envconfig:"DN_USERS"`
DNGroups string `json:"dn-groups" yaml:"dn-groups" envconfig:"DN_GROUPS"`
AttributeUsername string `json:"attribute-username" yaml:"attribute-username" envconfig:"ATTRIBUTE_USERNAME"`
AttributeName string `json:"attribute-name" yaml:"attribute-name" envconfig:"ATTRIBUTE_NAME"`
AttributeEmail string `json:"attribute-email" yaml:"attribute-email" envconfig:"ATTRIBUTE_EMAIL"`
AttributeGroupID string `json:"attribute-group-id" yaml:"attribute-group-id" envconfig:"ATTRIBUTE_GROUP_ID"`
AttributeGroupMember string `json:"attribute-group-member" yaml:"attribute-group-member" envconfig:"ATTRIBUTE_GROUP_MEMBER"`
Groups []string `json:"groups" yaml:"groups" envconfig:"GROUPS"`
MaxConnections int `json:"max-connections" yaml:"max-connections" envconfig:"MAX_CONNECTIONS"`
Timeout marshal.Duration `json:"timeout" yaml:"timeout" envconfig:"TIMEOUT"`
}
LDAPOptions defines parameters for LDAP authentication.
func NewLDAPOptions ¶ added in v0.2.1
func NewLDAPOptions() *LDAPOptions
NewLDAPOptions initializes LDAPOptions with default values.
func (*LDAPOptions) Prepare ¶ added in v0.2.1
func (o *LDAPOptions) Prepare() error
Prepare doesn't do anything, just provides method for Options interface.
func (*LDAPOptions) String ¶ added in v0.2.1
func (o *LDAPOptions) String() string
String returns a JSON representation of the options.
func (*LDAPOptions) Update ¶ added in v0.2.1
func (o *LDAPOptions) Update(dirs ...string) error
Update updates options by loading ldap.json files.
func (*LDAPOptions) Verify ¶ added in v0.2.1
func (o *LDAPOptions) Verify() (help string, err error)
Verify doesn't do anything, just provides method for Options interface.
type LoggingOptions ¶
type LoggingOptions struct {
LogDir string `json:"log-dir" yaml:"log-dir" envconfig:"LOG_DIR"`
LogLevel logging.Level `json:"log-level" yaml:"log-level" envconfig:"LOG_LEVEL"`
LogFileMode marshal.Mode `json:"log-file-mode" yaml:"log-file-mode" envconfig:"LOG_FILE_MODE"`
LogDirectoryMode marshal.Mode `json:"log-directory-mode" yaml:"log-directory-mode" envconfig:"LOG_DIRECTORY_MODE"`
SyslogFacility logging.SyslogFacility `json:"syslog-facility" yaml:"syslog-facility" envconfig:"SYSLOG_FACILITY"`
SyslogTag string `json:"syslog-tag" yaml:"syslog-tag" envconfig:"SYSLOG_TAG"`
SyslogNetwork string `json:"syslog-network" yaml:"syslog-network" envconfig:"SYSLOG_NETWORK"`
SyslogAddress string `json:"syslog-address" yaml:"syslog-address" envconfig:"SYSLOG_ADDRESS"`
AccessLogLevel logging.Level `json:"access-log-level" yaml:"access-log-level" envconfig:"ACCESS_LOG_LEVEL"`
AccessSyslogFacility logging.SyslogFacility `json:"access-syslog-facility" yaml:"access-syslog-facility" envconfig:"ACCESS_SYSLOG_FACILITY"`
AccessSyslogTag string `json:"access-syslog-tag" yaml:"access-syslog-tag" envconfig:"ACCESS_SYSLOG_TAG"`
PackageAccessLogLevel logging.Level `json:"package-access-log-level" yaml:"package-access-log-level" envconfig:"PACKAGE_ACCESS_LOG_LEVEL"`
PackageAccessSyslogFacility logging.SyslogFacility `json:"package-access-syslog-facility" yaml:"package-access-syslog-facility" envconfig:"PACKAGE_ACCESS_SYSLOG_FACILITY"`
PackageAccessSyslogTag string `json:"package-access-syslog-tag" yaml:"package-access-syslog-tag" envconfig:"PACKAGE_ACCESS_SYSLOG_TAG"`
AuditLogDisabled bool `json:"audit-log-disabled" yaml:"audit-log-disabled" envconfig:"AUDIT_LOG_DISABLED"`
AuditSyslogFacility logging.SyslogFacility `json:"audit-syslog-facility" yaml:"audit-syslog-facility" envconfig:"AUDIT_SYSLOG_FACILITY"`
AuditSyslogTag string `json:"audit-syslog-tag" yaml:"audit-syslog-tag" envconfig:"AUDIT_SYSLOG_TAG"`
DaemonLogFileName string `json:"daemon-log-file" yaml:"daemon-log-file" envconfig:"DAEMON_LOG_FILE"`
DaemonLogFileMode marshal.Mode `json:"daemon-log-file-mode" yaml:"daemon-log-file-mode" envconfig:"DAEMON_LOG_FILE_MODE"`
}
LoggingOptions defines parameters related to service's core functionality.
func NewLoggingOptions ¶
func NewLoggingOptions() *LoggingOptions
NewLoggingOptions initializes LoggingOptions with default values.
func (*LoggingOptions) Prepare ¶
func (o *LoggingOptions) Prepare() error
Prepare creates configured directories for home, storage, logs and temporary files.
func (*LoggingOptions) String ¶
func (o *LoggingOptions) String() string
String returns a JSON representation of the options.
func (*LoggingOptions) Update ¶
func (o *LoggingOptions) Update(dirs ...string) error
Update updates options by loading logging.json files.
func (*LoggingOptions) Verify ¶
func (o *LoggingOptions) Verify() (help string, err error)
Verify checks if configuration values are valid and if all requirements are set for service to start.
type Options ¶
type Options interface {
Update(dirs ...string) error
Verify() (help string, err error)
Prepare() error
String() string
}
Options interface defines functionality to update, verify, prepare and display configuration.
type ServicesOptions ¶
type ServicesOptions struct {
UserEndpoint string `json:"user-endpoint" yaml:"user-endpoint" envconfig:"USER_ENDPOINT"`
UserKey string `json:"user-key" yaml:"user-key" envconfig:"USER_KEY"`
UserOptions *httpClient.Options `json:"user-options" yaml:"user-options" envconfig:"USER_OPTIONS"`
SessionEndpoint string `json:"session-endpoint" yaml:"session-endpoint" envconfig:"SESSION_ENDPOINT"`
SessionKey string `json:"session-key" yaml:"session-key" envconfig:"SESSION_KEY"`
SessionOptions *httpClient.Options `json:"session-options" yaml:"session-options" envconfig:"SESSION_OPTIONS"`
NotificationEndpoint string `json:"notification-endpoint" yaml:"notification-endpoint" envconfig:"NOTIFICATION_ENDPOINT"`
NotificationKey string `json:"notification-key" yaml:"notification-key" envconfig:"NOTIFICATION_KEY"`
NotificationOptions *httpClient.Options `json:"notification-options" yaml:"notification-options" envconfig:"NOTIFICATION_OPTIONS"`
CertificateEndpoint string `json:"certificate-endpoint" yaml:"certificate-endpoint" envconfig:"CERTIFICATE_ENDPOINT"`
CertificateKey string `json:"certificate-key" yaml:"certificate-key" envconfig:"CERTIFICATE_KEY"`
CertificateOptions *httpClient.Options `json:"certificate-options" yaml:"certificate-options" envconfig:"CERTIFICATE_OPTIONS"`
PackagesEndpoint string `json:"packages-endpoint" yaml:"packages-endpoint" envconfig:"PACKAGES_ENDPOINT"`
PackagesKey string `json:"packages-key" yaml:"packages-key" envconfig:"PACKAGES_KEY"`
PackagesOptions *httpClient.Options `json:"packages-options" yaml:"packages-options" envconfig:"PACKAGES_OPTIONS"`
}
ServicesOptions defines parameters for communication with external services.
func NewServicesOptions ¶
func NewServicesOptions() *ServicesOptions
NewServicesOptions initializes ServicesOptions with empty values.
func (*ServicesOptions) Prepare ¶
func (o *ServicesOptions) Prepare() error
Prepare doesn't do anything, just provides method for Options interface.
func (*ServicesOptions) String ¶
func (o *ServicesOptions) String() string
String returns a JSON representation of the options.
func (*ServicesOptions) Update ¶
func (o *ServicesOptions) Update(dirs ...string) error
Update updates options by loading services.json files.
func (*ServicesOptions) Verify ¶
func (o *ServicesOptions) Verify() (help string, err error)
Verify doesn't do anything, just provides method for Options interface.
type SessionOptions ¶
type SessionOptions struct {
CleanupPeriod marshal.Duration `json:"cleanup-period" yaml:"cleanup-period" envconfig:"CLEANUP_PERIOD"`
DefaultLifetime marshal.Duration `json:"default-lifetime" yaml:"default-lifetime" envconfig:"DEFAULT_LIFETIME"`
}
SessionOptions defines parameters related to session storage.
func NewSessionOptions ¶
func NewSessionOptions() *SessionOptions
NewSessionOptions initializes SessionOptions with default values.
func (*SessionOptions) Prepare ¶
func (o *SessionOptions) Prepare() error
Prepare doesn't do anything, just provides method for Options interface.
func (*SessionOptions) String ¶
func (o *SessionOptions) String() string
String returns a JSON representation of the options.
func (*SessionOptions) Update ¶
func (o *SessionOptions) Update(dirs ...string) error
Update updates options by loading session.json files.
func (*SessionOptions) Verify ¶
func (o *SessionOptions) Verify() (help string, err error)
Verify doesn't do anything, just provides method for Options interface.
type UserOptions ¶
type UserOptions struct {
RememberMeDays int `json:"remember-me-days" yaml:"remember-me-days" envconfig:"REMEMBER_ME_DAYS"`
PasswordNoReuseMonths int `json:"password-no-reuse-months" yaml:"password-no-reuse-months" envconfig:"PASSWORD_NO_REUSE_MONTHS"`
}
UserOptions defines parameters related to the user management.
func NewUserOptions ¶
func NewUserOptions() *UserOptions
NewUserOptions initializes UserOptions with default values.
func (*UserOptions) Prepare ¶
func (o *UserOptions) Prepare() error
Prepare doesn't do anything, just provides method for Options interface.
func (*UserOptions) String ¶
func (o *UserOptions) String() string
String returns a JSON representation of the options.
func (*UserOptions) Update ¶
func (o *UserOptions) Update(dirs ...string) error
Update updates options by loading user.json files.
func (*UserOptions) Verify ¶
func (o *UserOptions) Verify() (help string, err error)
Verify doesn't do anything, just provides method for Options interface.