Fix whitespace
This runs `go fmt` on changed files and moves around some blank lines.
This commit is contained in:
parent
6506709fbc
commit
a740c67495
|
@ -28,9 +28,9 @@ func main() {
|
||||||
// Setup actions
|
// Setup actions
|
||||||
createConfig := flag.Bool("create-config", false, "Creates a basic configuration and exits")
|
createConfig := flag.Bool("create-config", false, "Creates a basic configuration and exits")
|
||||||
doConfig := flag.Bool("config", false, "Run the configuration process")
|
doConfig := flag.Bool("config", false, "Run the configuration process")
|
||||||
configSections := flag.String("sections", "server db app", "Which sections of the configuration to go through (requires --config), " +
|
configSections := flag.String("sections", "server db app", "Which sections of the configuration to go through (requires --config), "+
|
||||||
"valid values are any combination of 'server', 'db' and 'app' " +
|
"valid values are any combination of 'server', 'db' and 'app' "+
|
||||||
"example: writefreely --config --sections \"db app\"")
|
"example: writefreely --config --sections \"db app\"")
|
||||||
genKeys := flag.Bool("gen-keys", false, "Generate encryption and authentication keys")
|
genKeys := flag.Bool("gen-keys", false, "Generate encryption and authentication keys")
|
||||||
createSchema := flag.Bool("init-db", false, "Initialize app database")
|
createSchema := flag.Bool("init-db", false, "Initialize app database")
|
||||||
migrate := flag.Bool("migrate", false, "Migrate the database")
|
migrate := flag.Bool("migrate", false, "Migrate the database")
|
||||||
|
|
|
@ -76,12 +76,11 @@ func Configure(fname string, configSections string) (*SetupData, error) {
|
||||||
data.Config.Server.Dev = isDevEnv
|
data.Config.Server.Dev = isDevEnv
|
||||||
|
|
||||||
var prompt promptui.Prompt
|
var prompt promptui.Prompt
|
||||||
|
|
||||||
if strings.Contains(configSections, "server"){
|
|
||||||
|
|
||||||
|
if strings.Contains(configSections, "server") {
|
||||||
title(" Server setup ")
|
title(" Server setup ")
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
||||||
if isDevEnv || !isStandalone {
|
if isDevEnv || !isStandalone {
|
||||||
// Running in dev environment or behind reverse proxy; ask for port
|
// Running in dev environment or behind reverse proxy; ask for port
|
||||||
prompt = promptui.Prompt{
|
prompt = promptui.Prompt{
|
||||||
|
@ -96,7 +95,7 @@ func Configure(fname string, configSections string) (*SetupData, error) {
|
||||||
}
|
}
|
||||||
data.Config.Server.Port, _ = strconv.Atoi(port) // Ignore error, as we've already validated number
|
data.Config.Server.Port, _ = strconv.Atoi(port) // Ignore error, as we've already validated number
|
||||||
}
|
}
|
||||||
|
|
||||||
if isStandalone {
|
if isStandalone {
|
||||||
selPrompt = promptui.Select{
|
selPrompt = promptui.Select{
|
||||||
Templates: selTmpls,
|
Templates: selTmpls,
|
||||||
|
@ -113,7 +112,7 @@ func Configure(fname string, configSections string) (*SetupData, error) {
|
||||||
data.Config.Server.TLSKeyPath = ""
|
data.Config.Server.TLSKeyPath = ""
|
||||||
} else if sel == 1 {
|
} else if sel == 1 {
|
||||||
data.Config.Server.Port = 443
|
data.Config.Server.Port = 443
|
||||||
|
|
||||||
prompt = promptui.Prompt{
|
prompt = promptui.Prompt{
|
||||||
Templates: tmpls,
|
Templates: tmpls,
|
||||||
Label: "Certificate path",
|
Label: "Certificate path",
|
||||||
|
@ -124,7 +123,7 @@ func Configure(fname string, configSections string) (*SetupData, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return data, err
|
return data, err
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt = promptui.Prompt{
|
prompt = promptui.Prompt{
|
||||||
Templates: tmpls,
|
Templates: tmpls,
|
||||||
Label: "Key path",
|
Label: "Key path",
|
||||||
|
@ -140,13 +139,14 @@ func Configure(fname string, configSections string) (*SetupData, error) {
|
||||||
data.Config.Server.TLSCertPath = ""
|
data.Config.Server.TLSCertPath = ""
|
||||||
data.Config.Server.TLSKeyPath = ""
|
data.Config.Server.TLSKeyPath = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
}
|
}
|
||||||
if strings.Contains(configSections, "db"){
|
|
||||||
|
if strings.Contains(configSections, "db") {
|
||||||
title(" Database setup ")
|
title(" Database setup ")
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
||||||
selPrompt = promptui.Select{
|
selPrompt = promptui.Select{
|
||||||
Templates: selTmpls,
|
Templates: selTmpls,
|
||||||
Label: "Database driver",
|
Label: "Database driver",
|
||||||
|
@ -156,11 +156,11 @@ func Configure(fname string, configSections string) (*SetupData, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return data, err
|
return data, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if sel == 0 {
|
if sel == 0 {
|
||||||
// Configure for MySQL
|
// Configure for MySQL
|
||||||
data.Config.UseMySQL(isNewCfg)
|
data.Config.UseMySQL(isNewCfg)
|
||||||
|
|
||||||
prompt = promptui.Prompt{
|
prompt = promptui.Prompt{
|
||||||
Templates: tmpls,
|
Templates: tmpls,
|
||||||
Label: "Username",
|
Label: "Username",
|
||||||
|
@ -171,7 +171,7 @@ func Configure(fname string, configSections string) (*SetupData, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return data, err
|
return data, err
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt = promptui.Prompt{
|
prompt = promptui.Prompt{
|
||||||
Templates: tmpls,
|
Templates: tmpls,
|
||||||
Label: "Password",
|
Label: "Password",
|
||||||
|
@ -183,7 +183,7 @@ func Configure(fname string, configSections string) (*SetupData, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return data, err
|
return data, err
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt = promptui.Prompt{
|
prompt = promptui.Prompt{
|
||||||
Templates: tmpls,
|
Templates: tmpls,
|
||||||
Label: "Database name",
|
Label: "Database name",
|
||||||
|
@ -194,7 +194,7 @@ func Configure(fname string, configSections string) (*SetupData, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return data, err
|
return data, err
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt = promptui.Prompt{
|
prompt = promptui.Prompt{
|
||||||
Templates: tmpls,
|
Templates: tmpls,
|
||||||
Label: "Host",
|
Label: "Host",
|
||||||
|
@ -205,7 +205,7 @@ func Configure(fname string, configSections string) (*SetupData, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return data, err
|
return data, err
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt = promptui.Prompt{
|
prompt = promptui.Prompt{
|
||||||
Templates: tmpls,
|
Templates: tmpls,
|
||||||
Label: "Port",
|
Label: "Port",
|
||||||
|
@ -220,7 +220,7 @@ func Configure(fname string, configSections string) (*SetupData, error) {
|
||||||
} else if sel == 1 {
|
} else if sel == 1 {
|
||||||
// Configure for SQLite
|
// Configure for SQLite
|
||||||
data.Config.UseSQLite(isNewCfg)
|
data.Config.UseSQLite(isNewCfg)
|
||||||
|
|
||||||
prompt = promptui.Prompt{
|
prompt = promptui.Prompt{
|
||||||
Templates: tmpls,
|
Templates: tmpls,
|
||||||
Label: "Filename",
|
Label: "Filename",
|
||||||
|
@ -232,14 +232,14 @@ func Configure(fname string, configSections string) (*SetupData, error) {
|
||||||
return data, err
|
return data, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
}
|
}
|
||||||
if strings.Contains(configSections, "app"){
|
|
||||||
|
|
||||||
|
if strings.Contains(configSections, "app") {
|
||||||
title(" App setup ")
|
title(" App setup ")
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
|
|
||||||
selPrompt = promptui.Select{
|
selPrompt = promptui.Select{
|
||||||
Templates: selTmpls,
|
Templates: selTmpls,
|
||||||
Label: "Site type",
|
Label: "Site type",
|
||||||
|
@ -250,10 +250,10 @@ func Configure(fname string, configSections string) (*SetupData, error) {
|
||||||
return data, err
|
return data, err
|
||||||
}
|
}
|
||||||
data.Config.App.SingleUser = usersType == "Single user blog"
|
data.Config.App.SingleUser = usersType == "Single user blog"
|
||||||
|
|
||||||
if data.Config.App.SingleUser {
|
if data.Config.App.SingleUser {
|
||||||
data.User = &UserCreation{}
|
data.User = &UserCreation{}
|
||||||
|
|
||||||
// prompt for username
|
// prompt for username
|
||||||
prompt = promptui.Prompt{
|
prompt = promptui.Prompt{
|
||||||
Templates: tmpls,
|
Templates: tmpls,
|
||||||
|
@ -264,7 +264,7 @@ func Configure(fname string, configSections string) (*SetupData, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return data, err
|
return data, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// prompt for password
|
// prompt for password
|
||||||
prompt = promptui.Prompt{
|
prompt = promptui.Prompt{
|
||||||
Templates: tmpls,
|
Templates: tmpls,
|
||||||
|
@ -275,13 +275,13 @@ func Configure(fname string, configSections string) (*SetupData, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return data, err
|
return data, err
|
||||||
}
|
}
|
||||||
|
|
||||||
data.User.HashedPass, err = auth.HashPass([]byte(newUserPass))
|
data.User.HashedPass, err = auth.HashPass([]byte(newUserPass))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return data, err
|
return data, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
siteNameLabel := "Instance name"
|
siteNameLabel := "Instance name"
|
||||||
if data.Config.App.SingleUser {
|
if data.Config.App.SingleUser {
|
||||||
siteNameLabel = "Blog name"
|
siteNameLabel = "Blog name"
|
||||||
|
@ -296,7 +296,7 @@ func Configure(fname string, configSections string) (*SetupData, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return data, err
|
return data, err
|
||||||
}
|
}
|
||||||
|
|
||||||
prompt = promptui.Prompt{
|
prompt = promptui.Prompt{
|
||||||
Templates: tmpls,
|
Templates: tmpls,
|
||||||
Label: "Public URL",
|
Label: "Public URL",
|
||||||
|
@ -307,7 +307,7 @@ func Configure(fname string, configSections string) (*SetupData, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return data, err
|
return data, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if !data.Config.App.SingleUser {
|
if !data.Config.App.SingleUser {
|
||||||
selPrompt = promptui.Select{
|
selPrompt = promptui.Select{
|
||||||
Templates: selTmpls,
|
Templates: selTmpls,
|
||||||
|
@ -319,7 +319,7 @@ func Configure(fname string, configSections string) (*SetupData, error) {
|
||||||
return data, err
|
return data, err
|
||||||
}
|
}
|
||||||
data.Config.App.OpenRegistration = regType == "Open"
|
data.Config.App.OpenRegistration = regType == "Open"
|
||||||
|
|
||||||
prompt = promptui.Prompt{
|
prompt = promptui.Prompt{
|
||||||
Templates: tmpls,
|
Templates: tmpls,
|
||||||
Label: "Max blogs per user",
|
Label: "Max blogs per user",
|
||||||
|
@ -331,7 +331,7 @@ func Configure(fname string, configSections string) (*SetupData, error) {
|
||||||
}
|
}
|
||||||
data.Config.App.MaxBlogs, _ = strconv.Atoi(maxBlogs) // Ignore error, as we've already validated number
|
data.Config.App.MaxBlogs, _ = strconv.Atoi(maxBlogs) // Ignore error, as we've already validated number
|
||||||
}
|
}
|
||||||
|
|
||||||
selPrompt = promptui.Select{
|
selPrompt = promptui.Select{
|
||||||
Templates: selTmpls,
|
Templates: selTmpls,
|
||||||
Label: "Federation",
|
Label: "Federation",
|
||||||
|
@ -342,7 +342,7 @@ func Configure(fname string, configSections string) (*SetupData, error) {
|
||||||
return data, err
|
return data, err
|
||||||
}
|
}
|
||||||
data.Config.App.Federation = fedType == "Enabled"
|
data.Config.App.Federation = fedType == "Enabled"
|
||||||
|
|
||||||
if data.Config.App.Federation {
|
if data.Config.App.Federation {
|
||||||
selPrompt = promptui.Select{
|
selPrompt = promptui.Select{
|
||||||
Templates: selTmpls,
|
Templates: selTmpls,
|
||||||
|
@ -354,7 +354,7 @@ func Configure(fname string, configSections string) (*SetupData, error) {
|
||||||
return data, err
|
return data, err
|
||||||
}
|
}
|
||||||
data.Config.App.PublicStats = fedStatsType == "Public"
|
data.Config.App.PublicStats = fedStatsType == "Public"
|
||||||
|
|
||||||
selPrompt = promptui.Select{
|
selPrompt = promptui.Select{
|
||||||
Templates: selTmpls,
|
Templates: selTmpls,
|
||||||
Label: "Instance metadata privacy",
|
Label: "Instance metadata privacy",
|
||||||
|
|
Loading…
Reference in New Issue