Skip to content

Commit 05eb6bc

Browse files
authored
Refactor (#72)
* Minor updates, cleaning up dev branch * Updated embedded dojoConfig.yml to latest version * More clean-up for 2.0.x and start of work on supporting Debian install targets * Update for new embedded version * Workaround Python 3.8 bug that kinda broke 1.15.1 (and maybe other releases) * Bump version for 2 bugfixes * Bug fixes for 2 bugs impacting 1.15.x installs on 'iron' (#23) (#24) * Fix bug in installing PostgreSQL DB install process Remove use of legacy resolver for pip installs Ensure there's an admin email address provided, use default of not Ensure special characters in passwords are handled correctly when setting the intiial web admin password * Update version number to 1.1.7 * Merge master back into dev (#34) * Fix a couple of bugs (#32) * Fix bug in installing PostgreSQL DB install process * Remove use of legacy resolver for pip installs * Ensure there's an admin email address provided, use default if not * Ensure special characters in passwords are handled correctly when setting the initial web admin password * Bump version number to 1.1.7 (#33) * Update version number to 1.1.7 * Removed debugging messages * Fix typo in link to upgrade instructions * Added link to post-install and upgrade documentation * Update embedded files * Updated go modules (depenencies), removed go-bindata to use go:embed, added libcurl4-openssl-dev needed by pycurl * Remove bindata.go - no longer necessary * Fix multiple issues - download timeout, newer Ubuntu distros, etc * Initial commit of refactor * Part 1 of major refactor * Uncommented a line that shouldn't have been * Part 2 of major refactor - cleanup redundanct code * Completed majority of the refactor, added beta RHEL support * Refactor complete
1 parent b2c2325 commit 05eb6bc

78 files changed

Lines changed: 25733 additions & 3475 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 17 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
1-
package main
1+
package cmd
22

33
import (
44
"flag"
55
"fmt"
6-
"io/ioutil"
76
"os"
87
)
98

10-
type launchArgs struct {
11-
Dev bool
12-
Default bool
13-
Componse bool // TODO: Implement this
14-
K8s bool // TODO: Implement this
15-
}
16-
17-
func readArgs() launchArgs {
18-
//TODO TUrn me to a log writer fmt.Println("Called readArgs")
9+
// readArgs() takes no arguements and returns filled launchArgs struct unless
10+
// there are errors in the arguments or the argument provided calls for an
11+
// early exist such as --version or --help
12+
func readArgs(d *DDConfig) {
13+
d.traceMsg("Called readArgs")
1914
// Read in the supported command-line options
2015
var version, help, v, h bool
21-
opts := launchArgs{}
22-
flag.BoolVar(&opts.Default, "default", false, "Do an install based on default config values")
23-
flag.BoolVar(&opts.Dev, "dev", false, "Do a development install with known config values")
16+
flag.BoolVar(&d.defInstall, "default", false, "Do an install based on default config values")
2417
flag.BoolVar(&version, "version", false, "Print the version and exit")
2518
flag.BoolVar(&v, "v", false, "Print the version and exit")
2619
flag.BoolVar(&help, "help", false, "Print the help message and exit")
@@ -34,21 +27,13 @@ func readArgs() launchArgs {
3427
}
3528
// Print version
3629
if version || v {
37-
fmt.Printf("godojo version %s\n", ver)
30+
fmt.Printf("godojo version %s\n", d.ver)
3831
os.Exit(0)
3932
}
4033

41-
// Handle double options (dev and default currently)
42-
if opts.Dev && opts.Default {
43-
// Only 1 option should be provided, not both
44-
fmt.Println("Error: godojo only supports a single install option")
45-
fmt.Println("Both -dev and --default have been provided so exiting.")
46-
os.Exit(1)
47-
}
48-
49-
// Handle special install cases of default and dev
50-
if opts.Default || opts.Dev {
51-
return opts
34+
// Handle special install case of default installs
35+
if d.defInstall {
36+
return
5237
}
5338

5439
// See if the dojoConfig.yml is in the local directory
@@ -58,15 +43,16 @@ func readArgs() launchArgs {
5843
fmt.Printf("Error: %v\n", err)
5944
os.Exit(1)
6045
}
61-
_, err = os.Stat(path + "/" + cf)
46+
_, err = os.Stat(path + "/" + d.cf)
6247
if err != nil {
6348
// No config file found, so create one and exit
64-
createDefaultConfig(cf, true)
49+
writeDefaultConfig(d.cf, true)
6550
}
66-
traceMsg("Reached the end of readArgs")
67-
return opts
51+
52+
d.traceMsg("Reached the end of readArgs")
6853
}
6954

55+
// printHelp takes no arguements and prints godojo's help content to stdout
7056
func printHelp() {
7157
// Output the help info
7258
fmt.Println("")
@@ -81,9 +67,6 @@ func printHelp() {
8167
fmt.Println(" -default")
8268
fmt.Println(" OPTIONAL - Do an install based on the default dojoConfig.yml values")
8369
fmt.Println(" Must be used alone and without other arguments")
84-
fmt.Println(" -dev")
85-
fmt.Println(" OPTIONAL - Do an dev install with fixed values especially for testing")
86-
fmt.Println(" Must be used alone and without other arguments")
8770
fmt.Println(" -help, -h")
8871
fmt.Println(" Print this help message and exit, ignoring all other arguments")
8972
fmt.Println(" -version, -v")
@@ -98,40 +81,6 @@ func printHelp() {
9881
fmt.Println(" (Either creates a default config file or installs based on the config file in the same directory)")
9982
fmt.Println("$ ./godojo -dev")
10083
fmt.Println(" (Does a dev aka development/test install using known and fixed values for the installation")
84+
// TODO Consider an example of overriding with an env variable
10185
fmt.Println("")
10286
}
103-
104-
func createDefaultConfig(c string, ex bool) {
105-
// Get the current working directory for future operations
106-
path, err := os.Getwd()
107-
if err != nil {
108-
fmt.Println("Unable to determine current working directory, exiting...")
109-
fmt.Printf("Error: %v\n", err)
110-
os.Exit(1)
111-
}
112-
113-
// Extract the embedded config file
114-
f, err := embd.ReadFile(embdConfig)
115-
if err != nil {
116-
// file was not found.
117-
fmt.Println("Unable to extract embedded config file")
118-
fmt.Printf("Error: %v\n", err)
119-
os.Exit(1)
120-
}
121-
122-
// Write out the embedded default dojoConfig.yml
123-
err = ioutil.WriteFile(path+"/"+c, f, 0644)
124-
if err != nil {
125-
// Cannot write config file
126-
fmt.Printf("Unable to write configuration file in %s, exiting...\n", path)
127-
fmt.Printf("Error: %v\n", err)
128-
}
129-
130-
if ex {
131-
fmt.Println("\nNOTE: A dojoConfig.yml file was not found in the current directory:")
132-
fmt.Printf("\t%s\nA default configuration file was written there.\n\n", path)
133-
fmt.Println("Please review the configuration settings, adjusting as needed and")
134-
fmt.Println("re-run the godojo installer to begin the install you configured.")
135-
os.Exit(0)
136-
}
137-
}

0 commit comments

Comments
 (0)