3
0

Merge branch '2020.12.x-feature-opt-codegen' into 2020.12.x

This commit is contained in:
Urban Klinc
2020-11-27 09:46:05 +01:00
58 changed files with 1320 additions and 507 deletions
+12 -18
View File
@@ -24,29 +24,23 @@ type (
}
)
func NewOptions(prefix ...string) *Options {
var p = ""
if len(prefix) > 0 {
p = prefix[0]
}
func NewOptions() *Options {
// @todo remover prefixes on opt constructors and
// pass in EnvironmentOpt so we can have environment-dependant defaults
return &Options{
Environment: *options.Environment(),
ActionLog: *options.ActionLog(),
Auth: *options.Auth(),
SMTP: *options.SMTP(p),
HTTPClient: *options.HttpClient(p),
DB: *options.DB(p),
Upgrade: *options.Upgrade(p),
Provision: *options.Provision(p),
Sentry: *options.Sentry(p),
ObjStore: *options.ObjectStore(p),
SMTP: *options.SMTP(),
HTTPClient: *options.HTTPClient(),
DB: *options.DB(),
Upgrade: *options.Upgrade(),
Provision: *options.Provision(),
Sentry: *options.Sentry(),
ObjStore: *options.ObjectStore(),
Corredor: *options.Corredor(),
Monitor: *options.Monitor(p),
WaitFor: *options.WaitFor(p),
HTTPServer: *options.HTTP(p),
Websocket: *options.Websocket(p),
Monitor: *options.Monitor(),
WaitFor: *options.WaitFor(),
HTTPServer: *options.HTTPServer(),
Websocket: *options.Websocket(),
}
}
+6 -1
View File
@@ -4,6 +4,7 @@ go 1.15
require (
cloud.google.com/go v0.44.3 // indirect
github.com/0xAX/notificator v0.0.0-20191016112426-3962a5ea8da1 // indirect
github.com/360EntSecGroup-Skylar/excelize/v2 v2.0.2
github.com/766b/chi-prometheus v0.0.0-20180509160047-46ac2b31aa30
github.com/99designs/basicauth-go v0.0.0-20160802081356-2a93ba0f464d
@@ -14,6 +15,8 @@ require (
github.com/PaesslerAG/gval v1.0.1 // indirect
github.com/PaesslerAG/jsonpath v0.1.1 // indirect
github.com/SentimensRG/ctx v0.0.0-20180729130232-0bfd988c655d
github.com/codegangsta/envy v0.0.0-20141216192214-4b78388c8ce4 // indirect
github.com/codegangsta/gin v0.0.0-20171026143024-cafe2ce98974 // indirect
github.com/crusttech/go-oidc v0.0.0-20180918092017-982855dad3e1
github.com/davecgh/go-spew v1.1.1
github.com/deckarep/golang-set v1.7.1 // indirect
@@ -44,6 +47,7 @@ require (
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0
github.com/lib/pq v1.1.0
github.com/markbates/goth v1.50.0
github.com/mattn/go-shellwords v1.0.10 // indirect
github.com/mattn/go-sqlite3 v1.14.0
github.com/minio/minio-go/v6 v6.0.39
github.com/mitchellh/copystructure v1.0.0 // indirect
@@ -73,6 +77,7 @@ require (
gopkg.in/ini.v1 v1.51.0 // indirect
gopkg.in/mail.v2 v2.3.1
gopkg.in/square/go-jose.v2 v2.3.1 // indirect
gopkg.in/urfave/cli.v1 v1.20.0 // indirect
gopkg.in/yaml.v2 v2.3.0
gopkg.in/yaml.v3 v3.0.0-20200601152816-913338de1bd2 // indirect
gopkg.in/yaml.v3 v3.0.0-20200601152816-913338de1bd2
)
+10
View File
@@ -6,6 +6,8 @@ cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6A
cloud.google.com/go v0.44.3 h1:0sMegbmn/8uTwpNkB0q9cLEpZ2W5a6kl+wtBQgPWBJQ=
cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
github.com/0xAX/notificator v0.0.0-20191016112426-3962a5ea8da1 h1:j9HaafapDbPbGRDku6e/HRs6KBMcKHiWcm1/9Sbxnl4=
github.com/0xAX/notificator v0.0.0-20191016112426-3962a5ea8da1/go.mod h1:NtXa9WwQsukMHZpjNakTTz0LArxvGYdPA9CjIcUSZ6s=
github.com/360EntSecGroup-Skylar/excelize/v2 v2.0.2 h1:StMrA6UQ5Cm6206DxXGuV/NMqSIOIDoMXMYt8JPe1lE=
github.com/360EntSecGroup-Skylar/excelize/v2 v2.0.2/go.mod h1:EfRHD2k+Kd7ijnqlwOrH1IifwgWB9yYJ0pdXtBZmlpU=
github.com/766b/chi-prometheus v0.0.0-20180509160047-46ac2b31aa30 h1:bNHbCMKiQxpRNe4Pk2W09N1aXXc4ICOawQFKIDEicqc=
@@ -44,6 +46,10 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/codegangsta/envy v0.0.0-20141216192214-4b78388c8ce4 h1:ihrIKrLQzm6Q6NJHBMemvaIGTFxgxQUEkn2AjN0Aulw=
github.com/codegangsta/envy v0.0.0-20141216192214-4b78388c8ce4/go.mod h1:X7wHz0C25Lga6CnJ4WAQNbUQ9P/8eWSNv8qIO71YkSM=
github.com/codegangsta/gin v0.0.0-20171026143024-cafe2ce98974 h1:ysuVNDVE4LIky6I+6JlgAKG+wBNKMpVv3m3neVpvFVw=
github.com/codegangsta/gin v0.0.0-20171026143024-cafe2ce98974/go.mod h1:UBYuwaH3dMw91EZ7tGVaFF6GDj5j46S7zqB9lZPIe58=
github.com/crusttech/go-oidc v0.0.0-20180918092017-982855dad3e1 h1:V2GKd4ImRY9lFUu3TclHNmqgJCADdA7muym9JuVEPlY=
github.com/crusttech/go-oidc v0.0.0-20180918092017-982855dad3e1/go.mod h1:2LVBu240CBZgYkGOSRx733tkh9QUNcH+fIqmeAsdrds=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -176,6 +182,8 @@ github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/markbates/going v1.0.0/go.mod h1:I6mnB4BPnEeqo85ynXIx1ZFLLbtiLHNXVgWeFO9OGOA=
github.com/markbates/goth v1.50.0 h1:KCAErbDdHh11gQAJs/GV73LCv4NwA7Z6wNZAU32ggMc=
github.com/markbates/goth v1.50.0/go.mod h1:zZmAw0Es0Dpm7TT/4AdN14QrkiWLMrrU9Xei1o+/mdA=
github.com/mattn/go-shellwords v1.0.10 h1:Y7Xqm8piKOO3v10Thp7Z36h4FYFjt5xB//6XvOrs2Gw=
github.com/mattn/go-shellwords v1.0.10/go.mod h1:EZzvwXDESEeg03EKmM+RmDnNOPKG4lLtQsUlTZDWQ8Y=
github.com/mattn/go-sqlite3 v1.9.0 h1:pDRiWfl+++eC2FEFRy6jXmQlvp4Yh3z1MJKg4UeYM/4=
github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/mattn/go-sqlite3 v1.14.0 h1:mLyGNKR8+Vv9CAU7PphKa2hkEqxxhn8i32J6FPj1/QA=
@@ -416,6 +424,8 @@ gopkg.in/mail.v2 v2.3.1 h1:WYFn/oANrAGP2C0dcV6/pbkPzv8yGzqTjPmTeO7qoXk=
gopkg.in/mail.v2 v2.3.1/go.mod h1:htwXN1Qh09vZJ1NVKxQqHPBaCBbzKhp5GzuJEA4VJWw=
gopkg.in/square/go-jose.v2 v2.3.1 h1:SK5KegNXmKmqE342YYN2qPHEnUYeoMiXXl1poUlI+o4=
gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
gopkg.in/urfave/cli.v1 v1.20.0 h1:NdAVW6RYxDif9DhDHaAortIu956m2c0v+09AZBPTbE0=
gopkg.in/urfave/cli.v1 v1.20.0/go.mod h1:vuBzUtMdQeixQj8LVd+/98pzhxNGQoyuPBlsXHOQNO0=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+48
View File
@@ -0,0 +1,48 @@
package {{ .Package }}
// This file is auto-generated.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
// Definitions file that controls how this file is generated:
// {{ .Source }}
{{ if $.Imports -}}
import (
{{- range .Imports }}
{{ normalizeImport . }}
{{- end }}
){{ end }}
type (
{{ export $.Name }}Opt struct {
{{- range $prop := $.Properties}}
{{ export $prop.Name }} {{ $prop.Type }} `env:"{{ toUpper $prop.Env}}"`
{{- end }}
}
)
// {{ export $.Name }} initializes and returns a {{ export $.Name }}Opt with default values
func {{ export $.Name }}() (o *{{ export $.Name }}Opt) {
o = &{{ export $.Name }}Opt{
{{- range $prop := $.Properties }}
{{- if $prop.Default }}
{{ export $prop.Name }}: {{ $prop.Default }},
{{- end }}
{{- end }}
}
fill(o)
// Function that allows access to custom logic inside the parent function.
// The custom logic in the other file should be like:
// func (o *{{ export $.Name}}) Defaults() {...}
func(o interface{}) {
if def, ok := o.(interface{ Defaults() }); ok {
def.Defaults()
}
}(o)
return
}
+21 -3
View File
@@ -3,13 +3,14 @@ package codegen
import (
"flag"
"fmt"
"github.com/Masterminds/sprig"
"github.com/cortezaproject/corteza-server/pkg/cli"
"github.com/fsnotify/fsnotify"
"os"
"path/filepath"
"strings"
"text/template"
"github.com/Masterminds/sprig"
"github.com/cortezaproject/corteza-server/pkg/cli"
"github.com/fsnotify/fsnotify"
)
func Proc() {
@@ -47,6 +48,10 @@ func Proc() {
storeSrc []string
storeDefs []*storeDef
optionSrcPath = filepath.Join("pkg", "options", "*.yaml")
optionSrc []string
optionDefs []*optionsDef
tpls *template.Template
tplBase = template.New("").
Funcs(map[string]interface{}{
@@ -55,6 +60,7 @@ func Proc() {
"unexport": unexport,
"toggleExport": toggleExport,
"toLower": strings.ToLower,
"toUpper": strings.ToUpper,
"cc2underscore": cc2underscore,
"normalizeImport": normalizeImport,
"comment": func(text string, skip1st bool) string {
@@ -123,6 +129,9 @@ func Proc() {
storeSrc = glob(storeSrcPath)
output("loaded %d store definitions from %s\n", len(storeSrc), storeSrcPath)
optionSrc = glob(optionSrcPath)
output("loaded %d option defenitions from %s\n", len(optionSrc), optionSrcPath)
if watchChanges {
if watcher != nil {
watcher.Close()
@@ -137,6 +146,7 @@ func Proc() {
fileList = append(fileList, typeSrc...)
fileList = append(fileList, restSrc...)
fileList = append(fileList, storeSrc...)
fileList = append(fileList, optionSrc...)
for _, d := range fileList {
cli.HandleError(watcher.Add(d))
@@ -189,6 +199,14 @@ func Proc() {
return
}
if optionDefs, err = procOptions(optionSrc...); err == nil {
err = genOptions(tpls, optionDefs...)
}
if outputErr(err, "fail to process options:\n") {
return
}
}()
if !watchChanges {
+122
View File
@@ -0,0 +1,122 @@
package codegen
import (
"fmt"
"io"
"os"
"path"
"strings"
"text/template"
"gopkg.in/yaml.v3"
)
type (
optionsDef struct {
Source string
outputDir string
Name string
// List of imports
// Used only by generated file and not pre-generated-user-file
Imports []string `yaml:"imports"`
Properties optionsPropSet `yaml:"props"`
}
optionsPropSet []*optionsProp
optionsProp struct {
Name string
Type string
Env string
Default *optionsPropDefault
}
optionsPropDefault string
)
// Processes multiple options defenitions
func procOptions(mm ...string) (dd []*optionsDef, err error) {
var (
f io.ReadCloser
d *optionsDef
)
dd = make([]*optionsDef, 0)
for _, m := range mm {
err = func() error {
if f, err = os.Open(m); err != nil {
return err
}
defer f.Close()
d = &optionsDef{}
if err := yaml.NewDecoder(f).Decode(d); err != nil {
return err
}
for _, j := range d.Properties {
if j.Type == "" {
j.Type = "string"
}
if j.Env == "" {
j.Env = strings.ToUpper(d.Name + "_" + cc2underscore(j.Name))
}
}
d.Source = m
d.outputDir = path.Dir(m)
dd = append(dd, d)
return nil
}()
if err != nil {
return nil, fmt.Errorf("could not process %s: %w", m, err)
}
}
return dd, nil
}
// Custom UnmarshalYAML function for
func (pd *optionsPropDefault) UnmarshalYAML(n *yaml.Node) error {
val := n.Value
if n.Style == yaml.DoubleQuotedStyle {
val = "\"" + val + "\""
}
*pd = optionsPropDefault(val)
return nil
}
// Gets package name from file path
func (o optionsDef) Package() string {
return path.Base(path.Dir(o.Source))
}
func genOptions(tpl *template.Template, dd ...*optionsDef) (err error) {
var (
tplOptionsGen = tpl.Lookup("options.go.tpl")
dst string
)
for _, d := range dd {
dst = path.Join(d.outputDir, path.Base(d.Source)[:strings.LastIndex(path.Base(d.Source), ".")]+".gen.go")
err = goTemplate(dst, tplOptionsGen, d)
if err != nil {
return
}
}
return nil
}
+35
View File
@@ -0,0 +1,35 @@
package options
// This file is auto-generated.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
// Definitions file that controls how this file is generated:
// pkg/options/DB.yaml
type (
DBOpt struct {
DSN string `env:"DB_DSN"`
}
)
// DB initializes and returns a DBOpt with default values
func DB() (o *DBOpt) {
o = &DBOpt{
DSN: "sqlite3://file::memory:?cache=shared&mode=memory",
}
fill(o)
// Function that allows access to custom logic inside the parent function.
// The custom logic in the other file should be like:
// func (o *DB) Defaults() {...}
func(o interface{}) {
if def, ok := o.(interface{ Defaults() }); ok {
def.Defaults()
}
}(o)
return
}
+12
View File
@@ -0,0 +1,12 @@
package options
import (
"strings"
)
func (o *DBOpt) Defaults() {
if o.DSN != "" && !strings.Contains(o.DSN, "://") {
// Make sure DSN is compatible with new requirements
o.DSN = "mysql://" + o.DSN
}
}
+6
View File
@@ -0,0 +1,6 @@
name: DB
props:
- name: DSN
default: "sqlite3://file::memory:?cache=shared&mode=memory"
+41
View File
@@ -0,0 +1,41 @@
package options
// This file is auto-generated.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
// Definitions file that controls how this file is generated:
// pkg/options/HTTPClient.yaml
import (
"time"
)
type (
HTTPClientOpt struct {
ClientTSLInsecure bool `env:"HTTP_CLIENT_TSL_INSECURE"`
HttpClientTimeout time.Duration `env:"HTTP_CLIENT_TIMEOUT"`
}
)
// HTTPClient initializes and returns a HTTPClientOpt with default values
func HTTPClient() (o *HTTPClientOpt) {
o = &HTTPClientOpt{
ClientTSLInsecure: false,
HttpClientTimeout: 30 * time.Second,
}
fill(o)
// Function that allows access to custom logic inside the parent function.
// The custom logic in the other file should be like:
// func (o *HTTPClient) Defaults() {...}
func(o interface{}) {
if def, ok := o.(interface{ Defaults() }); ok {
def.Defaults()
}
}(o)
return
}
+16
View File
@@ -0,0 +1,16 @@
name: HTTPClient
imports:
- time
props:
- name: clientTSLInsecure
type: bool
env: HTTP_CLIENT_TSL_INSECURE
default: false
- name: httpClientTimeout
type: time.Duration
env: HTTP_CLIENT_TIMEOUT
default: 30 * time.Second
+72
View File
@@ -0,0 +1,72 @@
package options
// This file is auto-generated.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
// Definitions file that controls how this file is generated:
// pkg/options/HTTPServer.yaml
import (
"github.com/cortezaproject/corteza-server/pkg/rand"
)
type (
HTTPServerOpt struct {
Addr string `env:"HTTP_ADDR"`
LogRequest bool `env:"HTTP_LOG_REQUEST"`
LogResponse bool `env:"HTTP_LOG_RESPONSE"`
Tracing bool `env:"HTTP_ERROR_TRACING"`
EnableHealthcheckRoute bool `env:"HTTP_ENABLE_HEALTHCHECK_ROUTE"`
EnableVersionRoute bool `env:"HTTP_ENABLE_VERSION_ROUTE"`
EnableDebugRoute bool `env:"HTTP_ENABLE_DEBUG_ROUTE"`
EnableMetrics bool `env:"HTTP_METRICS"`
MetricsServiceLabel string `env:"HTTP_METRICS_NAME"`
MetricsUsername string `env:"HTTP_METRICS_USERNAME"`
MetricsPassword string `env:"HTTP_METRICS_PASSWORD"`
EnablePanicReporting bool `env:"HTTP_REPORT_PANIC"`
ApiEnabled bool `env:"HTTP_API_ENABLED"`
ApiBaseUrl string `env:"HTTP_API_BASE_URL"`
WebappEnabled bool `env:"HTTP_WEBAPP_ENABLED"`
WebappBaseUrl string `env:"HTTP_WEBAPP_BASE_URL"`
WebappBaseDir string `env:"HTTP_WEBAPP_BASE_DIR"`
WebappList string `env:"HTTP_WEBAPP_LIST"`
}
)
// HTTPServer initializes and returns a HTTPServerOpt with default values
func HTTPServer() (o *HTTPServerOpt) {
o = &HTTPServerOpt{
Addr: ":80",
LogRequest: false,
LogResponse: false,
Tracing: false,
EnableHealthcheckRoute: true,
EnableVersionRoute: true,
EnableDebugRoute: false,
EnableMetrics: false,
MetricsServiceLabel: "corteza",
MetricsUsername: "metrics",
MetricsPassword: string(rand.Bytes(5)),
EnablePanicReporting: true,
ApiEnabled: true,
WebappEnabled: false,
WebappBaseUrl: "/",
WebappBaseDir: "webapp/public",
WebappList: "admin,auth,messaging,compose",
}
fill(o)
// Function that allows access to custom logic inside the parent function.
// The custom logic in the other file should be like:
// func (o *HTTPServer) Defaults() {...}
func(o interface{}) {
if def, ok := o.(interface{ Defaults() }); ok {
def.Defaults()
}
}(o)
return
}
+12
View File
@@ -0,0 +1,12 @@
package options
func (o *HTTPServerOpt) Defaults() {
if o.WebappEnabled && o.ApiEnabled && o.ApiBaseUrl == "" {
// api base URL is still on root (empty string)
// but webapps are enabled (that means, server also serves static files from WebappBaseDir)
//
// Let's be nice and move API to /api
o.ApiBaseUrl = "/api"
}
}
+87
View File
@@ -0,0 +1,87 @@
name: HTTPServer
imports:
- github.com/cortezaproject/corteza-server/pkg/rand
props:
- name: addr
env: HTTP_ADDR
default: ":80"
- name: logRequest
type: bool
env: HTTP_LOG_REQUEST
default: false
- name: logResponse
type: bool
env: HTTP_LOG_RESPONSE
default: false
- name: tracing
type: bool
env: HTTP_ERROR_TRACING
default: false
- name: enableHealthcheckRoute
type: bool
env: HTTP_ENABLE_HEALTHCHECK_ROUTE
default: true
- name: enableVersionRoute
type: bool
env: HTTP_ENABLE_VERSION_ROUTE
default: true
- name: enableDebugRoute
type: bool
env: HTTP_ENABLE_DEBUG_ROUTE
default: false
- name: enableMetrics
type: bool
env: HTTP_METRICS
default: false
- name: metricsServiceLabel
env: HTTP_METRICS_NAME
default: "corteza"
- name: metricsUsername
env: HTTP_METRICS_USERNAME
default: "metrics"
- name: metricsPassword
env: HTTP_METRICS_PASSWORD
default: string(rand.Bytes(5))
- name: enablePanicReporting
type: bool
env: HTTP_REPORT_PANIC
default: true
- name: apiEnabled
type: bool
env: HTTP_API_ENABLED
default: true
- name: apiBaseUrl
env: HTTP_API_BASE_URL
- name: webappEnabled
type: bool
env: HTTP_WEBAPP_ENABLED
default: false
- name: webappBaseUrl
env: HTTP_WEBAPP_BASE_URL
default: "/"
- name: webappBaseDir
env: HTTP_WEBAPP_BASE_DIR
default: "webapp/public"
- name: webappList
env: HTTP_WEBAPP_LIST
default: "admin,auth,messaging,compose"
+32
View File
@@ -0,0 +1,32 @@
# Options YAML integration
This file is meant to help with the creation of a .YAML file inside options package.
The name of the .YAML will dedicate the name of the .gen.go file e.g. fileName1.yaml -> fileName1.gen.go, filename2.yaml -> filename2.gen.go
The contents of the .YAML file should look like this:
name: ...
imports:
- ...
props
- name: ...
type: ...
env: ...
default: ...
**name**
- It is the name of the struct
**imports**
- The list of imports that are needed, if there are no imporsts you may skip this step
**props**
- props: - *name* -> name of variable
- props: - *type* -> the type of variable if not given it is "string" by default
- props: - *env* -> environment value that if it is not defined will be auto generated from "name" and "props: - name"
- props: - *default* -> the default value that is asigned to the "prop" strings should be given in double quotations if they are to be qouted
+43
View File
@@ -0,0 +1,43 @@
package options
// This file is auto-generated.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
// Definitions file that controls how this file is generated:
// pkg/options/SMTP.yaml
type (
SMTPOpt struct {
Host string `env:"SMTP_HOST"`
Port int `env:"SMTP_PORT"`
User string `env:"SMTP_USER"`
Pass string `env:"SMTP_PASS"`
From string `env:"SMTP_FROM"`
TlsInsecure bool `env:"SMTP_TLS_INSECURE"`
TlsServerName string `env:"SMTP_TLS_SERVER_NAME"`
}
)
// SMTP initializes and returns a SMTPOpt with default values
func SMTP() (o *SMTPOpt) {
o = &SMTPOpt{
Host: "localhost",
Port: 25,
TlsInsecure: false,
}
fill(o)
// Function that allows access to custom logic inside the parent function.
// The custom logic in the other file should be like:
// func (o *SMTP) Defaults() {...}
func(o interface{}) {
if def, ok := o.(interface{ Defaults() }); ok {
def.Defaults()
}
}(o)
return
}
+22
View File
@@ -0,0 +1,22 @@
name: SMTP
props:
- name: host
default: "localhost"
- name: port
type: int
default: 25
- name: user
- name: pass
- name: from
- name: tlsInsecure
type: bool
default: false
- name: tlsServerName
+37
View File
@@ -0,0 +1,37 @@
package options
// This file is auto-generated.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
// Definitions file that controls how this file is generated:
// pkg/options/actionLog.yaml
type (
ActionLogOpt struct {
Enabled bool `env:"ACTIONLOG_ENABLED"`
Debug bool `env:"ACTIONLOG_DEBUG"`
}
)
// ActionLog initializes and returns a ActionLogOpt with default values
func ActionLog() (o *ActionLogOpt) {
o = &ActionLogOpt{
Enabled: true,
Debug: false,
}
fill(o)
// Function that allows access to custom logic inside the parent function.
// The custom logic in the other file should be like:
// func (o *ActionLog) Defaults() {...}
func(o interface{}) {
if def, ok := o.(interface{ Defaults() }); ok {
def.Defaults()
}
}(o)
return
}
+11
View File
@@ -0,0 +1,11 @@
name: actionLog
props:
- name: enabled
type: bool
default: true
- name: debug
type: bool
default: false
-19
View File
@@ -1,19 +0,0 @@
package options
type (
ActionLogOpt struct {
Enabled bool `env:"ACTIONLOG_ENABLED"`
Debug bool `env:"ACTIONLOG_DEBUG"`
}
)
func ActionLog() (o *ActionLogOpt) {
o = &ActionLogOpt{
Enabled: true,
Debug: false,
}
fill(o)
return
}
+40
View File
@@ -0,0 +1,40 @@
package options
// This file is auto-generated.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
// Definitions file that controls how this file is generated:
// pkg/options/auth.yaml
import (
"time"
)
type (
AuthOpt struct {
Secret string `env:"AUTH_JWT_SECRET"`
Expiry time.Duration `env:"AUTH_JWT_EXPIRY"`
}
)
// Auth initializes and returns a AuthOpt with default values
func Auth() (o *AuthOpt) {
o = &AuthOpt{
Expiry: time.Hour * 24 * 30,
}
fill(o)
// Function that allows access to custom logic inside the parent function.
// The custom logic in the other file should be like:
// func (o *Auth) Defaults() {...}
func(o interface{}) {
if def, ok := o.(interface{ Defaults() }); ok {
def.Defaults()
}
}(o)
return
}
+12
View File
@@ -0,0 +1,12 @@
package options
import (
"github.com/cortezaproject/corteza-server/pkg/rand"
)
func (o *AuthOpt) Defaults() {
if o.Secret == "" {
o.Secret = string(rand.Bytes(32))
}
}
+15
View File
@@ -0,0 +1,15 @@
name: auth
imports:
- time
#- github.com/cortezaproject/corteza-server/pkg/rand
props:
- name: secret
env: AUTH_JWT_SECRET
- name: expiry
type: time.Duration
env: AUTH_JWT_EXPIRY
default: time.Hour * 24 * 30
+64
View File
@@ -0,0 +1,64 @@
package options
// This file is auto-generated.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
// Definitions file that controls how this file is generated:
// pkg/options/corredor.yaml
import (
"time"
)
type (
CorredorOpt struct {
Enabled bool `env:"CORREDOR_ENABLED"`
Addr string `env:"CORREDOR_ADDR"`
MaxBackoffDelay time.Duration `env:"CORREDOR_MAX_BACKOFF_DELAY"`
MaxReceiveMessageSize int `env:"CORREDOR_MAX_RECEIVE_MESSAGE_SIZE"`
DefaultExecTimeout time.Duration `env:"CORREDOR_DEFAULT_EXEC_TIMEOUT"`
ListTimeout time.Duration `env:"CORREDOR_LIST_TIMEOUT"`
ListRefresh time.Duration `env:"CORREDOR_LIST_REFRESH"`
RunAsEnabled bool `env:"CORREDOR_RUN_AS_ENABLED"`
TlsCertEnabled bool `env:"CORREDOR_CLIENT_CERTIFICATES_ENABLED"`
TlsCertPath string `env:"CORREDOR_CLIENT_CERTIFICATES_PATH"`
TlsCertCA string `env:"CORREDOR_CLIENT_CERTIFICATES_CA"`
TlsCertPrivate string `env:"CORREDOR_CLIENT_CERTIFICATES_PRIVATE"`
TlsCertPublic string `env:"CORREDOR_CLIENT_CERTIFICATES_PUBLIC"`
TlsServerName string `env:"CORREDOR_CLIENT_CERTIFICATES_SERVER_NAME"`
}
)
// Corredor initializes and returns a CorredorOpt with default values
func Corredor() (o *CorredorOpt) {
o = &CorredorOpt{
Enabled: true,
Addr: "localhost:50051",
MaxBackoffDelay: time.Minute,
MaxReceiveMessageSize: 2 << 23,
DefaultExecTimeout: time.Minute,
ListTimeout: time.Second * 2,
ListRefresh: time.Second * 5,
RunAsEnabled: true,
TlsCertEnabled: false,
TlsCertPath: "/certs/corredor/client",
TlsCertCA: "ca.crt",
TlsCertPrivate: "private.key",
TlsCertPublic: "public.crt",
}
fill(o)
// Function that allows access to custom logic inside the parent function.
// The custom logic in the other file should be like:
// func (o *Corredor) Defaults() {...}
func(o interface{}) {
if def, ok := o.(interface{ Defaults() }); ok {
def.Defaults()
}
}(o)
return
}
+1 -51
View File
@@ -2,60 +2,10 @@ package options
import (
"path"
"time"
)
type (
CorredorOpt struct {
Enabled bool `env:"CORREDOR_ENABLED"`
// Also used by corredor service to configure gRPC server
Addr string `env:"CORREDOR_ADDR"`
MaxBackoffDelay time.Duration `env:"CORREDOR_MAX_BACKOFF_DELAY"`
MaxReceiveMessageSize int `env:"CORREDOR_MAX_RECEIVE_MESSAGE_SIZE"`
DefaultExecTimeout time.Duration `env:"CORREDOR_DEFAULT_EXEC_TIMEOUT"`
ListTimeout time.Duration `env:"CORREDOR_LIST_TIMEOUT"`
ListRefresh time.Duration `env:"CORREDOR_LIST_REFRESH"`
// Allow scripts to have runner explicitly defined
RunAsEnabled bool `env:"CORREDOR_RUN_AS_ENABLED"`
TlsCertEnabled bool `env:"CORREDOR_CLIENT_CERTIFICATES_ENABLED"`
TlsCertPath string `env:"CORREDOR_CLIENT_CERTIFICATES_PATH"`
TlsCertCA string `env:"CORREDOR_CLIENT_CERTIFICATES_CA"`
TlsCertPrivate string `env:"CORREDOR_CLIENT_CERTIFICATES_PRIVATE"`
TlsCertPublic string `env:"CORREDOR_CLIENT_CERTIFICATES_PUBLIC"`
TlsServerName string `env:"CORREDOR_CLIENT_CERTIFICATES_SERVER_NAME"`
}
)
func Corredor() (o *CorredorOpt) {
o = &CorredorOpt{
Enabled: true,
RunAsEnabled: true,
Addr: "localhost:50051",
MaxBackoffDelay: time.Minute,
MaxReceiveMessageSize: 2 << 23, // 16MB
DefaultExecTimeout: time.Minute,
ListTimeout: time.Second * 2,
ListRefresh: time.Second * 5,
TlsCertEnabled: false,
TlsCertPath: "/certs/corredor/client",
TlsCertCA: "ca.crt",
TlsCertPublic: "public.crt",
TlsCertPrivate: "private.key",
}
fill(o)
func (o *CorredorOpt) Defaults() {
o.TlsCertCA = path.Join(o.TlsCertPath, o.TlsCertCA)
o.TlsCertPrivate = path.Join(o.TlsCertPath, o.TlsCertPrivate)
o.TlsCertPublic = path.Join(o.TlsCertPath, o.TlsCertPublic)
return
}
+61
View File
@@ -0,0 +1,61 @@
name: corredor
imports:
- "time"
props:
- name: enabled
type: bool
default: true
- name: addr
default: "localhost:50051"
- name: maxBackoffDelay
type: time.Duration
default: time.Minute
- name: maxReceiveMessageSize
type: int
default: 2 << 23
- name: defaultExecTimeout
type: time.Duration
default: time.Minute
- name: listTimeout
type: time.Duration
default: time.Second * 2
- name: listRefresh
type: time.Duration
default: time.Second * 5
- name: runAsEnabled
type: bool
default: true
- name: tlsCertEnabled
type: bool
env: corredor_client_certificates_enabled
default: false
- name: tlsCertPath
env: corredor_client_certificates_path
default: "/certs/corredor/client"
- name: tlsCertCA
env: CORREDOR_CLIENT_CERTIFICATES_CA
default: "ca.crt"
- name: tlsCertPrivate
env: CORREDOR_CLIENT_CERTIFICATES_PRIVATE
default: "private.key"
- name: tlsCertPublic
env: CORREDOR_CLIENT_CERTIFICATES_PUBLIC
default: "public.crt"
- name: tlsServerName
env: CORREDOR_CLIENT_CERTIFICATES_SERVER_NAME
-26
View File
@@ -1,26 +0,0 @@
package options
import (
"strings"
)
type (
DBOpt struct {
DSN string `env:"DB_DSN"`
}
)
func DB(pfix string) (o *DBOpt) {
o = &DBOpt{
DSN: "sqlite3://file::memory:?cache=shared&mode=memory",
}
fill(o)
if o.DSN != "" && !strings.Contains(o.DSN, "://") {
// Make sure DSN is compatible with new requirements
o.DSN = "mysql://" + o.DSN
}
return
}
+35
View File
@@ -0,0 +1,35 @@
package options
// This file is auto-generated.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
// Definitions file that controls how this file is generated:
// pkg/options/environment.yaml
type (
EnvironmentOpt struct {
Environment string `env:"ENVIRONMENT"`
}
)
// Environment initializes and returns a EnvironmentOpt with default values
func Environment() (o *EnvironmentOpt) {
o = &EnvironmentOpt{
Environment: "production",
}
fill(o)
// Function that allows access to custom logic inside the parent function.
// The custom logic in the other file should be like:
// func (o *Environment) Defaults() {...}
func(o interface{}) {
if def, ok := o.(interface{ Defaults() }); ok {
def.Defaults()
}
}(o)
return
}
-16
View File
@@ -2,22 +2,6 @@ package options
import "strings"
type (
EnvironmentOpt struct {
Environment string `env:"ENVIRONMENT"`
}
)
func Environment() (o *EnvironmentOpt) {
o = &EnvironmentOpt{
Environment: "production",
}
fill(o)
return
}
func (e EnvironmentOpt) IsDevelopment() bool {
return strings.HasPrefix(e.Environment, "dev")
}
+7
View File
@@ -0,0 +1,7 @@
name: environment
props:
- name: environment
default: "production"
env: ENVIRONMENT
+6
View File
@@ -8,6 +8,12 @@ import (
"github.com/spf13/cast"
)
type (
filler interface {
fill()
}
)
func fill(opt interface{}) {
v := reflect.ValueOf(opt)
if v.Kind() != reflect.Ptr {
-74
View File
@@ -1,74 +0,0 @@
package options
import (
"github.com/cortezaproject/corteza-server/pkg/rand"
)
type (
HTTPServerOpt struct {
Addr string `env:"HTTP_ADDR"`
LogRequest bool `env:"HTTP_LOG_REQUEST"`
LogResponse bool `env:"HTTP_LOG_RESPONSE"`
Tracing bool `env:"HTTP_ERROR_TRACING"`
EnableHealthcheckRoute bool `env:"HTTP_ENABLE_HEALTHCHECK_ROUTE"`
EnableVersionRoute bool `env:"HTTP_ENABLE_VERSION_ROUTE"`
EnableDebugRoute bool `env:"HTTP_ENABLE_DEBUG_ROUTE"`
EnableMetrics bool `env:"HTTP_METRICS"`
MetricsServiceLabel string `env:"HTTP_METRICS_NAME"`
MetricsUsername string `env:"HTTP_METRICS_USERNAME"`
MetricsPassword string `env:"HTTP_METRICS_PASSWORD"`
EnablePanicReporting bool `env:"HTTP_REPORT_PANIC"`
ApiEnabled bool `env:"HTTP_API_ENABLED"`
ApiBaseUrl string `env:"HTTP_API_BASE_URL"`
WebappEnabled bool `env:"HTTP_WEBAPP_ENABLED"`
WebappBaseUrl string `env:"HTTP_WEBAPP_BASE_URL"`
WebappBaseDir string `env:"HTTP_WEBAPP_BASE_DIR"`
WebappList string `env:"HTTP_WEBAPP_LIST"`
}
)
func HTTP(pfix string) (o *HTTPServerOpt) {
o = &HTTPServerOpt{
Addr: ":80",
LogRequest: false,
LogResponse: false,
Tracing: false,
EnableHealthcheckRoute: true,
EnableVersionRoute: true,
EnableDebugRoute: false,
EnableMetrics: false,
MetricsServiceLabel: "corteza",
MetricsUsername: "metrics",
// Reports panics to Sentry through HTTP middleware
EnablePanicReporting: true,
// Setting metrics password to random string to prevent security accidents...
MetricsPassword: string(rand.Bytes(5)),
ApiEnabled: true,
ApiBaseUrl: "",
WebappEnabled: false,
WebappBaseUrl: "/",
WebappBaseDir: "webapp/public",
WebappList: "admin,auth,messaging,compose",
}
fill(o)
if o.WebappEnabled && o.ApiEnabled && o.ApiBaseUrl == "" {
// api base URL is still on root (empty string)
// but webapps are enabled (that means, server also serves static files from WebappBaseDir)
//
// Let's be nice and move API to /api
o.ApiBaseUrl = "/api"
}
return
}
-29
View File
@@ -1,29 +0,0 @@
package options
import (
"time"
)
type (
HTTPClientOpt struct {
ClientTSLInsecure bool `env:"HTTP_CLIENT_TSL_INSECURE"`
HttpClientTimeout time.Duration `env:"HTTP_CLIENT_TIMEOUT"`
}
)
func HttpClient(pfix string) (o *HTTPClientOpt) {
o = &HTTPClientOpt{
ClientTSLInsecure: false,
HttpClientTimeout: 30 * time.Second,
}
fill(o)
func(o interface{}) {
if def, ok := o.(interface{ Defaults() }); ok {
def.Defaults()
}
}(o)
return
}
-33
View File
@@ -1,33 +0,0 @@
package options
import (
"time"
"github.com/cortezaproject/corteza-server/pkg/rand"
)
type (
AuthOpt struct {
Secret string `env:"AUTH_JWT_SECRET"`
Expiry time.Duration `env:"AUTH_JWT_EXPIRY"`
}
)
func Auth() (o *AuthOpt) {
o = &AuthOpt{
Expiry: time.Hour * 24 * 30,
}
fill(o)
// Setting JWT secret to random string to prevent security accidents...
//
// @todo check if this is a monolith system
// on microservice setup we can not afford to autogenerate secret:
// each subsystem will get it's own
if o.Secret == "" {
o.Secret = string(rand.Bytes(32))
}
return
}
+39
View File
@@ -0,0 +1,39 @@
package options
// This file is auto-generated.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
// Definitions file that controls how this file is generated:
// pkg/options/monitor.yaml
import (
"time"
)
type (
MonitorOpt struct {
Interval time.Duration `env:"MONITOR_INTERVAL"`
}
)
// Monitor initializes and returns a MonitorOpt with default values
func Monitor() (o *MonitorOpt) {
o = &MonitorOpt{
Interval: 300 * time.Second,
}
fill(o)
// Function that allows access to custom logic inside the parent function.
// The custom logic in the other file should be like:
// func (o *Monitor) Defaults() {...}
func(o interface{}) {
if def, ok := o.(interface{ Defaults() }); ok {
def.Defaults()
}
}(o)
return
}
-20
View File
@@ -1,20 +0,0 @@
package options
import (
"time"
)
type (
MonitorOpt struct {
Interval time.Duration `env:"MONITOR_INTERVAL"`
}
)
func Monitor(pfix string) (o *MonitorOpt) {
o = &MonitorOpt{
Interval: 300 * time.Second,
}
fill(o)
return
}
+10
View File
@@ -0,0 +1,10 @@
name: monitor
imports:
- time
props:
- name: interval
type: time.Duration
default: 300 * time.Second
+44
View File
@@ -0,0 +1,44 @@
package options
// This file is auto-generated.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
// Definitions file that controls how this file is generated:
// pkg/options/objectStore.yaml
type (
ObjectStoreOpt struct {
Path string `env:"STORAGE_PATH"`
MinioEndpoint string `env:"MINIO_ENDPOINT"`
MinioSecure bool `env:"MINIO_SECURE"`
MinioAccessKey string `env:"MINIO_ACCESS_KEY"`
MinioSecretKey string `env:"MINIO_SECRET_KEY"`
MinioSSECKey string `env:"MINIO_SSEC_KEY"`
MinioBucket string `env:"MINIO_BUCKET"`
MinioStrict bool `env:"MINIO_STRICT"`
}
)
// ObjectStore initializes and returns a ObjectStoreOpt with default values
func ObjectStore() (o *ObjectStoreOpt) {
o = &ObjectStoreOpt{
Path: "var/store",
MinioSecure: true,
MinioStrict: false,
}
fill(o)
// Function that allows access to custom logic inside the parent function.
// The custom logic in the other file should be like:
// func (o *ObjectStore) Defaults() {...}
func(o interface{}) {
if def, ok := o.(interface{ Defaults() }); ok {
def.Defaults()
}
}(o)
return
}
+32
View File
@@ -0,0 +1,32 @@
name: objectStore
props:
- name: path
env: STORAGE_PATH
default: "var/store"
- name: minioEndpoint
env: MINIO_ENDPOINT
- name: minioSecure
type: bool
env: MINIO_SECURE
default: true
- name: minioAccessKey
env: MINIO_ACCESS_KEY
- name: minioSecretKey
env: MINIO_SECRET_KEY
- name: minioSSECKey
env: MINIO_SSEC_KEY
- name: minioBucket
env: MINIO_BUCKET
- name: minioStrict
type: bool
env: MINIO_STRICT
default: false
+35
View File
@@ -0,0 +1,35 @@
package options
// This file is auto-generated.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
// Definitions file that controls how this file is generated:
// pkg/options/provision.yaml
type (
ProvisionOpt struct {
Always bool `env:"PROVISION_ALWAYS"`
}
)
// Provision initializes and returns a ProvisionOpt with default values
func Provision() (o *ProvisionOpt) {
o = &ProvisionOpt{
Always: true,
}
fill(o)
// Function that allows access to custom logic inside the parent function.
// The custom logic in the other file should be like:
// func (o *Provision) Defaults() {...}
func(o interface{}) {
if def, ok := o.(interface{ Defaults() }); ok {
def.Defaults()
}
}(o)
return
}
-17
View File
@@ -1,17 +0,0 @@
package options
type (
ProvisionOpt struct {
Always bool `env:"PROVISION_ALWAYS"`
}
)
func Provision(pfix string) (o *ProvisionOpt) {
o = &ProvisionOpt{
Always: true,
}
fill(o)
return
}
+7
View File
@@ -0,0 +1,7 @@
name: provision
props:
- name: always
type: bool
default: true
-41
View File
@@ -1,41 +0,0 @@
package options
import (
"time"
)
type (
PubSubOpt struct {
Mode string `env:"PUBSUB_MODE"`
// Mode
PollingInterval time.Duration `env:"PUBSUB_POLLING_INTERVAL"`
// Redis
RedisAddr string `env:"PUBSUB_REDIS_ADDR"`
RedisTimeout time.Duration `env:"PUBSUB_REDIS_TIMEOUT"`
RedisPingTimeout time.Duration `env:"PUBSUB_REDIS_PING_TIMEOUT"`
RedisPingPeriod time.Duration `env:"PUBSUB_REDIS_PING_PERIOD"`
}
)
func PubSub(pfix string) (o *PubSubOpt) {
const (
timeout = 15 * time.Second
pingTimeout = 120 * time.Second
pingPeriod = (pingTimeout * 9) / 10
)
o = &PubSubOpt{
Mode: "poll",
PollingInterval: timeout,
RedisAddr: "redis:6379",
RedisTimeout: timeout,
RedisPingTimeout: pingTimeout,
RedisPingPeriod: pingPeriod,
}
fill(o)
return
}
+49
View File
@@ -0,0 +1,49 @@
package options
// This file is auto-generated.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
// Definitions file that controls how this file is generated:
// pkg/options/sentry.yaml
import (
"github.com/cortezaproject/corteza-server/pkg/version"
)
type (
SentryOpt struct {
DSN string `env:"SENTRY_DSN"`
Debug bool `env:"SENTRY_DEBUG"`
AttachStacktrace bool `env:"SENTRY_ATTACH_STACKTRACE"`
SampleRate float32 `env:"SENTRY_SAMPLE_RATE"`
MaxBreadcrumbs int `env:"SENTRY_MAX_BREADCRUMBS"`
ServerName string `env:"SENTRY_SERVERNAME"`
Release string `env:"SENTRY_RELEASE"`
Dist string `env:"SENTRY_DIST"`
Environment string `env:"SENTRY_ENVIRONMENT"`
}
)
// Sentry initializes and returns a SentryOpt with default values
func Sentry() (o *SentryOpt) {
o = &SentryOpt{
AttachStacktrace: true,
MaxBreadcrumbs: 0,
Release: version.Version,
}
fill(o)
// Function that allows access to custom logic inside the parent function.
// The custom logic in the other file should be like:
// func (o *Sentry) Defaults() {...}
func(o interface{}) {
if def, ok := o.(interface{ Defaults() }); ok {
def.Defaults()
}
}(o)
return
}
-34
View File
@@ -1,34 +0,0 @@
package options
import (
"github.com/cortezaproject/corteza-server/pkg/version"
)
type (
SentryOpt struct {
DSN string `env:"SENTRY_DSN"`
Debug bool `env:"SENTRY_DEBUG"`
AttachStacktrace bool `env:"SENTRY_ATTACH_STACKTRACE"`
SampleRate float32 `env:"SENTRY_SAMPLE_RATE"`
MaxBreadcrumbs int `env:"SENTRY_MAX_BREADCRUMBS"`
ServerName string `env:"SENTRY_SERVERNAME"`
Release string `env:"SENTRY_RELEASE"`
Dist string `env:"SENTRY_DIST"`
Environment string `env:"SENTRY_ENVIRONMENT"`
}
)
func Sentry(pfix string) (o *SentryOpt) {
o = &SentryOpt{
AttachStacktrace: true,
MaxBreadcrumbs: 0,
Release: version.Version,
}
fill(o)
return
}
+32
View File
@@ -0,0 +1,32 @@
name: sentry
imports:
- github.com/cortezaproject/corteza-server/pkg/version
props:
- name: DSN
- name: debug
type: bool
- name: attachStacktrace
type: bool
default: true
- name: sampleRate
type: float32
- name: maxBreadcrumbs
type: int
default: 0
- name: serverName
env: SENTRY_SERVERNAME
- name: release
default: version.Version
- name: dist
- name: environment
-31
View File
@@ -1,31 +0,0 @@
package options
type (
SMTPOpt struct {
Host string `env:"SMTP_HOST"`
Port int `env:"SMTP_PORT"`
User string `env:"SMTP_USER"`
Pass string `env:"SMTP_PASS"`
From string `env:"SMTP_FROM"`
TlsInsecure bool `env:"SMTP_TSL_INSECURE"`
TlsServerName string `env:"SMTP_TSL_SERVER_NAME"`
}
)
func SMTP(pfix string) (o *SMTPOpt) {
o = &SMTPOpt{
Host: "localhost",
Port: 25,
User: "",
Pass: "",
From: "",
TlsInsecure: false,
TlsServerName: "",
}
fill(o)
return
}
-32
View File
@@ -1,32 +0,0 @@
package options
type (
ObjectStoreOpt struct {
Path string `env:"STORAGE_PATH"`
MinioEndpoint string `env:"MINIO_ENDPOINT"`
MinioSecure bool `env:"MINIO_SECURE"`
MinioAccessKey string `env:"MINIO_ACCESS_KEY"`
MinioSecretKey string `env:"MINIO_SECRET_KEY"`
MinioSSECKey string `env:"MINIO_SSEC_KEY"`
MinioBucket string `env:"MINIO_BUCKET"`
MinioStrict bool `env:"MINIO_STRICT"`
}
)
func ObjectStore(pfix string) (o *ObjectStoreOpt) {
o = &ObjectStoreOpt{
Path: "var/store",
// Make minio secure by default
MinioSecure: true,
// Run in struct mode:
// - do not create un-existing buckets
MinioStrict: false,
}
fill(o)
return
}
+37
View File
@@ -0,0 +1,37 @@
package options
// This file is auto-generated.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
// Definitions file that controls how this file is generated:
// pkg/options/upgrade.yaml
type (
UpgradeOpt struct {
Debug bool `env:"UPGRADE_DEBUG"`
Always bool `env:"UPGRADE_ALWAYS"`
}
)
// Upgrade initializes and returns a UpgradeOpt with default values
func Upgrade() (o *UpgradeOpt) {
o = &UpgradeOpt{
Debug: false,
Always: true,
}
fill(o)
// Function that allows access to custom logic inside the parent function.
// The custom logic in the other file should be like:
// func (o *Upgrade) Defaults() {...}
func(o interface{}) {
if def, ok := o.(interface{ Defaults() }); ok {
def.Defaults()
}
}(o)
return
}
-19
View File
@@ -1,19 +0,0 @@
package options
type (
UpgradeOpt struct {
Debug bool `env:"UPGRADE_DEBUG"`
Always bool `env:"UPGRADE_ALWAYS"`
}
)
func Upgrade(pfix string) (o *UpgradeOpt) {
o = &UpgradeOpt{
Debug: false,
Always: true,
}
fill(o)
return
}
+11
View File
@@ -0,0 +1,11 @@
name: upgrade
props:
- name: Debug
type: bool
default: false
- name: Always
type: bool
default: true
@@ -1,7 +1,14 @@
package options
// This file is auto-generated.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
// Definitions file that controls how this file is generated:
// pkg/options/waitFor.yaml
import (
"strings"
"time"
)
@@ -16,11 +23,11 @@ type (
}
)
func WaitFor(pfix string) (o *WaitForOpt) {
// WaitFor initializes and returns a WaitForOpt with default values
func WaitFor() (o *WaitForOpt) {
o = &WaitForOpt{
Delay: 0,
StatusPage: true,
Services: "",
ServicesTimeout: time.Minute,
ServicesProbeTimeout: time.Second * 30,
ServicesProbeInterval: time.Second * 5,
@@ -28,14 +35,14 @@ func WaitFor(pfix string) (o *WaitForOpt) {
fill(o)
// Function that allows access to custom logic inside the parent function.
// The custom logic in the other file should be like:
// func (o *WaitFor) Defaults() {...}
func(o interface{}) {
if def, ok := o.(interface{ Defaults() }); ok {
def.Defaults()
}
}(o)
return
}
// Parses hosts and return slice of strings, one per host
func (o WaitForOpt) GetServices() []string {
if len(o.Services) == 0 {
return []string{}
}
return strings.Split(o.Services, " ")
}
+14
View File
@@ -0,0 +1,14 @@
package options
import (
"strings"
)
// Parses hosts and return slice of strings, one per host
func (o WaitForOpt) GetServices() []string {
if len(o.Services) == 0 {
return []string{}
}
return strings.Split(o.Services, " ")
}
+34
View File
@@ -0,0 +1,34 @@
name: waitFor
imports:
- time
props:
- name: Delay
type: time.Duration
env: WAIT_FOR
default: 0
- name: StatusPage
type: bool
env: WAIT_FOR_STATUS_PAGE
default: true
- name: Services
env: WAIT_FOR_SERVICES
- name: ServicesTimeout
type: time.Duration
env: WAIT_FOR_SERVICES_TIMEOUT
default: time.Minute
- name: ServicesProbeTimeout
type: time.Duration
env: WAIT_FOR_SERVICES_PROBE_TIMEOUT
default: time.Second * 30
- name: ServicesProbeInterval
type: time.Duration
env: WAIT_FOR_SERVICES_PROBE_INTERVAL
default: time.Second * 5
+43
View File
@@ -0,0 +1,43 @@
package options
// This file is auto-generated.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
// Definitions file that controls how this file is generated:
// pkg/options/websocket.yaml
import (
"time"
)
type (
WebsocketOpt struct {
Timeout time.Duration `env:"WEBSOCKET_TIMEOUT"`
PingTimeout time.Duration `env:"WEBSOCKET_PING_TIMEOUT"`
PingPeriod time.Duration `env:"WEBSOCKET_PING_PERIOD"`
}
)
// Websocket initializes and returns a WebsocketOpt with default values
func Websocket() (o *WebsocketOpt) {
o = &WebsocketOpt{
Timeout: 15 * time.Second,
PingTimeout: 120 * time.Second,
PingPeriod: ((120 * time.Second) * 9) / 10,
}
fill(o)
// Function that allows access to custom logic inside the parent function.
// The custom logic in the other file should be like:
// func (o *Websocket) Defaults() {...}
func(o interface{}) {
if def, ok := o.(interface{ Defaults() }); ok {
def.Defaults()
}
}(o)
return
}
-31
View File
@@ -1,31 +0,0 @@
package options
import (
"time"
)
type (
WebsocketOpt struct {
Timeout time.Duration `env:"WEBSOCKET_TIMEOUT"`
PingTimeout time.Duration `env:"WEBSOCKET_PING_TIMEOUT"`
PingPeriod time.Duration `env:"WEBSOCKET_PING_PERIOD"`
}
)
func Websocket(pfix string) (o *WebsocketOpt) {
const (
timeout = 15 * time.Second
pingTimeout = 120 * time.Second
pingPeriod = (pingTimeout * 9) / 10
)
o = &WebsocketOpt{
Timeout: timeout,
PingTimeout: pingTimeout,
PingPeriod: pingPeriod,
}
fill(o)
return
}
+18
View File
@@ -0,0 +1,18 @@
name: websocket
imports:
- time
props:
- name: Timeout
type: time.Duration
default: 15 * time.Second
- name: PingTimeout
type: time.Duration
default: 120 * time.Second
- name: PingPeriod
type: time.Duration
default: ((120 * time.Second) * 9) / 10
+10
View File
@@ -1,6 +1,8 @@
# cloud.google.com/go v0.44.3
## explicit
cloud.google.com/go/compute/metadata
# github.com/0xAX/notificator v0.0.0-20191016112426-3962a5ea8da1
## explicit
# github.com/360EntSecGroup-Skylar/excelize/v2 v2.0.2
## explicit
github.com/360EntSecGroup-Skylar/excelize/v2
@@ -34,6 +36,10 @@ github.com/SentimensRG/ctx
github.com/SentimensRG/ctx/sigctx
# github.com/beorn7/perks v1.0.0
github.com/beorn7/perks/quantile
# github.com/codegangsta/envy v0.0.0-20141216192214-4b78388c8ce4
## explicit
# github.com/codegangsta/gin v0.0.0-20171026143024-cafe2ce98974
## explicit
# github.com/crusttech/go-oidc v0.0.0-20180918092017-982855dad3e1
## explicit
github.com/crusttech/go-oidc
@@ -147,6 +153,8 @@ github.com/markbates/goth/providers/github
github.com/markbates/goth/providers/google
github.com/markbates/goth/providers/linkedin
github.com/markbates/goth/providers/openidConnect
# github.com/mattn/go-shellwords v1.0.10
## explicit
# github.com/mattn/go-sqlite3 v1.14.0
## explicit
github.com/mattn/go-sqlite3
@@ -389,6 +397,8 @@ gopkg.in/mail.v2
gopkg.in/square/go-jose.v2
gopkg.in/square/go-jose.v2/cipher
gopkg.in/square/go-jose.v2/json
# gopkg.in/urfave/cli.v1 v1.20.0
## explicit
# gopkg.in/yaml.v2 v2.3.0
## explicit
gopkg.in/yaml.v2