internal/config/template: Cleanup
This commit cleans up the internal/config/template to remove code no longer used because of the new configuration.
This commit is contained in:
parent
aa3580c248
commit
2edd0f2fe2
7 changed files with 66 additions and 69 deletions
|
|
@ -100,7 +100,7 @@ func (bs cBootstrap) Run(context wisski_distillery.Context) error {
|
||||||
|
|
||||||
// setup a new template for the configuration file!
|
// setup a new template for the configuration file!
|
||||||
var tpl config.Template
|
var tpl config.Template
|
||||||
tpl.DeployRoot = bs.Directory
|
tpl.RootPath = bs.Directory
|
||||||
tpl.DefaultDomain = bs.Hostname
|
tpl.DefaultDomain = bs.Hostname
|
||||||
|
|
||||||
// and use thge defaults
|
// and use thge defaults
|
||||||
|
|
@ -129,7 +129,7 @@ func (bs cBootstrap) Run(context wisski_distillery.Context) error {
|
||||||
|
|
||||||
// write out all the extra config files
|
// write out all the extra config files
|
||||||
if err := logging.LogOperation(func() error {
|
if err := logging.LogOperation(func() error {
|
||||||
context.Println(tpl.SelfOverridesFile)
|
context.Println(cfg.Paths.OverridesJSON)
|
||||||
if err := environment.WriteFile(
|
if err := environment.WriteFile(
|
||||||
env,
|
env,
|
||||||
cfg.Paths.OverridesJSON,
|
cfg.Paths.OverridesJSON,
|
||||||
|
|
@ -139,7 +139,7 @@ func (bs cBootstrap) Run(context wisski_distillery.Context) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
context.Println(tpl.SelfResolverBlockFile)
|
context.Println(cfg.Paths.ResolverBlocks)
|
||||||
if err := environment.WriteFile(
|
if err := environment.WriteFile(
|
||||||
env,
|
env,
|
||||||
cfg.Paths.ResolverBlocks,
|
cfg.Paths.ResolverBlocks,
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ type Config struct {
|
||||||
PublicSSHPort uint16 `yaml:"ssh_port" default:"2222" validate:"port"`
|
PublicSSHPort uint16 `yaml:"ssh_port" default:"2222" validate:"port"`
|
||||||
|
|
||||||
// session secret holds the secret for login
|
// session secret holds the secret for login
|
||||||
SessionSecret string `yaml:"session_secret" default:"" validate:"nonempty"`
|
SessionSecret string `yaml:"session_secret" validate:"nonempty"`
|
||||||
|
|
||||||
// interval to trigger distillery cron tasks in
|
// interval to trigger distillery cron tasks in
|
||||||
CronInterval time.Duration `yaml:"cron_interval" default:"10m" validate:"duration"`
|
CronInterval time.Duration `yaml:"cron_interval" default:"10m" validate:"duration"`
|
||||||
|
|
|
||||||
|
|
@ -2,24 +2,24 @@ paths:
|
||||||
# A WissKI Distillery needs to store a lot of data on disk.
|
# A WissKI Distillery needs to store a lot of data on disk.
|
||||||
# This setting defines a root folder all of these will be placed in.
|
# This setting defines a root folder all of these will be placed in.
|
||||||
# On top of this all real-system space will be created under this directory
|
# On top of this all real-system space will be created under this directory
|
||||||
root: ""
|
root: null
|
||||||
|
|
||||||
# Individual paths on the root domain can be overwritten.
|
# Individual paths on the root domain can be overwritten.
|
||||||
# This can be achieved by adding URLs (without trailing '/'s) into a JSON file.
|
# This can be achieved by adding URLs (without trailing '/'s) into a JSON file.
|
||||||
# This setting defines the path to that file.
|
# This setting defines the path to that file.
|
||||||
overrides: ""
|
overrides: null
|
||||||
|
|
||||||
# You can block specific prefixes within Triplestore from showing up in the global resolver.
|
# You can block specific prefixes within Triplestore from showing up in the global resolver.
|
||||||
# Do this by adding one prefix per line in this file.
|
# Do this by adding one prefix per line in this file.
|
||||||
# Lines starting with '#' and blank lines are ignored.
|
# Lines starting with '#' and blank lines are ignored.
|
||||||
# This setting defines the path to that file.
|
# This setting defines the path to that file.
|
||||||
blocks: ""
|
blocks: null
|
||||||
|
|
||||||
http:
|
http:
|
||||||
# Each created Drupal Instance corresponds to a single domain name.
|
# Each created Drupal Instance corresponds to a single domain name.
|
||||||
# These domain names should either be a complete domain name or a sub-domain of a default domain.
|
# These domain names should either be a complete domain name or a sub-domain of a default domain.
|
||||||
# This setting configures the default domain-name to create subdomains of.
|
# This setting configures the default domain-name to create subdomains of.
|
||||||
domain: ${DEFAULT_DOMAIN}
|
domain: null
|
||||||
|
|
||||||
# By default, only the 'domain' domain above is caught.
|
# By default, only the 'domain' domain above is caught.
|
||||||
# To catch additional domains, add them here
|
# To catch additional domains, add them here
|
||||||
|
|
@ -28,59 +28,59 @@ http:
|
||||||
# The system can support setting up certificate(s) automatically.
|
# The system can support setting up certificate(s) automatically.
|
||||||
# It can be enabled by setting an email for certbot certificates.
|
# It can be enabled by setting an email for certbot certificates.
|
||||||
# This email address can be configured here.
|
# This email address can be configured here.
|
||||||
certbot_email: ""
|
certbot_email: null
|
||||||
|
|
||||||
# By default, the default domain redirects to the distillery repository.
|
# By default, the default domain redirects to the distillery repository.
|
||||||
# If you want to change this, set an alternate domain name here.
|
# If you want to change this, set an alternate domain name here.
|
||||||
theme:
|
theme:
|
||||||
home: ""
|
home: null
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
# The name of the (global) docker network to run the distillery services in.
|
# The name of the (global) docker network to run the distillery services in.
|
||||||
network: ${DOCKER_NETWORK_NAME}
|
network: null
|
||||||
|
|
||||||
# Configuration of the sql backend
|
# Configuration of the sql backend
|
||||||
sql:
|
sql:
|
||||||
# username and password for the sql administrative user.
|
# username and password for the sql administrative user.
|
||||||
# this user is automatically created.
|
# this user is automatically created.
|
||||||
username: ${MYSQL_ADMIN_USER}
|
username: null
|
||||||
password: ${MYSQL_ADMIN_PASSWORD}
|
password: null
|
||||||
|
|
||||||
# prefixes for the data and users to be created and managed
|
# prefixes for the data and users to be created and managed
|
||||||
# one of these is created per WissKI instance.
|
# one of these is created per WissKI instance.
|
||||||
user_prefix: "mysql-factory-"
|
user_prefix: null
|
||||||
data_prefix: "mysql-factory-"
|
data_prefix: null
|
||||||
|
|
||||||
# database used for internal configuration
|
# database used for internal configuration
|
||||||
database: "distillery"
|
database: null
|
||||||
|
|
||||||
# configuration of the triplestore backend
|
# configuration of the triplestore backend
|
||||||
triplestore:
|
triplestore:
|
||||||
# admin user and password of the graphdb interface
|
# admin user and password of the graphdb interface
|
||||||
# this will be created automatically.
|
# this will be created automatically.
|
||||||
username: ${GRAPHDB_ADMIN_USER}
|
username: null
|
||||||
password: ${GRAPHDB_ADMIN_PASSWORD}
|
password: null
|
||||||
|
|
||||||
# prefixes for the users and repositories to be created
|
# prefixes for the users and repositories to be created
|
||||||
user_prefix: "graphdb-factory-"
|
user_prefix: null
|
||||||
data_prefix: "graphdb-factory-"
|
data_prefix: null
|
||||||
|
|
||||||
# The maximum agefor backups to be kept.
|
# The maximum agefor backups to be kept.
|
||||||
# Backups older than this will be removed when a new backup is made.
|
# Backups older than this will be removed when a new backup is made.
|
||||||
# The default here is 720hours (== 30 days)
|
# The default here is 720hours (== 30 days)
|
||||||
age: '720h'
|
age: null
|
||||||
|
|
||||||
|
|
||||||
# Various components use password-based-authentication.
|
# Various components use password-based-authentication.
|
||||||
# These passwords are generated automatically.
|
# These passwords are generated automatically.
|
||||||
# This variable can be used to determine their length.
|
# This variable can be used to determine their length.
|
||||||
password_length: 64
|
password_length: null
|
||||||
|
|
||||||
# the port to use for the ssh server
|
# the port to use for the ssh server
|
||||||
ssh_port: 2222
|
ssh_port: null
|
||||||
|
|
||||||
# The secret for sessions (for login etc)
|
# The secret for sessions (for login etc)
|
||||||
session_secret: ${SESSION_SECRET}
|
session_secret: null
|
||||||
|
|
||||||
# the interval to run cron in
|
# the interval to run cron in
|
||||||
cron_interval: "10m"
|
cron_interval: null
|
||||||
|
|
@ -9,5 +9,5 @@ import (
|
||||||
|
|
||||||
// NewPassword returns a new password using the password settings from this configuration
|
// NewPassword returns a new password using the password settings from this configuration
|
||||||
func (cfg Config) NewPassword() (string, error) {
|
func (cfg Config) NewPassword() (string, error) {
|
||||||
return password.Generate(rand.Reader, cfg.PasswordLength, passwordx.Charset)
|
return password.Generate(rand.Reader, cfg.PasswordLength, passwordx.Safe)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,62 +12,55 @@ import (
|
||||||
"github.com/tkw1536/pkglib/password"
|
"github.com/tkw1536/pkglib/password"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Template is a template for the configuration file
|
// Template is used to generate a configuration file.
|
||||||
type Template struct {
|
type Template struct {
|
||||||
DeployRoot string `env:"DEPLOY_ROOT"`
|
RootPath string
|
||||||
DefaultDomain string `env:"DEFAULT_DOMAIN"`
|
DefaultDomain string
|
||||||
SelfOverridesFile string `env:"SELF_OVERRIDES_FILE"`
|
|
||||||
SelfResolverBlockFile string `env:"SELF_RESOLVER_BLOCK_FILE"`
|
TSAdminUser string
|
||||||
TriplestoreAdminUser string `env:"GRAPHDB_ADMIN_USER"`
|
TSAdminPassword string
|
||||||
TriplestoreAdminPassword string `env:"GRAPHDB_ADMIN_PASSWORD"`
|
|
||||||
MysqlAdminUsername string `env:"MYSQL_ADMIN_USER"`
|
SQLAdminUsername string
|
||||||
MysqlAdminPassword string `env:"MYSQL_ADMIN_PASSWORD"`
|
SQLAdminPassword string
|
||||||
DockerNetworkName string `env:"DOCKER_NETWORK_NAME"`
|
|
||||||
SessionSecret string `env:"SESSION_SECRET"`
|
DockerNetworkName string
|
||||||
|
SessionSecret string
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetDefaults sets defaults on the template
|
// SetDefaults sets defaults on the template
|
||||||
func (tpl *Template) SetDefaults(env environment.Environment) (err error) {
|
func (tpl *Template) SetDefaults(env environment.Environment) (err error) {
|
||||||
if tpl.DeployRoot == "" {
|
if tpl.RootPath == "" {
|
||||||
tpl.DeployRoot = bootstrap.BaseDirectoryDefault
|
tpl.RootPath = bootstrap.BaseDirectoryDefault
|
||||||
}
|
}
|
||||||
|
|
||||||
if tpl.DefaultDomain == "" {
|
if tpl.DefaultDomain == "" {
|
||||||
tpl.DefaultDomain = hostname.FQDN() // TODO: Make this environment specific
|
tpl.DefaultDomain = hostname.FQDN() // TODO: Make this environment specific
|
||||||
}
|
}
|
||||||
|
|
||||||
if tpl.SelfOverridesFile == "" {
|
if tpl.TSAdminUser == "" {
|
||||||
tpl.SelfOverridesFile = filepath.Join(tpl.DeployRoot, bootstrap.OverridesJSON)
|
tpl.TSAdminUser = "admin"
|
||||||
}
|
}
|
||||||
|
|
||||||
if tpl.SelfResolverBlockFile == "" {
|
if tpl.TSAdminPassword == "" {
|
||||||
tpl.SelfResolverBlockFile = filepath.Join(tpl.DeployRoot, bootstrap.ResolverBlockedTXT)
|
tpl.TSAdminPassword, err = password.Generate(rand.Reader, 64, passwordx.Safe)
|
||||||
}
|
|
||||||
|
|
||||||
if tpl.TriplestoreAdminUser == "" {
|
|
||||||
tpl.TriplestoreAdminUser = "admin"
|
|
||||||
}
|
|
||||||
|
|
||||||
if tpl.TriplestoreAdminPassword == "" {
|
|
||||||
tpl.TriplestoreAdminPassword, err = password.Generate(rand.Reader, 64, passwordx.Charset)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if tpl.MysqlAdminUsername == "" {
|
if tpl.SQLAdminUsername == "" {
|
||||||
tpl.MysqlAdminUsername = "admin"
|
tpl.SQLAdminUsername = "admin"
|
||||||
}
|
}
|
||||||
|
|
||||||
if tpl.MysqlAdminPassword == "" {
|
if tpl.SQLAdminPassword == "" {
|
||||||
tpl.MysqlAdminPassword, err = password.Generate(rand.Reader, 64, passwordx.Charset)
|
tpl.SQLAdminPassword, err = password.Generate(rand.Reader, 64, passwordx.Safe)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if tpl.DockerNetworkName == "" {
|
if tpl.DockerNetworkName == "" {
|
||||||
tpl.DockerNetworkName, err = password.Generate(rand.Reader, 10, passwordx.Charset)
|
tpl.DockerNetworkName, err = password.Generate(rand.Reader, 10, passwordx.Identifier)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -75,7 +68,7 @@ func (tpl *Template) SetDefaults(env environment.Environment) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if tpl.SessionSecret == "" {
|
if tpl.SessionSecret == "" {
|
||||||
tpl.SessionSecret, err = password.Generate(rand.Reader, 100, passwordx.Charset)
|
tpl.SessionSecret, err = password.Generate(rand.Reader, 100, passwordx.Printable)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -88,9 +81,9 @@ func (tpl *Template) SetDefaults(env environment.Environment) (err error) {
|
||||||
func (tpl Template) Generate() Config {
|
func (tpl Template) Generate() Config {
|
||||||
return Config{
|
return Config{
|
||||||
Paths: PathsConfig{
|
Paths: PathsConfig{
|
||||||
Root: tpl.DeployRoot,
|
Root: tpl.RootPath,
|
||||||
OverridesJSON: tpl.SelfOverridesFile,
|
OverridesJSON: filepath.Join(tpl.RootPath, bootstrap.OverridesJSON),
|
||||||
ResolverBlocks: tpl.SelfResolverBlockFile,
|
ResolverBlocks: filepath.Join(tpl.RootPath, bootstrap.ResolverBlockedTXT),
|
||||||
},
|
},
|
||||||
HTTP: HTTPConfig{
|
HTTP: HTTPConfig{
|
||||||
PrimaryDomain: tpl.DefaultDomain,
|
PrimaryDomain: tpl.DefaultDomain,
|
||||||
|
|
@ -101,8 +94,8 @@ func (tpl Template) Generate() Config {
|
||||||
},
|
},
|
||||||
SQL: SQLConfig{
|
SQL: SQLConfig{
|
||||||
DatabaseConfig: DatabaseConfig{
|
DatabaseConfig: DatabaseConfig{
|
||||||
AdminUsername: tpl.MysqlAdminUsername,
|
AdminUsername: tpl.SQLAdminUsername,
|
||||||
AdminPassword: tpl.MysqlAdminPassword,
|
AdminPassword: tpl.SQLAdminPassword,
|
||||||
|
|
||||||
UserPrefix: "mysql-factory-",
|
UserPrefix: "mysql-factory-",
|
||||||
DataPrefix: "mysql-factory-",
|
DataPrefix: "mysql-factory-",
|
||||||
|
|
@ -112,8 +105,8 @@ func (tpl Template) Generate() Config {
|
||||||
},
|
},
|
||||||
TS: TSConfig{
|
TS: TSConfig{
|
||||||
DatabaseConfig: DatabaseConfig{
|
DatabaseConfig: DatabaseConfig{
|
||||||
AdminUsername: tpl.TriplestoreAdminUser,
|
AdminUsername: tpl.TSAdminUser,
|
||||||
AdminPassword: tpl.TriplestoreAdminPassword,
|
AdminPassword: tpl.TSAdminPassword,
|
||||||
|
|
||||||
UserPrefix: "graphdb-factory-",
|
UserPrefix: "graphdb-factory-",
|
||||||
DataPrefix: "graphdb-factory-",
|
DataPrefix: "graphdb-factory-",
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ func (dis *Exporter) NewArchivePath(prefix string) (path string) {
|
||||||
// newSnapshot name returns a new basename for a snapshot with the provided prefix.
|
// newSnapshot name returns a new basename for a snapshot with the provided prefix.
|
||||||
// The name is guaranteed to be unique within this process.
|
// The name is guaranteed to be unique within this process.
|
||||||
func (*Exporter) newSnapshotName(prefix string) string {
|
func (*Exporter) newSnapshotName(prefix string) string {
|
||||||
suffix, _ := password.Generate(rand.Reader, 10, passwordx.Snapshot) // silently ignore any errors!
|
suffix, _ := password.Generate(rand.Reader, 10, passwordx.Identifier) // silently ignore any errors!
|
||||||
if prefix == "" {
|
if prefix == "" {
|
||||||
prefix = "backup"
|
prefix = "backup"
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,12 @@ package passwordx
|
||||||
|
|
||||||
import "github.com/tkw1536/pkglib/password"
|
import "github.com/tkw1536/pkglib/password"
|
||||||
|
|
||||||
// Charset is a Charset safe for usage within the distillery
|
// Safe is a charset used for generating passwords that can be safely passed without having to be escaped.
|
||||||
const Charset = password.DefaultCharSet
|
const Safe = password.DefaultCharSet
|
||||||
|
|
||||||
// Snapshot is a charset to be used to generate snapshot ids
|
// Printable is a charset that contains all printable ascii characters
|
||||||
const Snapshot = password.DefaultCharSet
|
const Printable = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
|
||||||
|
|
||||||
|
// Identifier is a charset to be used to generate unique identifiers.
|
||||||
|
// These are typically used for snapshots and names.
|
||||||
|
const Identifier = password.DefaultCharSet
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue