refactor trivial objects in favor of arguments to static functions

This commit is contained in:
Cory Bennett
2017-08-27 00:47:11 -07:00
parent 5716a7cb59
commit 1f345cedee
49 changed files with 840 additions and 629 deletions
+6 -1
View File
@@ -7,6 +7,7 @@ import (
"io/ioutil"
"os"
"os/exec"
"path"
"path/filepath"
"reflect"
"strings"
@@ -22,6 +23,7 @@ import (
var log = logging.MustGetLogger("figtree")
type FigTree struct {
ConfigDir string
Defaults interface{}
EnvPrefix string
stop bool
@@ -44,7 +46,10 @@ func LoadConfig(configFile string, options interface{}) error {
func (f *FigTree) LoadAllConfigs(configFile string, options interface{}) error {
// reset from any previous config parsing runs
f.stop = false
// assert options is a pointer
if f.ConfigDir != "" {
configFile = path.Join(f.ConfigDir, configFile)
}
paths := FindParentPaths(configFile)
paths = append([]string{fmt.Sprintf("/etc/%s", configFile)}, paths...)
+5 -1
View File
@@ -322,7 +322,6 @@ func (c *Client) Do(req *http.Request) (resp *http.Response, err error) {
if err != nil {
return nil, err
}
// log any cookies sent b/c they will not be present until
// afater we call the `Do` func
if log.IsEnabledFor(logging.DEBUG) && TraceRequestBody {
@@ -335,6 +334,11 @@ func (c *Client) Do(req *http.Request) (resp *http.Response, err error) {
}
}
if log.IsEnabledFor(logging.DEBUG) && TraceResponseBody {
out, _ := httputil.DumpResponse(resp, true)
log.Debugf("Response: %s", out)
}
err = c.saveCookies(resp)
if err != nil {
return resp, err